Author: dmaliarevich
Date: 2010-06-11 08:18:35 -0400 (Fri, 11 Jun 2010)
New Revision: 22767
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6287 , Dialog and SWTBot test were updated.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-06-11
11:41:35 UTC (rev 22766)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-06-11
12:18:35 UTC (rev 22767)
@@ -63,7 +63,6 @@
private final int DIALOG_WIDTH = 450;
private final int DIALOG_HEIGHT = 650;
private VpeController vpeController;
- private Text textStringValue;
private Text propsKey;
private Text propsValue;
private Button newFile;
@@ -75,7 +74,8 @@
private Group propsFilesGroup;
private Status propsKeyStatus;
private Status propsValueStatus;
- private Status selectedTextStatus;
+ private Status rbComboStatus;
+
private Table tagsTable;
public ExternalizeStringsWizardPage(String pageName, VpeController vpeController) {
@@ -91,7 +91,7 @@
this.bm = vpeController.getPageContext().getBundle();
propsKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
propsValueStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- selectedTextStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
+ rbComboStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
}
public ExternalizeStringsWizardPage(String pageName) {
@@ -116,19 +116,19 @@
propsStringGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
propsStringGroup.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
- /*
- * Create Text String label
- */
- Label textStringLabel = new Label(propsStringGroup, SWT.NONE);
- textStringLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
- textStringLabel.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TEXT_STRING);
- /*
- * Create Text String value
- */
- textStringValue = new Text(propsStringGroup, SWT.BORDER);
- textStringValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
- textStringValue.setText(Constants.EMPTY);
- textStringValue.setEditable(false);
+// /*
+// * Create Text String label
+// */
+// Label textStringLabel = new Label(propsStringGroup, SWT.NONE);
+// textStringLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1,
1));
+// textStringLabel.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TEXT_STRING);
+// /*
+// * Create Text String value
+// */
+// textStringValue = new Text(propsStringGroup, SWT.BORDER);
+// textStringValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
+// textStringValue.setText(Constants.EMPTY);
+// textStringValue.setEditable(false);
/*
* Create Properties Key label
@@ -144,15 +144,6 @@
propsKey.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_KEY);
propsKey.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- if ((propsKey.getText() == null)
- || (Constants.EMPTY.equalsIgnoreCase(propsKey.getText().trim()))) {
- propsKeyStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET);
- } else {
- propsKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
updateStatus();
}
});
@@ -167,18 +158,10 @@
*/
propsValue = new Text(propsStringGroup, SWT.BORDER);
propsValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
- propsValue.setText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE);
+ propsValue.setText(Constants.EMPTY);
+ propsValue.setEditable(false);
propsValue.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- if ((propsValue.getText() == null)
- || (Constants.EMPTY.equalsIgnoreCase(propsValue.getText().trim()))) {
- propsValueStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_VALUE_MUST_BE_SET);
- } else {
- propsValueStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
updateStatus();
}
});
@@ -235,8 +218,15 @@
if (bundleFile != null) {
bundlePath = bundleFile.getFullPath().toString();
updateTable(bundleFile);
- }
+ } else {
+ VpePlugin.getDefault().logError(
+ "Could not get Bundle File for resource '" //$NON-NLS-1$
+ + rbCombo.getText() + "'"); //$NON-NLS-1$
+ }
propsFile.setText(bundlePath);
+
+ updateDuplicateKeyStatus();
+ updateStatus();
setPageComplete(isPageComplete());
}
});
@@ -291,7 +281,7 @@
VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR);
} else {
ISelection sel =
vpeController.getSourceEditor().getSelectionProvider().getSelection();
- if ((textStringValue != null) && (propsKey != null)
+ if ((propsValue != null) && (propsKey != null)
&& isSelectionCorrect(sel)) {
/*
* TODO: One must add functionality
@@ -303,20 +293,11 @@
IStructuredSelection structuredSelection = (IStructuredSelection) sel;
textSelection = (TextSelection) sel;
text = textSelection.getText();
- if (text.trim().length() < 1) {
- selectedTextStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_SELECTED_TEXT_IS_EMPTY);
- } else if ((text.indexOf(Constants.GT) != -1) || (text.indexOf(Constants.LT) != -1))
{
- selectedTextStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT);
- } else {
- selectedTextStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
/*
+ * Update text string field
+ */
+ propsValue.setText(text);
+ /*
* Update status message.
*/
updateStatus();
@@ -341,10 +322,6 @@
VpePlugin.getDefault().logWarning(
VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR);
}
- /*
- * Update text string field
- */
- textStringValue.setText(text);
/*
* Initialize bundle messages field
@@ -374,12 +351,36 @@
}
}
+ private boolean isDuplicatedKey(String key) {
+ boolean isDupliacted = false;
+ if ((tagsTable.getItemCount() > 0) && (null != key)) {
+ TableItem[] items = tagsTable.getItems();
+ for (TableItem tableItem : items) {
+ if (key.equalsIgnoreCase(tableItem.getText(0))) {
+ isDupliacted = true;
+ break;
+ }
+ }
+ }
+ return isDupliacted;
+ }
+
private void updateTable(IFile file) {
if ((file != null) && file.exists()) {
try {
+ /*
+ * Rad file content
+ */
BufferedReader in = new BufferedReader(new InputStreamReader(
file.getContents()));
String line = in.readLine();
+ /*
+ * Clear the table
+ */
+ tagsTable.clearAll();
+ /*
+ * Fill in new values
+ */
int i = 0;
while (line != null) {
TableItem tableItem = null;
@@ -395,10 +396,15 @@
line = in.readLine();
}
} catch (CoreException e) {
- e.printStackTrace();
+ VpePlugin.getDefault().logError(
+ "Could not load file content for '" + file + "'", e);
//$NON-NLS-1$ //$NON-NLS-2$
} catch (IOException e) {
- e.printStackTrace();
+ VpePlugin.getDefault().logError(
+ "Could not read file: '" + file + "'", e); //$NON-NLS-1$
//$NON-NLS-2$
}
+ } else {
+ VpePlugin.getDefault().logError(
+ "Bundle File'" + file + "' does not exist!");
//$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -454,8 +460,58 @@
return true;
}
+ private void updateDuplicateKeyStatus() {
+ if (isDuplicatedKey(propsKey.getText())) {
+ rbComboStatus = new Status(
+ IStatus.ERROR,
+ VpePlugin.PLUGIN_ID,
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS);
+ } else {
+ rbComboStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
+ }
+ }
+
+ private void updatePropertiesValueStatus() {
+ String text = propsValue.getText();
+ if ((text == null)
+ || (Constants.EMPTY.equalsIgnoreCase(text.trim()))
+ || (text.indexOf(Constants.GT) != -1)
+ || (text.indexOf(Constants.LT) != -1)) {
+ propsValueStatus = new Status(
+ IStatus.ERROR,
+ VpePlugin.PLUGIN_ID,
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT);
+ } else {
+ propsValueStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
+ }
+ }
+
+ private void updatePropertiesKeyStatus() {
+ if ((propsKey.getText() == null)
+ || (Constants.EMPTY.equalsIgnoreCase(propsKey.getText().trim()))) {
+ propsKeyStatus = new Status(
+ IStatus.ERROR,
+ VpePlugin.PLUGIN_ID,
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET);
+ } else {
+ propsKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
+ }
+ }
+
private void updateStatus() {
- applyStatus(this, new IStatus[] {selectedTextStatus, propsKeyStatus,
propsValueStatus});
+ /*
+ * Update all statuses
+ */
+ updatePropertiesKeyStatus();
+ updatePropertiesValueStatus();
+ updateDuplicateKeyStatus();
+ /*
+ * Apply status to the dialog
+ */
+ applyStatus(this, new IStatus[] {propsKeyStatus, propsValueStatus, rbComboStatus});
+ /*
+ * Set page complete
+ */
setPageComplete(isPageComplete());
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-06-11
11:41:35 UTC (rev 22766)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-06-11
12:18:35 UTC (rev 22767)
@@ -179,6 +179,7 @@
public static String EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE;
public static String EXTRNALIZE_STRINGS_DIALOG_PROPERTY_NAME;
public static String EXTRNALIZE_STRINGS_DIALOG_PROPERTY_VALUE;
+ public static String EXTRNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS;
public static String COULD_NOT_OPEN_VPE_RESOURCES_DIALOG;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-06-11
11:41:35 UTC (rev 22766)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-06-11
12:18:35 UTC (rev 22767)
@@ -167,6 +167,7 @@
EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE=value
EXTRNALIZE_STRINGS_DIALOG_PROPERTY_NAME=Property name
EXTRNALIZE_STRINGS_DIALOG_PROPERTY_VALUE=Property value
+EXTRNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS=Such a key already exists
# Other messages
CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT=Cannot load taglibs from PageContext!
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-06-11
11:41:35 UTC (rev 22766)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-06-11
12:18:35 UTC (rev 22767)
@@ -23,6 +23,7 @@
import org.jboss.tools.vpe.ui.bot.test.smoke.RenameJSPFileTest;
import org.jboss.tools.vpe.ui.bot.test.smoke.RenameXHTMLFileTest;
import org.jboss.tools.vpe.ui.bot.test.smoke.XHTMLPageCreationTest;
+import org.jboss.tools.vpe.ui.bot.test.wizard.ExternalizeStringsDialogTest;
import org.jboss.tools.vpe.ui.bot.test.wizard.ImportUnknownTagsWizardTest;
import org.jboss.tools.vpe.ui.bot.test.wizard.NewXHTMLPageWizardTest;
import org.jboss.tools.vpe.ui.bot.test.wizard.VPESourceCodeTemplatesPreferencePageTest;
@@ -53,6 +54,8 @@
suite.addTestSuite(ImportUnknownTagsWizardTest.class);
suite.addTestSuite(NewXHTMLPageWizardTest.class);
suite.addTestSuite(VPESourceCodeTemplatesPreferencePageTest.class);
+ suite.addTestSuite(ExternalizeStringsDialogTest.class);
+
return new TestSetup(suite);
}
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2010-06-11
11:41:35 UTC (rev 22766)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2010-06-11
12:18:35 UTC (rev 22767)
@@ -13,6 +13,7 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.jboss.tools.vpe.messages.VpeUIMessages;
@@ -31,7 +32,12 @@
@Override
protected void closeUnuseDialogs() {
-
+// try {
+// SWTBotShell shell = bot.shell(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TITLE);
+// shell.close();
+// } catch (Exception e) {
+// // Do nothing
+// }
}
@Override
@@ -56,21 +62,21 @@
bot.toolbarButtonWithTooltip(VpeUIMessages.EXTENALIZE_STRINGS).click();
bot.shell(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TITLE).setFocus();
bot.shell(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_TITLE).activate();
-
/*
* Check properties key and value fields
*/
- SWTBotText defKeyText = bot.textInGroup(
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_KEY,
+ SWTBotText defKeyText = bot.textWithLabelInGroup(
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
if (null != defKeyText) {
- assertText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_KEY, defKeyText);
+ assertText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_KEY,
+ defKeyText);
}
- SWTBotText defValueText = bot.textInGroup(
- VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE,
+ SWTBotText defValueText = bot.textWithLabelInGroup(
+ VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
if (null != defValueText) {
- assertText(VpeUIMessages.EXTRNALIZE_STRINGS_DIALOG_DEFAULT_VALUE, defValueText);
+ assertText("User", defValueText); //$NON-NLS-1$
}
SWTBotCheckBox checkBox = bot.checkBox();
assertNotNull("Cannot find checkbox '" //$NON-NLS-1$
@@ -119,7 +125,7 @@
"Messages.properties"); //$NON-NLS-1$
editor2.toTextEditor().selectLine(3);
String line = editor2.toTextEditor().getSelection();
- assertEquals("'Messages.properties' was updated incorrectly",
"key=value", line); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("'Messages.properties' was updated incorrectly",
"key=User", line); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testNewFileInExternalizeStringsDialog() throws Throwable {
@@ -178,6 +184,6 @@
"externalize.properties"); //$NON-NLS-1$
editor2.toTextEditor().selectLine(1);
String line = editor2.toTextEditor().getSelection();
- assertEquals("Created file is incorrect", "key=value", line);
//$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Created file is incorrect", "key=Input", line);
//$NON-NLS-1$ //$NON-NLS-2$
}
}