diff options
| author | Markus Tiede | 2013-07-29 12:27:56 +0000 |
|---|---|---|
| committer | Markus Tiede | 2013-07-29 12:27:56 +0000 |
| commit | e4b810ff14f11fb60c75c3c96a564dca72225c5a (patch) | |
| tree | bbd1cd2732351b76bc2a807de66bd1dd83d499b0 | |
| parent | 6fed03faf787d016ad6a3ae7a51c0ccc22ca49c0 (diff) | |
| download | org.eclipse.jubula.core-e4b810ff14f11fb60c75c3c96a564dca72225c5a.tar.gz org.eclipse.jubula.core-e4b810ff14f11fb60c75c3c96a564dca72225c5a.tar.xz org.eclipse.jubula.core-e4b810ff14f11fb60c75c3c96a564dca72225c5a.zip | |
Non-sprint task - added ability to edit comments for projects / categories in TCB and TSB.
26 files changed, 506 insertions, 262 deletions
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestresultSummaryBP.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestresultSummaryBP.java index 62b92d51d..32e9e8d9a 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestresultSummaryBP.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestresultSummaryBP.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.Map; import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; import org.apache.commons.lang.StringUtils; import org.eclipse.jubula.client.core.ClientTestFactory; @@ -29,17 +30,23 @@ import org.eclipse.jubula.client.core.model.ITestCasePO; import org.eclipse.jubula.client.core.model.ITestJobPO; import org.eclipse.jubula.client.core.model.ITestResultPO; import org.eclipse.jubula.client.core.model.ITestResultSummary; +import org.eclipse.jubula.client.core.model.ITestResultSummaryPO; import org.eclipse.jubula.client.core.model.ITestSuitePO; import org.eclipse.jubula.client.core.model.PoMaker; import org.eclipse.jubula.client.core.model.TestResult; import org.eclipse.jubula.client.core.model.TestResultNode; import org.eclipse.jubula.client.core.model.TestResultParameter; +import org.eclipse.jubula.client.core.persistence.PMException; import org.eclipse.jubula.client.core.persistence.Persistor; +import org.eclipse.jubula.client.core.i18n.Messages; import org.eclipse.jubula.tools.constants.AutConfigConstants; import org.eclipse.jubula.tools.constants.MonitoringConstants; import org.eclipse.jubula.tools.constants.StringConstants; +import org.eclipse.jubula.tools.exception.JBFatalException; +import org.eclipse.jubula.tools.exception.ProjectDeletedException; import org.eclipse.jubula.tools.i18n.CompSystemI18n; import org.eclipse.jubula.tools.i18n.I18n; +import org.eclipse.jubula.tools.messagehandling.MessageIDs; import org.eclipse.jubula.tools.objects.event.TestErrorEvent; import org.eclipse.jubula.tools.utils.TimeUtil; @@ -331,6 +338,42 @@ public class TestresultSummaryBP { } } + + /** + * perform model changes + * + * @param selectedSummary the summary to change the comment for + * @param newTitle the new comment title + * @param newDetails the new comment details + */ + public void setCommentTitleAndDetails( + ITestResultSummaryPO selectedSummary, String newTitle, + String newDetails) { + + final EntityManager sess = Persistor.instance().openSession(); + try { + final EntityTransaction tx = + Persistor.instance().getTransaction(sess); + + ITestResultSummaryPO transactionSummary = + sess.merge(selectedSummary); + + transactionSummary.setCommentTitle(newTitle); + transactionSummary.setCommentDetail(newDetails); + + Persistor.instance().commitTransaction(sess, tx); + ClientTestFactory.getClientTest().fireTestresultSummaryChanged(); + } catch (PMException e) { + throw new JBFatalException(Messages.StoringOfMetadataFailed, e, + MessageIDs.E_DATABASE_GENERAL); + } catch (ProjectDeletedException e) { + throw new JBFatalException(Messages.StoringOfMetadataFailed, e, + MessageIDs.E_PROJECT_NOT_FOUND); + } finally { + Persistor.instance().dropSession(sess); + } + } + /** * @return instance of TestresultSummaryBP */ diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CategoryPO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CategoryPO.java index d4ad089c0..4ca524fa2 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CategoryPO.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CategoryPO.java @@ -12,14 +12,10 @@ package org.eclipse.jubula.client.core.model; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import javax.persistence.Transient; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /**
- * class to manage nodes in Specification Tree, which support grouping of nodes
+ * Class to manage grouping of nodes
*
* @author BREDEX GmbH
* @created 08.06.2005
@@ -27,10 +23,6 @@ import org.slf4j.LoggerFactory; @Entity
@DiscriminatorValue(value = "Y")
class CategoryPO extends NodePO implements ICategoryPO {
-
- /** The logger */
- private static final Logger LOG = LoggerFactory.getLogger(CategoryPO.class);
-
/**
* @param name name
* @param isGenerated indicates whether this node has been generated
@@ -54,12 +46,4 @@ class CategoryPO extends NodePO implements ICategoryPO { CategoryPO() {
// nothing
}
-
- /** {@inheritDoc}
- * @see org.eclipse.jubula.client.core.model.NodePO#isInterfaceLocked()
- */
- @Transient
- public Boolean isReused() {
- return true;
- }
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java index 295f8520b..65986f18c 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java @@ -22,6 +22,11 @@ import org.eclipse.jubula.client.core.businessprocess.problems.IProblem; */ public interface INodePO extends ITimestampPO { /** + * maximum length of strings in database + */ + public static final int MAX_STRING_LENGTH = 4000; + + /** * @return The name of this node */ public abstract String getName(); diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java index 28b5cf4ce..f397b0b46 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java @@ -186,10 +186,11 @@ abstract class NodePO implements INodePO { * @return the name of the node */ @Basic - @Column(name = "NAME", length = 4000) + @Column(name = "NAME", length = MAX_STRING_LENGTH) private String getHbmName() { return m_name; } + /** * For Persistence (JPA / EclipseLink) only * Sets the value of the m_name property. @@ -282,7 +283,7 @@ abstract class NodePO implements INodePO { * @return Returns the m_comment. */ @Basic - @Column(name = "COMM_TXT", length = 4000) + @Column(name = "COMM_TXT", length = MAX_STRING_LENGTH) private String getHbmComment() { return m_comment; } diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ProjectPO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ProjectPO.java index f61f2d971..4dda4bb80 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ProjectPO.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ProjectPO.java @@ -127,7 +127,6 @@ class ProjectPO extends ParamNodePO implements IProjectPO { } /** - * * {@inheritDoc} */ @Transient diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java index 4eb21026b..e02dd0914 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java @@ -400,7 +400,6 @@ public class NodePM extends PersistenceManager { } } - /** * @param node * the node to be renamed @@ -433,6 +432,37 @@ public class NodePM extends PersistenceManager { } } + /** + * @param node + * the node to be renamed + * @param newComment + * the new comment + * @throws PMDirtyVersionException + * in case of dirty version + * @throws PMAlreadyLockedException + * in case of locked node + * @throws PMSaveException + * in case of DB save error + * @throws PMException in case of general db error + * @throws ProjectDeletedException if the project was deleted in another + * instance + */ + public static void setComment(INodePO node, String newComment) + throws PMDirtyVersionException, PMAlreadyLockedException, + PMSaveException, PMException, ProjectDeletedException { + + EntityManager sess = GeneralStorage.getInstance().getMasterSession(); + EntityTransaction tx = null; + try { + final Persistor persistor = Persistor.instance(); + tx = persistor.getTransaction(sess); + persistor.lockPO(sess, node); + node.setComment(newComment); + persistor.commitTransaction(sess, tx); + } catch (PersistenceException e) { + PersistenceManager.handleDBExceptionForMasterSession(node, e); + } + } /** * @param cat category, which is the parent of the testcases to import diff --git a/org.eclipse.jubula.client.ui.rcp/plugin.xml b/org.eclipse.jubula.client.ui.rcp/plugin.xml index ace1f593f..6c58ed072 100644 --- a/org.eclipse.jubula.client.ui.rcp/plugin.xml +++ b/org.eclipse.jubula.client.ui.rcp/plugin.xml @@ -169,6 +169,11 @@ </extension> <extension point="org.eclipse.core.runtime.adapters"> <factory + adaptableType="org.eclipse.jubula.client.core.model.ICategoryPO" + class="org.eclipse.jubula.client.ui.rcp.adapter.PropertySourceAdapterFactory"> + <adapter type="org.eclipse.ui.views.properties.IPropertySource" /> + </factory> + <factory adaptableType="org.eclipse.jubula.client.core.model.IComponentNamePO" class="org.eclipse.jubula.client.ui.rcp.adapter.PropertySourceAdapterFactory"> <adapter type="org.eclipse.ui.views.properties.IPropertySource" /> @@ -199,7 +204,7 @@ <adapter type="org.eclipse.ui.views.properties.IPropertySource" /> </factory> <factory - adaptableType="org.eclipse.jubula.client.core.model.IProjectPO" + adaptableType="org.eclipse.jubula.client.core.model.IExecObjContPO" class="org.eclipse.jubula.client.ui.rcp.adapter.PropertySourceAdapterFactory"> <adapter type="org.eclipse.ui.views.properties.IPropertySource" /> </factory> @@ -1742,6 +1747,10 @@ commandId="org.eclipse.jubula.client.ui.rcp.commands.CopyID" style="push"> </command> + <command + commandId="org.eclipse.jubula.client.ui.commands.AddComment" + style="push"> + </command> <separator name="separator3" visible="true"> @@ -1845,6 +1854,10 @@ commandId="org.eclipse.jubula.client.ui.rcp.commands.CopyID" style="push"> </command> + <command + commandId="org.eclipse.jubula.client.ui.commands.AddComment" + style="push"> + </command> <separator name="separator3" visible="true"> </separator> @@ -2073,6 +2086,33 @@ </enabledWhen> </handler> <handler + class="org.eclipse.jubula.client.ui.rcp.handlers.EditNodeComment" + commandId="org.eclipse.jubula.client.ui.commands.AddComment"> + <activeWhen> + <or> + <with variable="activePartId"> + <equals value="org.eclipse.jubula.client.ui.rcp.views.TestCaseBrowser" /> + </with> + <with variable="activePartId"> + <equals value="org.eclipse.jubula.client.ui.rcp.views.TestSuiteBrowser" /> + </with> + </or> + </activeWhen> + <enabledWhen> + <and> + <count value="1" /> + <iterate + ifEmpty="false" + operator="and"> + <or> + <instanceof value="org.eclipse.jubula.client.core.model.ICategoryPO" /> + </or> + <test property="org.eclipse.jubula.client.ui.rcp.model.isEditable" /> + </iterate> + </and> + </enabledWhen> + </handler> + <handler class="org.eclipse.jubula.client.ui.rcp.handlers.rename.RenameTreeItemHandlerTSBrowser" commandId="org.eclipse.ui.edit.rename"> <activeWhen> diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/adapter/PropertySourceAdapterFactory.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/adapter/PropertySourceAdapterFactory.java index 439928e0d..9f2558b24 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/adapter/PropertySourceAdapterFactory.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/adapter/PropertySourceAdapterFactory.java @@ -12,8 +12,10 @@ package org.eclipse.jubula.client.ui.rcp.adapter; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.jubula.client.core.model.ICapPO; +import org.eclipse.jubula.client.core.model.ICategoryPO; import org.eclipse.jubula.client.core.model.IComponentNamePO; import org.eclipse.jubula.client.core.model.IEventExecTestCasePO; +import org.eclipse.jubula.client.core.model.IExecObjContPO; import org.eclipse.jubula.client.core.model.IExecTestCasePO; import org.eclipse.jubula.client.core.model.IObjectMappingAssoziationPO; import org.eclipse.jubula.client.core.model.IProjectPO; @@ -21,8 +23,10 @@ import org.eclipse.jubula.client.core.model.IRefTestSuitePO; import org.eclipse.jubula.client.core.model.ISpecTestCasePO; import org.eclipse.jubula.client.core.model.ITestJobPO; import org.eclipse.jubula.client.core.model.ITestSuitePO; +import org.eclipse.jubula.client.core.persistence.GeneralStorage; import org.eclipse.jubula.client.ui.rcp.controllers.propertysources.AutIdentifierPropertySource; import org.eclipse.jubula.client.ui.rcp.controllers.propertysources.CapGUIPropertySource; +import org.eclipse.jubula.client.ui.rcp.controllers.propertysources.CategoryGUIPropertySource; import org.eclipse.jubula.client.ui.rcp.controllers.propertysources.EventExecTestCaseGUIPropertySource; import org.eclipse.jubula.client.ui.rcp.controllers.propertysources.ExecTestCaseGUIPropertySource; import org.eclipse.jubula.client.ui.rcp.controllers.propertysources.OMLogicNameGUIPropertySource; @@ -49,7 +53,8 @@ public class PropertySourceAdapterFactory implements IAdapterFactory { IComponentNamePO.class, IObjectMappingAssoziationPO.class, AutIdentifier.class, ITestSuitePO.class, ISpecTestCasePO.class, ICapPO.class, IEventExecTestCasePO.class, IExecTestCasePO.class, - IProjectPO.class, IRefTestSuitePO.class, ITestJobPO.class + IExecObjContPO.class, IRefTestSuitePO.class, ITestJobPO.class, + ICategoryPO.class }; /** @@ -82,12 +87,16 @@ public class PropertySourceAdapterFactory implements IAdapterFactory { } else if (adaptableObject instanceof IExecTestCasePO) { return new ExecTestCaseGUIPropertySource( (IExecTestCasePO)adaptableObject); - } else if (adaptableObject instanceof IProjectPO) { - return new ProjectGUIPropertySource( - (IProjectPO)adaptableObject); + } else if (adaptableObject instanceof IExecObjContPO) { + IProjectPO project = GeneralStorage + .getInstance().getProject(); + return new ProjectGUIPropertySource(project); } else if (adaptableObject instanceof IRefTestSuitePO) { return new RefTestSuiteGUIPropertySource( (IRefTestSuitePO)adaptableObject); + } else if (adaptableObject instanceof ICategoryPO) { + return new CategoryGUIPropertySource( + (ICategoryPO)adaptableObject); } else if (adaptableObject instanceof ITestJobPO) { return new TestJobGUIPropertySource( (ITestJobPO)adaptableObject); diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/AbstractGuiNodePropertySource.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/AbstractGuiNodePropertySource.java index 66dd38602..7ddf2b374 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/AbstractGuiNodePropertySource.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/AbstractGuiNodePropertySource.java @@ -63,7 +63,7 @@ public abstract class AbstractGuiNodePropertySource private TestCaseParamBP m_testCaseParamBP; /** - * a usable readonly flag + * a usable read only flag */ private boolean m_readOnly; @@ -106,10 +106,8 @@ public abstract class AbstractGuiNodePropertySource * @created 04.08.2005 */ protected class CommentController extends AbstractPropertyController { - /** * {@inheritDoc} - * @param value */ public boolean setProperty(Object value) { if (value != null) { @@ -122,7 +120,6 @@ public abstract class AbstractGuiNodePropertySource /** * {@inheritDoc} - * @return */ public Object getProperty() { if (getPoNode() != null && getPoNode().getComment() != null) { @@ -133,12 +130,10 @@ public abstract class AbstractGuiNodePropertySource /** * {@inheritDoc} - * @return */ public Image getImage() { return DEFAULT_IMAGE; } - } /** diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/CategoryGUIPropertySource.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/CategoryGUIPropertySource.java new file mode 100644 index 000000000..f012961d9 --- /dev/null +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/CategoryGUIPropertySource.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2013 BREDEX GmbH. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * BREDEX GmbH - initial API and implementation and/or initial documentation + *******************************************************************************/ +package org.eclipse.jubula.client.ui.rcp.controllers.propertysources; + +import org.eclipse.jubula.client.core.model.ICategoryPO; +import org.eclipse.jubula.client.ui.rcp.i18n.Messages; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +/** + * @author BREDEX GmbH + */ +public class CategoryGUIPropertySource extends AbstractGuiNodePropertySource { + /** cached property descriptor for name */ + private IPropertyDescriptor m_namePropDesc = null; + + /** + * @param category + * the category + */ + public CategoryGUIPropertySource(ICategoryPO category) { + super(category); + } + + /** {@inheritDoc} */ + protected void initPropDescriptor() { + if (!getPropertyDescriptorList().isEmpty()) { + clearPropertyDescriptors(); + } + + // Project Name + if (m_namePropDesc == null) { + m_namePropDesc = new TextPropertyDescriptor( + new ElementNameController(), + Messages.CategoryGUIPropertySourceName); + } + addPropertyDescriptor(m_namePropDesc); + // Project Comment + super.initPropDescriptor(); + } +}
\ No newline at end of file diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/ProjectGUIPropertySource.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/ProjectGUIPropertySource.java index 7408f759f..0262b66ec 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/ProjectGUIPropertySource.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/propertysources/ProjectGUIPropertySource.java @@ -21,26 +21,18 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; * @created 06.12.2005 */ public class ProjectGUIPropertySource extends AbstractGuiNodePropertySource { - - - /** Constant for the String TestCase Name */ - public static final String P_ELEMENT_DISPLAY_NAME = - Messages.ProjectGUIPropertySourceProjectName; - /** cached property descriptor for name */ private IPropertyDescriptor m_namePropDesc = null; - /** - * @param guiNode the ProjectGUI + * @param project + * the project */ - public ProjectGUIPropertySource(IProjectPO guiNode) { - super(guiNode); + public ProjectGUIPropertySource(IProjectPO project) { + super(project); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void initPropDescriptor() { if (!getPropertyDescriptorList().isEmpty()) { clearPropertyDescriptors(); @@ -49,8 +41,11 @@ public class ProjectGUIPropertySource extends AbstractGuiNodePropertySource { // Project Name if (m_namePropDesc == null) { m_namePropDesc = new TextPropertyDescriptor( - new ElementNameController(), P_ELEMENT_DISPLAY_NAME); + new ElementNameController(), + Messages.ProjectGUIPropertySourceProjectName); } addPropertyDescriptor(m_namePropDesc); + // Project Comment + super.initPropDescriptor(); } }
\ No newline at end of file diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java index de2737c31..397cb33ad 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/dialogs/ProjectDialog.java @@ -110,16 +110,6 @@ public class ProjectDialog extends TitleAreaDialog { private ProjectData m_selection; /** - * label of name combo - */ - private String m_label = Messages.OpenProjectActionLabel; - - /** - * label of the version combo - */ - private String m_label2 = Messages.OpenProjectActionLabel2; - - /** * <code>m_title</code> title */ private String m_title; @@ -140,9 +130,9 @@ public class ProjectDialog extends TitleAreaDialog { private Button m_defaultProject; /** - * <code>m_isDeleteAction</code> true if dialog is "delete project"-dialog + * <code>m_isDeleteOperation</code> true if dialog is "delete project"-dialog */ - private boolean m_isDeleteAction = false; + private boolean m_isDeleteOperation = false; /** * check box to define if test result summary should not be deleted, when project is deleted @@ -282,8 +272,9 @@ public class ProjectDialog extends TitleAreaDialog { m_title = title; m_image = image; m_shellTitle = shellTitle; - m_isDeleteAction = isDeleteAction; + m_isDeleteOperation = isDeleteAction; } + /** * {@inheritDoc} */ @@ -319,7 +310,7 @@ public class ProjectDialog extends TitleAreaDialog { createComboBoxes(area); createDefaultProjectCheckbox(area); - if (m_isDeleteAction) { + if (m_isDeleteOperation) { createDeleteTestresultsCheckbox(area); } @@ -349,7 +340,7 @@ public class ProjectDialog extends TitleAreaDialog { */ private void createComboBoxes(Composite parent) { createEmptyLabel(parent); - new Label(parent, SWT.NONE).setText(m_label); + new Label(parent, SWT.NONE).setText(Messages.OpenProjectActionLabel); m_nameComboBox = new DirectCombo<String>(parent, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, m_guidList, m_nameList, false, true); GridData gridData = newGridData(); @@ -373,7 +364,7 @@ public class ProjectDialog extends TitleAreaDialog { m_versionList = m_guidToVersionMap.get( m_nameComboBox.getSelectedObject()); createEmptyLabel(parent); - new Label(parent, SWT.NONE).setText(m_label2); + new Label(parent, SWT.NONE).setText(Messages.OpenProjectActionLabel2); m_versionComboBox = new DirectCombo<String>(parent, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, m_versionList, m_versionList, false, @@ -409,7 +400,7 @@ public class ProjectDialog extends TitleAreaDialog { * @param composite the parent composite */ private void createDefaultProjectCheckbox(Composite composite) { - if (!m_isDeleteAction) { + if (!m_isDeleteOperation) { createEmptyLabel(composite); new Label(composite, SWT.NONE).setLayoutData(new GridData( GridData.FILL, GridData.CENTER, false, false, @@ -455,7 +446,7 @@ public class ProjectDialog extends TitleAreaDialog { m_versionComboBox.getSelectedObject()); final ProjectUIBP defaultProject = ProjectUIBP.getInstance(); - if (m_isDeleteAction) { + if (m_isDeleteOperation) { m_keepTestresultSummary = m_keepTestresultSummaryButton .getSelection(); } else if (m_defaultProject.getSelection()) { diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddTestResultSummaryCommentHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddTestResultSummaryCommentHandler.java index a4dab0d12..1f41a001e 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddTestResultSummaryCommentHandler.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddTestResultSummaryCommentHandler.java @@ -10,27 +10,16 @@ *******************************************************************************/ package org.eclipse.jubula.client.ui.rcp.handlers; -import javax.persistence.EntityManager; -import javax.persistence.EntityTransaction; - import org.apache.commons.lang.StringUtils; import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.databinding.validation.IValidator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jface.window.Window; -import org.eclipse.jubula.client.core.ClientTestFactory; +import org.eclipse.jubula.client.core.businessprocess.TestresultSummaryBP; import org.eclipse.jubula.client.core.model.ITestResultSummaryPO; -import org.eclipse.jubula.client.core.persistence.PMException; -import org.eclipse.jubula.client.core.persistence.Persistor; import org.eclipse.jubula.client.ui.constants.ContextHelpIds; -import org.eclipse.jubula.client.ui.dialogs.EnterCommentDialog; +import org.eclipse.jubula.client.ui.dialogs.EnterCommentAndDetailsDialog; import org.eclipse.jubula.client.ui.handlers.AbstractTestResultViewHandler; -import org.eclipse.jubula.client.ui.i18n.Messages; +import org.eclipse.jubula.client.ui.rcp.validator.MaxStringLengthValidator; import org.eclipse.jubula.client.ui.utils.DialogUtils; -import org.eclipse.jubula.tools.exception.JBFatalException; -import org.eclipse.jubula.tools.exception.ProjectDeletedException; -import org.eclipse.jubula.tools.messagehandling.MessageIDs; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; @@ -51,16 +40,10 @@ public class AddTestResultSummaryCommentHandler final String origTitle = selectedSummary.getCommentTitle(); final String origDetail = selectedSummary.getCommentDetail(); - EnterCommentDialog dialog = new EnterCommentDialog(HandlerUtil - .getActiveShell(event), new IValidator() { - public IStatus validate(Object value) { - if (value instanceof String) { - return (((String)value).length() < 4000) - ? Status.OK_STATUS : Status.CANCEL_STATUS; - } - return Status.OK_STATUS; - } - }, origTitle, origDetail); + EnterCommentAndDetailsDialog dialog = + new EnterCommentAndDetailsDialog( + HandlerUtil.getActiveShell(event), + new MaxStringLengthValidator(), origTitle, origDetail); dialog.setHelpAvailable(true); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); @@ -74,44 +57,11 @@ public class AddTestResultSummaryCommentHandler String newDetails = dialog.getCommentDetail(); if (!StringUtils.equals(origTitle, newTitle) || !StringUtils.equals(origDetail, newDetails)) { - performOperation(selectedSummary, newTitle, newDetails); + TestresultSummaryBP.getInstance().setCommentTitleAndDetails( + selectedSummary, newTitle, newDetails); } } return null; } - - /** - * perform model changes - * - * @param selectedSummary the summary to change the comment for - * @param newTitle the new comment title - * @param newDetails the new comment details - */ - private void performOperation(ITestResultSummaryPO selectedSummary, - String newTitle, String newDetails) { - - final EntityManager sess = Persistor.instance().openSession(); - try { - final EntityTransaction tx = - Persistor.instance().getTransaction(sess); - - ITestResultSummaryPO transactionSummary = - sess.merge(selectedSummary); - - transactionSummary.setCommentTitle(newTitle); - transactionSummary.setCommentDetail(newDetails); - - Persistor.instance().commitTransaction(sess, tx); - ClientTestFactory.getClientTest().fireTestresultSummaryChanged(); - } catch (PMException e) { - throw new JBFatalException(Messages.StoringOfMetadataFailed, e, - MessageIDs.E_DATABASE_GENERAL); - } catch (ProjectDeletedException e) { - throw new JBFatalException(Messages.StoringOfMetadataFailed, e, - MessageIDs.E_PROJECT_NOT_FOUND); - } finally { - Persistor.instance().dropSession(sess); - } - } } diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditNodeComment.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditNodeComment.java new file mode 100644 index 000000000..6c599e2ee --- /dev/null +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditNodeComment.java @@ -0,0 +1,60 @@ +package org.eclipse.jubula.client.ui.rcp.handlers; + +import org.apache.commons.lang.StringUtils; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.jface.window.Window; +import org.eclipse.jubula.client.core.events.DataEventDispatcher; +import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState; +import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState; +import org.eclipse.jubula.client.core.model.INodePO; +import org.eclipse.jubula.client.core.persistence.NodePM; +import org.eclipse.jubula.client.core.persistence.PMException; +import org.eclipse.jubula.client.ui.constants.ContextHelpIds; +import org.eclipse.jubula.client.ui.dialogs.EnterCommentDialog; +import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler; +import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler; +import org.eclipse.jubula.client.ui.rcp.validator.MaxStringLengthValidator; +import org.eclipse.jubula.client.ui.utils.DialogUtils; +import org.eclipse.jubula.tools.exception.ProjectDeletedException; +import org.eclipse.ui.PlatformUI; + +/** + * @author BREDEX GmbH + */ +public class EditNodeComment extends AbstractSelectionBasedHandler { + /** {@inheritDoc} */ + public Object executeImpl(ExecutionEvent event) { + INodePO node = getFirstElement(INodePO.class); + + if (node != null) { + final String origComment = node.getComment(); + + EnterCommentDialog dialog = new EnterCommentDialog( + getActiveShell(), new MaxStringLengthValidator(), + origComment); + dialog.setHelpAvailable(true); + dialog.create(); + DialogUtils.setWidgetNameForModalDialog(dialog); + PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), + ContextHelpIds.ADD_COMMENT); + int result = dialog.open(); + if (result != Window.OK) { + return null; + } + String newComment = dialog.getCommentTitle(); + if (!StringUtils.equals(origComment, newComment)) { + try { + NodePM.setComment(node, newComment); + DataEventDispatcher.getInstance().fireDataChangedListener( + node, DataState.Renamed, UpdateState.all); + } catch (PMException e) { + PMExceptionHandler.handlePMExceptionForMasterSession(e); + } catch (ProjectDeletedException e) { + PMExceptionHandler.handleProjectDeletedException(); + } + } + } + + return null; + } +} diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ToggleRelevanceHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ToggleRelevanceHandler.java index 09b83ad18..1599c334e 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ToggleRelevanceHandler.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ToggleRelevanceHandler.java @@ -19,7 +19,7 @@ import org.eclipse.jubula.client.core.model.ITestResultSummaryPO; import org.eclipse.jubula.client.core.persistence.PMException; import org.eclipse.jubula.client.core.persistence.Persistor; import org.eclipse.jubula.client.ui.handlers.AbstractTestResultViewHandler; -import org.eclipse.jubula.client.ui.i18n.Messages; +import org.eclipse.jubula.client.core.i18n.Messages; import org.eclipse.jubula.tools.exception.JBFatalException; import org.eclipse.jubula.tools.exception.ProjectDeletedException; import org.eclipse.jubula.tools.messagehandling.MessageIDs; @@ -29,9 +29,7 @@ import org.eclipse.jubula.tools.messagehandling.MessageIDs; * @created Mar 3, 2011 */ public class ToggleRelevanceHandler extends AbstractTestResultViewHandler { - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public Object executeImpl(ExecutionEvent event) { ITestResultSummaryPO selectedSummary = getSelectedSummary(event); diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java index 7ad10f805..3d45d751a 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java @@ -124,6 +124,7 @@ public class Messages extends NLS { public static String CapGUIAction; public static String CapGUIName; public static String CapGUIType; + public static String CategoryGUIPropertySourceName; public static String CentralTestDataEditorName; public static String ClassPathDialogAddDir; public static String ClassPathDialogDir; @@ -539,6 +540,7 @@ public class Messages extends NLS { public static String ProjectPropertyPageNoProjectLanguage; public static String ProjectPropertyPageProjectGuid; public static String ProjectPropertyPageProjectName; + public static String ProjectPropertyPageProjectDescr; public static String ProjectPropertyPageProjectVersion; public static String ProjectPropertyPageReusableProjectsAllDownToolTip; public static String ProjectPropertyPageReusableProjectsAllUpToolTip; @@ -718,6 +720,7 @@ public class Messages extends NLS { public static String StopAUTActionQuestionText; public static String StopAUTActionQuestionTextIfcollecting; public static String StopAUTActionShellTitle; + public static String StoringOfMetadataFailed; public static String TestCaseBrowser; public static String TestCaseBrowserMainPrefix; public static String TestCaseBrowserLinkWithEditor; diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties index 5749d8a27..1034620d1 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties @@ -109,7 +109,8 @@ CannotRemoveLastProjectDialogMsg=You cannot remove the last Language from the Pr CantLoadProjectInEditSession=Can't load project in edit session CapGUIAction=ACTION\: CapGUIName=NAME\: -CapGUIType=TYPE\: +CapGUIType=TYPE\: +CategoryGUIPropertySourceName=Category Name CentralTestDataEditorName=Central Test Data ClassPathDialogAddDir=Add a directory to AUT classpath. ClassPathDialogDir=Browse directory... @@ -517,7 +518,7 @@ ProblemCheckerReusedProjectMissingLanguage=Reused Project "{0}" does not support Project=PROJECT ProjectGUIPropertySourceProjectName=Project Name ProjectInfoWizardPageInfoText=The data for the Project are now complete.\nClick "Finish" to create this Project.\nTo add / edit / remove AUT's, use the Project Properties.\n\nThe next step is to create Test Cases and Test Suites. -ProjectPropertyPageAutToolKitLabel=Toolkit for Test\nSpecification\: +ProjectPropertyPageAutToolKitLabel=Test Specification Toolkit\: ProjectPropertyPageDownToolTip=Add a selected available language to the list of Project languages. ProjectPropertyPageIsProtected=Is Protected\: ProjectPropertyPageIsReusable=Is Reusable\: @@ -525,6 +526,7 @@ ProjectPropertyPageLanguageLabel=Select the default language for this project\: ProjectPropertyPageNoProjectLanguage=You have to choose at least one Project language. ProjectPropertyPageProjectGuid=Project GUID\: ProjectPropertyPageProjectName=Project name\: +ProjectPropertyPageProjectDescr=Project description\: ProjectPropertyPageProjectVersion=Project version\: ProjectPropertyPageReusableProjectsAllDownToolTip=Add all available reusable projects to the list of reused Projects. ProjectPropertyPageReusableProjectsAllUpToolTip=Remove all reused projects from the list of reused Projects. @@ -704,6 +706,7 @@ StatusLine_NotConnected=Not connected to AUT Agent StopAUTActionQuestionText=Are you sure you want to stop the AUT? StopAUTActionQuestionTextIfcollecting=The client is still collecting monitoring data.\nExiting the AUT now might corrupt the collected data\!\nAre you sure you want to stop the AUT? StopAUTActionShellTitle=Stop running AUT? +StoringOfMetadataFailed=Storing of metadata failed. TestCaseBrowser=Test Case Browser TestCaseBrowserMainPrefix=Main TestCaseBrowserLinkWithEditor=Link with Editor @@ -780,7 +783,7 @@ TestResultViewPreferencePageAutoScreenshots=Automatically take screenshots (save TestResultViewPreferencePageBrowse=&Browse TestResultViewPreferencePageCleanDaysLabel=days TestResultViewPreferencePageCleanResultDaysEmpty=Please specify a valid value for automatic deletion of test results. -TestResultViewPreferencePageCleanResults=&Clean test results after +TestResultViewPreferencePageCleanResults=Days to &keep the test results TestResultViewPreferencePageDescription=This is the preference page for the test result settings. TestResultViewPreferencePageDirSelector=Select directory where XML/HTML reports should be saved. TestResultViewPreferencePageGenerateReport=&Generate XML/HTML Test Result Reports diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/properties/ProjectGeneralPropertyPage.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/properties/ProjectGeneralPropertyPage.java index 378a57a9b..fe551b5ba 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/properties/ProjectGeneralPropertyPage.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/properties/ProjectGeneralPropertyPage.java @@ -16,6 +16,7 @@ import java.util.Set; import javax.persistence.EntityNotFoundException; +import org.apache.commons.lang.StringUtils; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jubula.client.core.businessprocess.ComponentNamesBP; import org.eclipse.jubula.client.core.businessprocess.ProjectNameBP; @@ -138,6 +139,10 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { /** set of listeners to be informed when ok has been pressed */ private Set<IOkListener> m_okListenerList = new HashSet<IOkListener>(); + /** + * the projects description text field + */ + private Text m_projectDescriptionTextField; /** * @param es the editSupport @@ -168,6 +173,9 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { createEmptyLabel(projectNameComposite); createProjectNameField(projectNameComposite); + createProjectDescrField(projectNameComposite); + createProjectVersionInfo(projectNameComposite); + createProjectGuidInfo(projectNameComposite); createEmptyLabel(projectNameComposite); separator(projectNameComposite, NUM_COLUMNS_2); @@ -179,8 +187,6 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { createIsReusable(projectNameComposite); createIsProtected(projectNameComposite); - createVersionInfo(projectNameComposite); - createGuidInfo(projectNameComposite); separator(projectNameComposite, NUM_COLUMNS_2); createEmptyLabel(projectNameComposite); @@ -214,7 +220,7 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { /** * @param parent the parent composite */ - private void createVersionInfo(Composite parent) { + private void createProjectVersionInfo(Composite parent) { Composite leftComposite = createComposite(parent, NUM_COLUMNS_1, GridData.BEGINNING, false); Composite rightComposite = createComposite(parent, 3, @@ -235,7 +241,7 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { /** * @param parent the parent composite */ - private void createGuidInfo(Composite parent) { + private void createProjectGuidInfo(Composite parent) { Composite leftComposite = createComposite(parent, NUM_COLUMNS_1, GridData.BEGINNING, false); Composite rightComposite = createComposite(parent, 3, @@ -245,8 +251,7 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { Messages.ProjectPropertyPageProjectGuid), "ControlDecorator.ProjectPropertiesGUID", false); //$NON-NLS-1$ - Text projectGuid = new Text(rightComposite, - SWT.READ_ONLY | SWT.BORDER); + Label projectGuid = new Label(rightComposite, SWT.NONE); projectGuid.setText(m_projectGuid); Label l = createLabel(rightComposite, StringConstants.EMPTY); GridData layoutData = new GridData(); @@ -345,7 +350,7 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { /** * Creates a separator line. * @param composite The parent composite. - * @param horSpan The horizonzal span. + * @param horSpan The horizontal span. */ private void separator(Composite composite, int horSpan) { createLabel(composite, StringConstants.EMPTY); @@ -381,6 +386,30 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { } /** + * Creates the textfield for the project description. + * + * @param parent + * The parent composite. + */ + private void createProjectDescrField(Composite parent) { + Composite leftComposite = createComposite(parent, NUM_COLUMNS_1, + GridData.BEGINNING, false); + Composite rightComposite = createComposite(parent, NUM_COLUMNS_1, + GridData.FILL, true); + createLabel(leftComposite, Messages.ProjectPropertyPageProjectDescr); + m_projectDescriptionTextField = new Text(rightComposite, SWT.BORDER); + m_projectDescriptionTextField.setText(StringUtils + .defaultString(getProject().getComment())); + GridData textGridData = new GridData(); + textGridData.grabExcessHorizontalSpace = true; + textGridData.horizontalAlignment = GridData.FILL; + LayoutUtil.addToolTipAndMaxWidth( + textGridData, m_projectDescriptionTextField); + m_projectDescriptionTextField.setLayoutData(textGridData); + LayoutUtil.setMaxChar(m_projectDescriptionTextField); + } + + /** * @param parent the parent composite */ private void createAutToolKit(Composite parent) { @@ -389,26 +418,13 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { Composite rightComposite = createComposite(parent, NUM_COLUMNS_2, GridData.FILL, true); createLabel(leftComposite, Messages.ProjectPropertyPageAutToolKitLabel); - m_projectToolkitCombo = createToolkitCombo(rightComposite); + m_projectToolkitCombo = ControlFactory + .createProjectToolkitCombo(rightComposite); m_projectToolkitCombo.setSelectedObject(getProject().getToolkit()); GridData textGridData = new GridData(); textGridData.grabExcessHorizontalSpace = true; textGridData.horizontalAlignment = GridData.FILL; m_projectToolkitCombo.setLayoutData(textGridData); - Label l = createLabel(rightComposite, StringConstants.EMPTY); - GridData txtGridData = new GridData(); - txtGridData.grabExcessHorizontalSpace = true; - txtGridData.horizontalAlignment = GridData.FILL; - l.setLayoutData(txtGridData); - } - - /** - * Creates the toolkit combo. - * @param parent the parent. - * @return the toolkit combo. - */ - private DirectCombo<String> createToolkitCombo(Composite parent) { - return ControlFactory.createProjectToolkitCombo(parent); } /** @@ -463,14 +479,8 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { } }); - Label label = new Label(parent, SWT.NONE); - label.setText(Messages.TestResultViewPreferencePageCleanDaysLabel); - gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gridData.horizontalSpan = 1; - gridData.grabExcessHorizontalSpace = false; - label.setLayoutData(gridData); enableCleanResultDaysTextfield(); - ControlDecorator.decorateInfo(label, + ControlDecorator.decorateInfo(m_cleanResultDays, "TestResultViewPreferencePage.cleanResultsInfo", false); //$NON-NLS-1$ } @@ -503,19 +513,21 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { return false; } } + IProjectPO project = getProject(); if (m_isReusableCheckbox != null) { - getProject().setIsReusable( - m_isReusableCheckbox.getSelection()); + project.setIsReusable(m_isReusableCheckbox.getSelection()); } if (m_isProtectedCheckbox != null) { - getProject().setIsProtected( - m_isProtectedCheckbox.getSelection()); + project.setIsProtected(m_isProtectedCheckbox.getSelection()); + } + if (m_projectDescriptionTextField != null) { + project.setComment(m_projectDescriptionTextField.getText()); } storeAutoTestResultCleanup(); if (!m_oldProjectName.equals(m_newProjectName)) { ProjectNameBP.getInstance().setName( - getEditSupport().getSession(), getProject().getGuid(), + getEditSupport().getSession(), project.getGuid(), m_newProjectName); } fireOkPressed(); @@ -527,9 +539,9 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { .getUsedProjects()); newReused.removeAll(origReused); getEditSupport().saveWorkVersion(); - refreshAutMainList(); - DataEventDispatcher.getInstance().fireProjectStateChanged( - ProjectState.prop_modified); + refreshProject(); + DataEventDispatcher ded = DataEventDispatcher.getInstance(); + ded.fireProjectStateChanged(ProjectState.prop_modified); for (IReusedProjectPO reused : newReused) { try { IProjectPO reusedProject = @@ -549,12 +561,11 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { // FIXME zeb This updates the Test Case Browser. Once we have separate // EditSupports for each property page, then we can use // "real" ReusedProjectPOs instead of a placeholder. - DataEventDispatcher.getInstance().fireDataChangedListener( + ded.fireDataChangedListener( PoMaker.createReusedProjectPO("1", 1, 1), //$NON-NLS-1$ DataState.ReuseChanged, UpdateState.notInEditor); - DataEventDispatcher.getInstance().fireDataChangedListener( - GeneralStorage.getInstance().getProject(), - DataState.Renamed, UpdateState.notInEditor); + ded.fireDataChangedListener(GeneralStorage.getInstance() + .getProject(), DataState.Renamed, UpdateState.notInEditor); CompletenessBP.getInstance().completeProjectCheck(); } catch (PMException e) { ErrorHandlingUtil.createMessageDialog(e, null, null); @@ -564,7 +575,6 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { ErrorHandlingUtil.createMessageDialog( ite, ite.getErrorMessageParams(), null); } - return true; } @@ -596,23 +606,21 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { } /** - * Refreshes the AutMainList of the Project. + * Refreshes the project. */ - private void refreshAutMainList() throws ProjectDeletedException { + private void refreshProject() throws ProjectDeletedException { + GeneralStorage storage = GeneralStorage.getInstance(); try { - GeneralStorage.getInstance().getMasterSession().refresh( - GeneralStorage.getInstance().getProject().getAutCont()); + storage.getMasterSession().refresh(storage.getProject()); } catch (EntityNotFoundException enfe) { // Occurs if any Object Mapping information has been deleted while // the Project Properties were being edited. // Refresh the entire master session to ensure that AUT settings // and Object Mappings are in sync - GeneralStorage.getInstance().reloadMasterSession( - new NullProgressMonitor()); + storage.reloadMasterSession(new NullProgressMonitor()); } } - /** * Adds necessary listeners. */ @@ -684,7 +692,7 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { if (o.equals(m_projectNameTextField)) { modifyProjectNameFieldAction(true); return; - } + } } } @@ -748,7 +756,8 @@ public class ProjectGeneralPropertyPage extends AbstractProjectPropertyPage { */ private void refreshAutToolkitCombo() { final Composite parent = m_projectToolkitCombo.getParent(); - final DirectCombo<String> tmpCombo = createToolkitCombo(parent); + final DirectCombo<String> tmpCombo = ControlFactory + .createProjectToolkitCombo(parent); m_projectToolkitCombo.setItems(tmpCombo.getValues(), Arrays.asList( tmpCombo.getItems())); tmpCombo.dispose(); diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/provider/contentprovider/TestSuiteBrowserContentProvider.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/provider/contentprovider/TestSuiteBrowserContentProvider.java index b01794960..884b1f85b 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/provider/contentprovider/TestSuiteBrowserContentProvider.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/provider/contentprovider/TestSuiteBrowserContentProvider.java @@ -20,6 +20,7 @@ import org.eclipse.jubula.client.core.model.IEventExecTestCasePO; import org.eclipse.jubula.client.core.model.IExecObjContPO; import org.eclipse.jubula.client.core.model.IExecTestCasePO; import org.eclipse.jubula.client.core.model.INodePO; +import org.eclipse.jubula.client.core.model.IProjectPO; import org.eclipse.jubula.client.core.model.ISpecTestCasePO; import org.eclipse.jubula.client.core.model.ITestSuitePO; import org.eclipse.jubula.client.ui.rcp.businessprocess.WorkingLanguageBP; @@ -43,8 +44,9 @@ public class TestSuiteBrowserContentProvider * @return object array */ public Object[] getChildren(Object parentElement) { - if (parentElement instanceof IExecObjContPO[]) { - return new Object[] { ((IExecObjContPO[])parentElement)[0] }; + if (parentElement instanceof IProjectPO) { + return new Object[] { ((IProjectPO) parentElement) + .getExecObjCont() }; } if (parentElement instanceof IExecObjContPO) { @@ -70,12 +72,11 @@ public class TestSuiteBrowserContentProvider } if (parentElement instanceof ITestSuitePO) { - ITestSuitePO testSuite = (ITestSuitePO)parentElement; - Locale workLang = WorkingLanguageBP.getInstance() - .getWorkingLanguage(); + ITestSuitePO testSuite = (ITestSuitePO) parentElement; + WorkingLanguageBP workLangBP = WorkingLanguageBP.getInstance(); + Locale workLang = workLangBP.getWorkingLanguage(); if (testSuite.getAut() != null - && !WorkingLanguageBP.getInstance() - .isTestSuiteLanguage(workLang, testSuite)) { + && !workLangBP.isTestSuiteLanguage(workLang, testSuite)) { return ArrayUtils.EMPTY_OBJECT_ARRAY; } // fall through diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/provider/labelprovider/GeneralLabelProvider.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/provider/labelprovider/GeneralLabelProvider.java index 55e5dafdd..f10a1fc00 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/provider/labelprovider/GeneralLabelProvider.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/provider/labelprovider/GeneralLabelProvider.java @@ -62,10 +62,8 @@ import org.eclipse.ui.PlatformUI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - - /** - * Base class for all label probider + * Base class for all label provider * * @author BREDEX GmbH * @created May 11, 2010 diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/validator/MaxStringLengthValidator.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/validator/MaxStringLengthValidator.java new file mode 100644 index 000000000..6df25b650 --- /dev/null +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/validator/MaxStringLengthValidator.java @@ -0,0 +1,20 @@ +package org.eclipse.jubula.client.ui.rcp.validator; + +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jubula.client.core.model.INodePO; + +/** + * @author BREDEX GmbH + */ +public class MaxStringLengthValidator implements IValidator { + /** {@inheritDoc} */ + public IStatus validate(Object value) { + if (value instanceof String) { + return (((String) value).length() < INodePO.MAX_STRING_LENGTH) + ? Status.OK_STATUS : Status.CANCEL_STATUS; + } + return Status.OK_STATUS; + } +} diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java index c13f0ea8b..28004fc48 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java @@ -398,13 +398,7 @@ public class TestSuiteBrowser extends AbstractJBTreeView implements * Sets the input for the tree viewer. */ private void setViewerInput() { - IProjectPO activeProject = GeneralStorage.getInstance().getProject(); - if (activeProject != null) { - getTreeViewer().setInput( - new IExecObjContPO[] {activeProject.getExecObjCont()}); - } else { - getTreeViewer().setInput(null); - } + getTreeViewer().setInput(GeneralStorage.getInstance().getProject()); } /** {@inheritDoc} */ diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/EnterCommentAndDetailsDialog.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/EnterCommentAndDetailsDialog.java new file mode 100644 index 000000000..af18dd3ec --- /dev/null +++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/EnterCommentAndDetailsDialog.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2004, 2010 BREDEX GmbH. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * BREDEX GmbH - initial API and implementation and/or initial documentation + *******************************************************************************/ +package org.eclipse.jubula.client.ui.dialogs; + +import org.apache.commons.lang.StringUtils; +import org.eclipse.core.databinding.UpdateValueStrategy; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.core.databinding.observable.value.WritableValue; +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jubula.client.ui.i18n.Messages; +import org.eclipse.jubula.client.ui.utils.LayoutUtil; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + + +/** + * Dialog for entering the comment e.g for a test result summary. + * + * @author BREDEX GmbH + * @created Aug 23, 2010 + */ +public class EnterCommentAndDetailsDialog extends EnterCommentDialog { + /** observable (bindable) value for comment detail */ + private WritableValue m_commentDetail; + + /** + * <code>m_initialDetail</code> + */ + private String m_initialDetail = null; + + /** + * Constructor + * + * @param parentShell + * The Shell to use as a parent for the dialog. + * @param commentValidator + * The validator to use for the commentary values + * @param title + * the initial comment title + * @param detail + * the initial comment detail + */ + public EnterCommentAndDetailsDialog(Shell parentShell, + IValidator commentValidator, String title, String detail) { + super(parentShell, commentValidator, title); + m_initialDetail = detail; + } + + @Override + protected void createDialogAdditionalArea(Composite area) { + GridData gridData; + Text commentDetailField = createCommentDetailText(area); + gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + LayoutUtil.addToolTipAndMaxWidth(gridData, commentDetailField); + commentDetailField.setLayoutData(gridData); + + IObservableValue commentDetailFieldText = SWTObservables.observeText( + commentDetailField, SWT.Modify); + m_commentDetail = WritableValue.withValueType(String.class); + + getValidationContext().bindValue(commentDetailFieldText, + m_commentDetail, + new UpdateValueStrategy().setAfterGetValidator(getValidator()), + new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); + + if (!StringUtils.isEmpty(m_initialDetail)) { + m_commentDetail.setValue(m_initialDetail); + } + LayoutUtil.setMaxChar(commentDetailField, 4000); + } + + /** + * @param area The parent for the created widgets. + * @return the created text field. + */ + private Text createCommentDetailText(Composite area) { + new Label(area, SWT.NONE).setText( + Messages.EnterCommentDialogDetailLabel); + return new Text(area, SWT.V_SCROLL | SWT.BORDER); + } + + /** + * This method must be called from the GUI thread. + * + * @return the comment detail + */ + public String getCommentDetail() { + return (String)m_commentDetail.getValue(); + } +} diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/EnterCommentDialog.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/EnterCommentDialog.java index 659d1c702..e8114ef90 100644 --- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/EnterCommentDialog.java +++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/EnterCommentDialog.java @@ -36,26 +36,19 @@ import org.eclipse.swt.widgets.Text; * @created Aug 23, 2010 */ public class EnterCommentDialog extends AbstractValidatedDialog { + /** + * the validator used for validation of value correctness + */ + private IValidator m_validator; + /** observable (bindable) value for comment title */ private WritableValue m_commentTitle; - - /** observable (bindable) value for comment detail */ - private WritableValue m_commentDetail; /** * <code>m_initialTitle</code> */ private String m_initialTitle = null; - /** - * <code>m_initialDetail</code> - */ - private String m_initialDetail = null; - - /** - * the validator used for validation of value correctness - */ - private IValidator m_validator; /** * Constructor @@ -66,15 +59,12 @@ public class EnterCommentDialog extends AbstractValidatedDialog { * The validator to use for the commentary values * @param title * the initial comment title - * @param detail - * the initial comment detail */ public EnterCommentDialog(Shell parentShell, IValidator commentValidator, - String title, String detail) { + String title) { super(parentShell); - m_validator = commentValidator; + setValidator(commentValidator); m_initialTitle = title; - m_initialDetail = detail; } /** @@ -91,19 +81,26 @@ public class EnterCommentDialog extends AbstractValidatedDialog { area.setLayout(new GridLayout(2, false)); createCommentTitleField(area); - createCommentDetailField(area); + createDialogAdditionalArea(area); return area; } /** + * @param area the area to create some additional content on + */ + protected void createDialogAdditionalArea(Composite area) { + // currently empty + } + + /** * {@inheritDoc} */ protected Point getInitialSize() { Point shellSize = super.getInitialSize(); return new Point(Math.max( convertHorizontalDLUsToPixels(450), shellSize.x), - Math.max(convertVerticalDLUsToPixels(300), + Math.max(convertVerticalDLUsToPixels(100), shellSize.y)); } @@ -130,7 +127,7 @@ public class EnterCommentDialog extends AbstractValidatedDialog { getValidationContext().bindValue( commentTitleFieldText, m_commentTitle, - new UpdateValueStrategy().setAfterGetValidator(m_validator), + new UpdateValueStrategy().setAfterGetValidator(getValidator()), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); if (!StringUtils.isEmpty(m_initialTitle)) { @@ -142,32 +139,6 @@ public class EnterCommentDialog extends AbstractValidatedDialog { } /** - * @param area the parent area - */ - private void createCommentDetailField(Composite area) { - GridData gridData; - Text commentDetailField = createCommentDetailText(area); - gridData = new GridData(SWT.FILL, SWT.FILL, true, true); - LayoutUtil.addToolTipAndMaxWidth(gridData, commentDetailField); - commentDetailField.setLayoutData(gridData); - - IObservableValue commentDetailFieldText = - SWTObservables.observeText(commentDetailField, SWT.Modify); - m_commentDetail = WritableValue.withValueType(String.class); - - getValidationContext().bindValue( - commentDetailFieldText, - m_commentDetail, - new UpdateValueStrategy().setAfterGetValidator(m_validator), - new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); - - if (!StringUtils.isEmpty(m_initialDetail)) { - m_commentDetail.setValue(m_initialDetail); - } - LayoutUtil.setMaxChar(commentDetailField, 4000); - } - - /** * @param area The parent for the created widgets. * @return the created text field. */ @@ -178,16 +149,6 @@ public class EnterCommentDialog extends AbstractValidatedDialog { } /** - * @param area The parent for the created widgets. - * @return the created text field. - */ - private Text createCommentDetailText(Composite area) { - new Label(area, SWT.NONE).setText( - Messages.EnterCommentDialogDetailLabel); - return new Text(area, SWT.V_SCROLL | SWT.BORDER); - } - - /** * This method must be called from the GUI thread. * * @return the comment title @@ -195,13 +156,18 @@ public class EnterCommentDialog extends AbstractValidatedDialog { public String getCommentTitle() { return (String)m_commentTitle.getValue(); } - + /** - * This method must be called from the GUI thread. - * - * @return the comment detail + * @return the validator + */ + protected IValidator getValidator() { + return m_validator; + } + + /** + * @param validator the validator to set */ - public String getCommentDetail() { - return (String)m_commentDetail.getValue(); + private void setValidator(IValidator validator) { + m_validator = validator; } } diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java index 55f16744d..f35add3ed 100644 --- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java +++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java @@ -72,7 +72,6 @@ public class Messages extends NLS { public static String SelectDatabaseConnectSuccessful; public static String SelectedElementIsNotTestResultSummary; public static String SetItemsNotValidForThisSubclass; - public static String StoringOfMetadataFailed; public static String TestResultNodePropertySourceCapDetail; public static String TestResultNodePropertySourceDataCat; public static String TestResultNodePropertySourceDataParameter; diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties index 55bdf856d..0313cafd5 100644 --- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties +++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties @@ -58,7 +58,6 @@ SelectDatabaseConnectFailed=Connection to Database failed. SelectDatabaseConnectSuccessful=Connection to Database successful. SelectedElementIsNotTestResultSummary=Selected element is not a Test Result Summary SetItemsNotValidForThisSubclass=setItems() not valid for this subclass. -StoringOfMetadataFailed=storing of metadata failed. TestResultNodePropertySourceCapDetail=Component Details TestResultNodePropertySourceDataCat=Test Data TestResultNodePropertySourceDataParameter={0} |
