Author: dmaliarevich
Date: 2011-03-21 14:41:34 -0400 (Mon, 21 Mar 2011)
New Revision: 29923
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsKeysListPage.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsSelectBundlePage.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsWizard.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
Log:
https://issues.jboss.org/browse/JBIDE-7004 , validation was updated, bundle name on the
last page was initialized.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsKeysListPage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsKeysListPage.java 2011-03-21
15:10:08 UTC (rev 29922)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsKeysListPage.java 2011-03-21
18:41:34 UTC (rev 29923)
@@ -79,7 +79,7 @@
red = parent.getDisplay().getSystemColor(SWT.COLOR_RED);
white = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
initKeys = getAllNonExternalizedStrings();
- Collections.sort(initKeys, Collections.reverseOrder());
+ Collections.sort(initKeys);
tv = createTable(parent);
highlightAllDuplicateKeys(tv);
setControl(tv.getTable());
@@ -270,6 +270,19 @@
kve.value = value.toString();
}
viewer.refresh(kve);
+ /*
+ * Mark/unmark all duplicated keys with red/white.
+ * Change the dialog status.
+ */
+ for (KeyValueElement k : initKeys) {
+ if (isDuplicatedBundleKey(k.key) || isDuplicatedStringKey(k, k.key)) {
+ k.duplicated = true;
+ } else {
+ k.duplicated = false;
+ }
+ }
+ highlightAllDuplicateKeys(viewer);
+ updateStatus();
}
});
TextCellEditor keyEditor = new TextCellEditor(parent);
@@ -288,11 +301,10 @@
@Override
public void modifyText(ModifyEvent e) {
Text t = (Text) e.getSource();
+ String key = t.getText();
Table table = (Table) t.getParent();
int ind = table.getSelectionIndex();
KeyValueElement element = (KeyValueElement) viewer.getElementAt(ind);
- TableItem ti = table.getItem(ind);
- String key = t.getText();
/*
* Check duplicate key, set bkg color to red
* Setting new key value is called after this modyfy listener,
@@ -300,14 +312,11 @@
*/
if (isDuplicatedBundleKey(key) || isDuplicatedStringKey(element, key)) {
element.duplicated = true;
- highlightDuplicateKey(ti, true);
t.setBackground(red);
} else {
element.duplicated = false;
- highlightDuplicateKey(ti, false);
t.setBackground(white);
}
- updateStatus();
}
});
((Text)keyEditor.getControl()).addVerifyListener(new VerifyListener() {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsSelectBundlePage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsSelectBundlePage.java 2011-03-21
15:10:08 UTC (rev 29922)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsSelectBundlePage.java 2011-03-21
18:41:34 UTC (rev 29923)
@@ -73,6 +73,7 @@
bundleFile = new File((String)event.getNewValue());
properties = ExternalizeStringsUtils.populatePropertiesTable(table, bundleFile);
wiz.setUpdatedProperties(properties);
+ wiz.setPage3BundleName();
/*
* Set page complete
*/
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsWizard.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsWizard.java 2011-03-21
15:10:08 UTC (rev 29922)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeAllStringsWizard.java 2011-03-21
18:41:34 UTC (rev 29923)
@@ -33,7 +33,7 @@
private BundleMap bm = null;
ExternalizeAllStringsSelectBundlePage page1;
ExternalizeAllStringsKeysListPage page2;
- ExternalizeStringsWizardRegisterBundlePage page3 = null;
+ ExternalizeStringsWizardRegisterBundlePage page3;
public ExternalizeAllStringsWizard(ITextEditor editor, BundleMap bm) {
super();
@@ -49,9 +49,9 @@
@Override
public void addPages() {
super.addPages();
- page1 = new ExternalizeAllStringsSelectBundlePage("page1");
- page2 = new ExternalizeAllStringsKeysListPage("page2");
- page3 = new ExternalizeStringsWizardRegisterBundlePage("page3");
+ page1 = new
ExternalizeAllStringsSelectBundlePage("ExternalizeAllStringsSelectBundlePage");
+ page2 = new
ExternalizeAllStringsKeysListPage("ExternalizeAllStringsKeysListPage");
+ page3 = new
ExternalizeStringsWizardRegisterBundlePage("ExternalizeStringsWizardRegisterBundlePage");
/*
* Add all the pages to the wizard
*/
@@ -92,23 +92,26 @@
}
out.close();
out = null;
- }
- /*
- * Find bundle prefix
- */
+ }
+ page2.replaceAllStrings(findBundlePrefix());
+ return true;
+ }
+
+ public String findBundlePrefix() {
String bundlePrefix = Constants.EMPTY;
- String ap = bundleFile.getAbsolutePath();
- for (BundleEntry be : bm.getBundles()) {
- IFile bf = bm.getBundleFile(be.uri);
- if (ap.equalsIgnoreCase(bf.getLocation().toOSString())) {
- bundlePrefix = be.prefix;
- break;
+ if (page1.getBundleFile() != null) {
+ String ap = page1.getBundleFile().getAbsolutePath();
+ for (BundleEntry be : bm.getBundles()) {
+ IFile bf = bm.getBundleFile(be.uri);
+ if (ap.equalsIgnoreCase(bf.getLocation().toOSString())) {
+ bundlePrefix = be.prefix;
+ break;
+ }
}
}
- page2.replaceAllStrings(bundlePrefix);
- return true;
+ return bundlePrefix;
}
-
+
public Properties getOriginalProperties() {
if (null != page1) {
return page1.getOriginalProperties();
@@ -118,4 +121,7 @@
public void setUpdatedProperties(Properties p) {
page2.updateTable(p);
}
+ public void setPage3BundleName() {
+ page3.setBundleName(findBundlePrefix());
+ }
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2011-03-21
15:10:08 UTC (rev 29922)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2011-03-21
18:41:34 UTC (rev 29923)
@@ -31,6 +31,8 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -504,6 +506,19 @@
updateStatus();
}
});
+ propsKey.addVerifyListener(new VerifyListener() {
+ public void verifyText(VerifyEvent e) {
+ for (int i = 0; i < ExternalizeStringsUtils.REPLACED_CHARACTERS.length; i++) {
+ /*
+ * Entering of the forbidden characters will be prevented.
+ */
+ if (e.character == ExternalizeStringsUtils.REPLACED_CHARACTERS[i]) {
+ e.doit = false;
+ break;
+ }
+ }
+ }
+ });
propsValue.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updateStatus();
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java 2011-03-21
15:10:08 UTC (rev 29922)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java 2011-03-21
18:41:34 UTC (rev 29923)
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2010 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.i18n;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-import org.jboss.tools.common.EclipseUtil;
-import org.jboss.tools.common.model.ui.ModelUIImages;
-import org.jboss.tools.jst.jsp.messages.JstUIMessages;
-import org.jboss.tools.jst.jsp.util.Constants;
-
-/**
- * The Class ExternalizeStringsWizardRegisterBundlePage.
- */
-public class ExternalizeStringsWizardRegisterBundlePage extends WizardPage
- implements SelectionListener {
-
- public static final String PAGE_NAME =
"ExternalizeStringsWizardRegisterBundlePage"; //$NON-NLS-1$
- /*
- * Constants that indicate user selection
- */
- public static final int FACES_CONFIG = 1;
- public static final int LOAD_BUNDLE = 2;
- public static final int USER_DEFINED = 3;
-
- private final int DIALOG_WIDTH = 450;
- private final int DIALOG_HEIGHT = 650;
-
- private Button facesConfig;
- private Button laodBundle;
- private Button userDefined;
- private Label bundleLabel;
- private Text bundleName;
-
- /**
- * Instantiates a new externalize strings wizard register bundle page.
- *
- * @param pageName the page name
- */
- public ExternalizeStringsWizardRegisterBundlePage(String pageName) {
- super(pageName, JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE,
- ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
- setDescription(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
- setPageComplete(true);
- }
-
- /* (non-Javadoc)
- * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- /*
- * Create basic container
- */
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.widthHint = DIALOG_WIDTH;
- gd.heightHint = DIALOG_HEIGHT;
- composite.setLayoutData(gd);
- /*
- * Input field with bundle name
- */
- bundleLabel = new Label(composite, SWT.NONE);
- bundleLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
- bundleLabel.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_BUNDLE_NAME);
- bundleName = new Text(composite, SWT.BORDER);
- bundleName.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
- String fileName = Constants.EMPTY;
- if (getWizard() instanceof ExternalizeStringsWizard) {
- fileName = ((ExternalizeStringsWizard) getWizard()).getFileName();
- int pos = fileName.lastIndexOf(Constants.DOT);
- if (pos != -1) {
- fileName = fileName.substring(0, pos);
- }
- }
- bundleName.setText(fileName);
-
- /*
- * Group with a place for bundle
- */
- Group group = new Group(composite, SWT.SHADOW_ETCHED_IN);
- group.setLayout(new GridLayout(1, true));
- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
- group.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_SAVE_RESOURCE_BUNDLE);
-
- facesConfig = new Button(group, SWT.RADIO);
- laodBundle = new Button(group, SWT.RADIO);
- userDefined = new Button(group, SWT.RADIO);
- facesConfig.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_FACES_CONFIG);
- laodBundle.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_LOAD_BUNDLE);
- userDefined.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_USER_DEFINED);
-
- userDefined.setSelection(true);
-
- facesConfig.addSelectionListener(this);
- laodBundle.addSelectionListener(this);
- userDefined.addSelectionListener(this);
-
- updateBundleNameField();
- /*
- * Wizard Page control should be initialized.
- */
- setControl(composite);
- }
-
- /**
- * Gets the user specified bundle name.
- *
- * @return the bundle name
- */
- public String getBundleName() {
- String name = Constants.EMPTY;
- if (bundleName != null) {
- name = bundleName.getText();
- }
- return name;
- }
-
- /**
- * Checks if user has selected faces config.
- *
- * @return true, if in faces config
- */
- public boolean isInFacesConfig() {
- return (null != facesConfig) && facesConfig.getSelection();
- }
-
- /**
- * Checks if user has selected load bundle.
- *
- * @return true, if via load bundle
- */
- public boolean isViaLoadBundle() {
- return (null != laodBundle) && laodBundle.getSelection();
- }
-
- /**
- * Checks if user will register the bundle manually.
- *
- * @return true, if user defined
- */
- public boolean isUserDefined() {
- return (null != userDefined) && userDefined.getSelection();
- }
-
- /**
- * Update the dialog status.
- */
- public void updateStatus() {
- /*
- * If user has entered a path that is different from the source folder
- * the base-name will be incorrect.
- * Thus show warning message.
- */
- if (isSourceFolderSelected()) {
- setMessage(null, IMessageProvider.NONE);
- } else {
- setMessage(
- JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_WRONG_BUNDLE_PLACEMENT,
- IMessageProvider.WARNING);
- }
- }
-
-// /**
-// * Gets the selected place.
-// *
-// * @return the selected place
-// */
-// private int getSelectedPlace() {
-// int place = FACES_CONFIG;
-// if (isInFacesConfig()) {
-// place = FACES_CONFIG;
-// } else if (isViaLoadBundle()) {
-// place = LOAD_BUNDLE;
-// } else if (isUserDefined()) {
-// place = USER_DEFINED;
-// }
-// return place;
-// }
-
- /**
- * Update bundle name field.
- */
- private void updateBundleNameField() {
- if (isUserDefined()) {
- bundleLabel.setEnabled(false);
- bundleName.setEnabled(false);
- } else {
- bundleLabel.setEnabled(true);
- bundleName.setEnabled(true);
- }
- }
-
- /**
- * Checks if the source folder is selected.
- *
- * @return true, if the source folder is selected.
- */
- private boolean isSourceFolderSelected() {
- boolean sourceFolderSelected = false;
- if (getWizard() instanceof ExternalizeStringsWizard) {
- ExternalizeStringsWizard wiz = (ExternalizeStringsWizard) getWizard();
- if (wiz.getProject()!=null) {
- IProject project = wiz.getProject();
- WizardNewFileCreationPage page2 = (WizardNewFileCreationPage)wiz.getPage(
- ExternalizeStringsWizard.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE);
- String userDefinedPath = page2.getContainerFullPath().toString();
- /*
- * Get the source folders for the project
- */
- IResource[] src = EclipseUtil.getJavaSourceRoots(project);
- /*
- * When there are multiple source folders --
- * match user defined folder to them.
- */
- String srcPath = Constants.EMPTY;
- for (IResource res : src) {
- srcPath = res.getFullPath().toString();
- if (userDefinedPath.indexOf(srcPath) > -1) {
- sourceFolderSelected = true;
- break;
- }
- }
- }
- }
- return sourceFolderSelected;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
- */
- public boolean isPageComplete() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see
org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- updateBundleNameField();
- }
-
- /* (non-Javadoc)
- * @see
org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- updateBundleNameField();
- }
-}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java 2011-03-21
18:41:34 UTC (rev 29923)
@@ -0,0 +1,279 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.i18n;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.ui.ModelUIImages;
+import org.jboss.tools.jst.jsp.messages.JstUIMessages;
+import org.jboss.tools.jst.jsp.util.Constants;
+
+/**
+ * The Class ExternalizeStringsWizardRegisterBundlePage.
+ */
+public class ExternalizeStringsWizardRegisterBundlePage extends WizardPage
+ implements SelectionListener {
+
+ public static final String PAGE_NAME =
"ExternalizeStringsWizardRegisterBundlePage"; //$NON-NLS-1$
+ /*
+ * Constants that indicate user selection
+ */
+ public static final int FACES_CONFIG = 1;
+ public static final int LOAD_BUNDLE = 2;
+ public static final int USER_DEFINED = 3;
+
+ private final int DIALOG_WIDTH = 450;
+ private final int DIALOG_HEIGHT = 650;
+
+ private Button facesConfig;
+ private Button laodBundle;
+ private Button userDefined;
+ private Label bundleLabel;
+ private Text bundleName;
+
+ /**
+ * Instantiates a new externalize strings wizard register bundle page.
+ *
+ * @param pageName the page name
+ */
+ public ExternalizeStringsWizardRegisterBundlePage(String pageName) {
+ super(pageName, JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE,
+ ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
+ setDescription(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
+ setPageComplete(true);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ /*
+ * Create basic container
+ */
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = DIALOG_WIDTH;
+ gd.heightHint = DIALOG_HEIGHT;
+ composite.setLayoutData(gd);
+ /*
+ * Input field with bundle name
+ */
+ bundleLabel = new Label(composite, SWT.NONE);
+ bundleLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
+ bundleLabel.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_BUNDLE_NAME);
+ bundleName = new Text(composite, SWT.BORDER);
+ bundleName.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
+ String fileName = Constants.EMPTY;
+ if (getWizard() instanceof ExternalizeStringsWizard) {
+ fileName = ((ExternalizeStringsWizard) getWizard()).getFileName();
+ int pos = fileName.lastIndexOf(Constants.DOT);
+ if (pos != -1) {
+ fileName = fileName.substring(0, pos);
+ }
+ } else if (getWizard() instanceof ExternalizeAllStringsWizard) {
+ fileName = ((ExternalizeAllStringsWizard) getWizard()).findBundlePrefix();
+ }
+ bundleName.setText(fileName);
+
+ /*
+ * Group with a place for bundle
+ */
+ Group group = new Group(composite, SWT.SHADOW_ETCHED_IN);
+ group.setLayout(new GridLayout(1, true));
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ group.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_SAVE_RESOURCE_BUNDLE);
+
+ facesConfig = new Button(group, SWT.RADIO);
+ laodBundle = new Button(group, SWT.RADIO);
+ userDefined = new Button(group, SWT.RADIO);
+ facesConfig.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_FACES_CONFIG);
+ laodBundle.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_LOAD_BUNDLE);
+ userDefined.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_USER_DEFINED);
+
+ userDefined.setSelection(true);
+
+ facesConfig.addSelectionListener(this);
+ laodBundle.addSelectionListener(this);
+ userDefined.addSelectionListener(this);
+
+ updateBundleNameField();
+ /*
+ * Wizard Page control should be initialized.
+ */
+ setControl(composite);
+ }
+
+ /**
+ * Gets the user specified bundle name.
+ *
+ * @return the bundle name
+ */
+ public String getBundleName() {
+ String name = Constants.EMPTY;
+ if (bundleName != null) {
+ name = bundleName.getText();
+ }
+ return name;
+ }
+
+ /**
+ * Checks if user has selected faces config.
+ *
+ * @return true, if in faces config
+ */
+ public boolean isInFacesConfig() {
+ return (null != facesConfig) && facesConfig.getSelection();
+ }
+
+ /**
+ * Checks if user has selected load bundle.
+ *
+ * @return true, if via load bundle
+ */
+ public boolean isViaLoadBundle() {
+ return (null != laodBundle) && laodBundle.getSelection();
+ }
+
+ /**
+ * Checks if user will register the bundle manually.
+ *
+ * @return true, if user defined
+ */
+ public boolean isUserDefined() {
+ return (null != userDefined) && userDefined.getSelection();
+ }
+
+ /**
+ * Update the dialog status.
+ */
+ public void updateStatus() {
+ /*
+ * If user has entered a path that is different from the source folder
+ * the base-name will be incorrect.
+ * Thus show warning message.
+ */
+ if (isSourceFolderSelected()) {
+ setMessage(null, IMessageProvider.NONE);
+ } else {
+ setMessage(
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_WRONG_BUNDLE_PLACEMENT,
+ IMessageProvider.WARNING);
+ }
+ }
+
+// /**
+// * Gets the selected place.
+// *
+// * @return the selected place
+// */
+// private int getSelectedPlace() {
+// int place = FACES_CONFIG;
+// if (isInFacesConfig()) {
+// place = FACES_CONFIG;
+// } else if (isViaLoadBundle()) {
+// place = LOAD_BUNDLE;
+// } else if (isUserDefined()) {
+// place = USER_DEFINED;
+// }
+// return place;
+// }
+
+ /**
+ * Update bundle name field.
+ */
+ private void updateBundleNameField() {
+ if (isUserDefined()) {
+ bundleLabel.setEnabled(false);
+ bundleName.setEnabled(false);
+ } else {
+ bundleLabel.setEnabled(true);
+ bundleName.setEnabled(true);
+ }
+ }
+
+ /**
+ * Checks if the source folder is selected.
+ *
+ * @return true, if the source folder is selected.
+ */
+ private boolean isSourceFolderSelected() {
+ boolean sourceFolderSelected = false;
+ if (getWizard() instanceof ExternalizeStringsWizard) {
+ ExternalizeStringsWizard wiz = (ExternalizeStringsWizard) getWizard();
+ if (wiz.getProject()!=null) {
+ IProject project = wiz.getProject();
+ WizardNewFileCreationPage page2 = (WizardNewFileCreationPage)wiz.getPage(
+ ExternalizeStringsWizard.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE);
+ String userDefinedPath = page2.getContainerFullPath().toString();
+ /*
+ * Get the source folders for the project
+ */
+ IResource[] src = EclipseUtil.getJavaSourceRoots(project);
+ /*
+ * When there are multiple source folders --
+ * match user defined folder to them.
+ */
+ String srcPath = Constants.EMPTY;
+ for (IResource res : src) {
+ srcPath = res.getFullPath().toString();
+ if (userDefinedPath.indexOf(srcPath) > -1) {
+ sourceFolderSelected = true;
+ break;
+ }
+ }
+ }
+ }
+ return sourceFolderSelected;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
+ */
+ public boolean isPageComplete() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ updateBundleNameField();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateBundleNameField();
+ }
+
+ public void setBundleName(String bn) {
+ if (bundleName != null) {
+ bundleName.setText(bn);
+ }
+ }
+
+}