Bug 444340 - Externalize Strings
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/Messages.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/Messages.java
index 610b27a..550169e 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/Messages.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/Messages.java
@@ -37,6 +37,7 @@
public static String BaseApplicationModelWizard_TheFileAlreadyExists;
public static String NewAddonClassWizard_NewAddon;
public static String NewAddonClassWizard_NewAddonClass;
+ public static String NewApplicationModelWizard_IncludeDefaultAddons;
public static String NewDynamicMenuContributionClassWizard_AboutToShowMethod;
public static String NewDynamicMenuContributionClassWizard_CreateNewContribution;
public static String NewDynamicMenuContributionClassWizard_NewDynamicContribution;
@@ -44,6 +45,18 @@
public static String NewHandlerClassWizard_CreateNewHandler;
public static String NewHandlerClassWizard_ExecuteMethod;
public static String NewHandlerClassWizard_NewHandler;
+ public static String NewModelFilePage_Browse;
+ public static String NewModelFilePage_Container;
+ public static String NewModelFilePage_FileContainerMustBeSpecified;
+ public static String NewModelFilePage_FileContainerMustExists;
+ public static String NewModelFilePage_FileExtensionMustBeE4XMI;
+ public static String NewModelFilePage_FileName;
+ public static String NewModelFilePage_FileNameMustBeSpecified;
+ public static String NewModelFilePage_FileNameMustBeValid;
+ public static String NewModelFilePage_NewApplicationModel;
+ public static String NewModelFilePage_ProjectMustBeWritable;
+ public static String NewModelFilePage_SelectTheNewContainer;
+ public static String NewModelFilePage_TheWizardCreates;
public static String NewPartClassWizard_CreateNewPart;
public static String NewPartClassWizard_FocusMethod;
public static String NewPartClassWizard_NewPart;
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/messages.properties b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/messages.properties
index 1c2f1cd..9c51ab9 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/messages.properties
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/messages.properties
@@ -16,6 +16,7 @@
BaseApplicationModelWizard_TheFileAlreadyExists=The file already exists.
NewAddonClassWizard_NewAddon=New Addon
NewAddonClassWizard_NewAddonClass=Create a new addon class
+NewApplicationModelWizard_IncludeDefaultAddons=Include default addons
NewDynamicMenuContributionClassWizard_AboutToShowMethod=AboutToShow Method
NewDynamicMenuContributionClassWizard_CreateNewContribution=Create a new dynamic menu contribution class
NewDynamicMenuContributionClassWizard_NewDynamicContribution=New Dynamic Menu Contribution
@@ -23,6 +24,18 @@
NewHandlerClassWizard_CreateNewHandler=Create a new handler class
NewHandlerClassWizard_ExecuteMethod=Execute Method
NewHandlerClassWizard_NewHandler=New Handler
+NewModelFilePage_Browse=Browse...
+NewModelFilePage_Container=&Container:
+NewModelFilePage_FileContainerMustBeSpecified=File container must be specified
+NewModelFilePage_FileContainerMustExists=File container must exist
+NewModelFilePage_FileExtensionMustBeE4XMI=File extension must be "e4xmi"
+NewModelFilePage_FileName=&File name:
+NewModelFilePage_FileNameMustBeSpecified=File name must be specified
+NewModelFilePage_FileNameMustBeValid=File name must be valid
+NewModelFilePage_NewApplicationModel=New application model
+NewModelFilePage_ProjectMustBeWritable=Project must be writable
+NewModelFilePage_SelectTheNewContainer=Select new file container
+NewModelFilePage_TheWizardCreates=This wizard creates a new Eclipse 4 application model
NewPartClassWizard_CreateNewPart=Create a new part class
NewPartClassWizard_FocusMethod=Focus Method
NewPartClassWizard_NewPart=New Part
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java
index 98cef78..bbbc1b1 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java
@@ -6,12 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Sopot Cela <sopotcela@gmail.com> - initial API and implementation
- * Marco Descher <marco@descher.at> - Bug 434371
+ * Sopot Cela <sopotcela@gmail.com> - initial API and implementation
+ * Marco Descher <marco@descher.at> - Bug 434371
******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.model;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -32,93 +31,97 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.PlatformUI;
-
public class ExtractContributionModelWizard extends BaseApplicationModelWizard {
- private List<MApplicationElement> oes= new ArrayList<MApplicationElement>();
+ private final List<MApplicationElement> oes = new ArrayList<MApplicationElement>();
- public ExtractContributionModelWizard(MApplicationElement oe){
+ public ExtractContributionModelWizard(MApplicationElement oe) {
super();
oes.add(oe);
}
- public ExtractContributionModelWizard(List<MApplicationElement> oes){
+ public ExtractContributionModelWizard(List<MApplicationElement> oes) {
this.oes.addAll(oes);
}
- public ExtractContributionModelWizard(){
+ public ExtractContributionModelWizard() {
super();
}
@Override
public String getDefaultFileName() {
- return "fragment.e4xmi";
+ return "fragment.e4xmi"; //$NON-NLS-1$
}
- HashMap<String, MCommand> importCommands=new HashMap<String, MCommand>();
- public void resolveCommandImports(MApplicationElement moe,MModelFragments mModelFragments){
- if (moe instanceof MHandler) {
- MHandler mhandler = (MHandler) moe;
- MCommand command = ((MHandler) moe).getCommand();
- MCommand existImportCommand = importCommands.get(command.getElementId());
- if(existImportCommand==null){
- MApplicationElement copy = (MApplicationElement) EcoreUtil.copy((EObject)command);
- mhandler.setCommand((MCommand) copy);
- importCommands.put(copy.getElementId(), (MCommand) copy);
+ HashMap<String, MCommand> importCommands = new HashMap<String, MCommand>();
+
+ public void resolveCommandImports(MApplicationElement moe, MModelFragments mModelFragments) {
+ if (moe instanceof MHandler) {
+
+ final MHandler mhandler = (MHandler) moe;
+ final MCommand command = ((MHandler) moe).getCommand();
+ final MCommand existImportCommand = importCommands.get(command.getElementId());
+ if (existImportCommand == null) {
+ final MApplicationElement copy = (MApplicationElement) EcoreUtil.copy((EObject) command);
+ mhandler.setCommand((MCommand) copy);
+ importCommands.put(copy.getElementId(), (MCommand) copy);
mModelFragments.getImports().add(copy);
- }else{
- mhandler.setCommand(existImportCommand);
- }
- }else if(moe instanceof MHandledItem){
- MHandledItem mh=(MHandledItem) moe;
- MCommand command = mh.getCommand();
- MCommand existImportCommand = importCommands.get(command.getElementId());
- if(existImportCommand==null){
- MApplicationElement copy = (MApplicationElement) EcoreUtil.copy((EObject)command);
- mh.setCommand((MCommand) copy);
- importCommands.put(copy.getElementId(), command);
- mModelFragments.getImports().add(copy);
- }else{
- mh.setCommand(existImportCommand);
- }
- }
- }
+ } else {
+ mhandler.setCommand(existImportCommand);
+ }
+ } else if (moe instanceof MHandledItem) {
+ final MHandledItem mh = (MHandledItem) moe;
+ final MCommand command = mh.getCommand();
+ final MCommand existImportCommand = importCommands.get(command.getElementId());
+ if (existImportCommand == null) {
+ final MApplicationElement copy = (MApplicationElement) EcoreUtil.copy((EObject) command);
+ mh.setCommand((MCommand) copy);
+ importCommands.put(copy.getElementId(), command);
+ mModelFragments.getImports().add(copy);
+ } else {
+ mh.setCommand(existImportCommand);
+ }
+ }
+ }
@Override
protected EObject createInitialModel() {
- MModelFragments createModelFragments = MFragmentFactory.INSTANCE.createModelFragments();
- for (MApplicationElement moe : oes) {
- EObject eObject=(EObject) moe;
- TreeIterator<EObject> eAllContents = eObject.eAllContents();
- boolean hasNext = eAllContents.hasNext();
- if(!hasNext){
- resolveCommandImports(moe, createModelFragments);
- }
- while(hasNext){
- MApplicationElement next=(MApplicationElement) eAllContents.next();
- resolveCommandImports(next, createModelFragments);
- hasNext=eAllContents.hasNext();
- }
- MStringModelFragment createStringModelFragment = MFragmentFactory.INSTANCE.createStringModelFragment();
- MApplicationElement e = (MApplicationElement) EcoreUtil.copy((EObject) moe);
- String featurename = ((EObject) moe).eContainmentFeature().getName();
- createStringModelFragment.setParentElementId(((MApplicationElement) ((EObject) moe).eContainer()).getElementId());
- createStringModelFragment.getElements().add(e);
- createStringModelFragment.setFeaturename(featurename);
+ final MModelFragments createModelFragments = MFragmentFactory.INSTANCE.createModelFragments();
+ for (final MApplicationElement moe : oes) {
+ final EObject eObject = (EObject) moe;
+ final TreeIterator<EObject> eAllContents = eObject.eAllContents();
+ boolean hasNext = eAllContents.hasNext();
+ if (!hasNext) {
+ resolveCommandImports(moe, createModelFragments);
+ }
+ while (hasNext) {
+ final MApplicationElement next = (MApplicationElement) eAllContents.next();
+ resolveCommandImports(next, createModelFragments);
+ hasNext = eAllContents.hasNext();
+ }
+ final MStringModelFragment createStringModelFragment = MFragmentFactory.INSTANCE
+ .createStringModelFragment();
+ final MApplicationElement e = (MApplicationElement) EcoreUtil.copy((EObject) moe);
+ final String featurename = ((EObject) moe).eContainmentFeature().getName();
+ createStringModelFragment.setParentElementId(((MApplicationElement) ((EObject) moe).eContainer())
+ .getElementId());
+ createStringModelFragment.getElements().add(e);
+ createStringModelFragment.setFeaturename(featurename);
- createModelFragments.getFragments().add(createStringModelFragment);
+ createModelFragments.getFragments().add(createStringModelFragment);
}
- return (EObject)createModelFragments;
+ return (EObject) createModelFragments;
}
- public void setup(IProject project){
- this.init(PlatformUI.getWorkbench(),new StructuredSelection(project));
+ public void setup(IProject project) {
+ init(PlatformUI.getWorkbench(), new StructuredSelection(project));
}
+
@Override
protected NewModelFilePage createWizardPage(ISelection selection) {
- return new NewModelFilePage(selection,getDefaultFileName());
+ return new NewModelFilePage(selection, getDefaultFileName());
}
-
+
@Override
protected void adjustDependencies(IFile file) {
super.adjustFragmentDependencies(file);
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewApplicationModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewApplicationModelWizard.java
index f4ab339..3af8280 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewApplicationModelWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewApplicationModelWizard.java
@@ -6,11 +6,12 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.model;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.e4.internal.tools.Messages;
import org.eclipse.e4.ui.model.application.MAddon;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.MApplicationFactory;
@@ -21,50 +22,56 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-
public class NewApplicationModelWizard extends BaseApplicationModelWizard {
@Override
public String getDefaultFileName() {
- return "Application.e4xmi";
+ return "Application.e4xmi"; //$NON-NLS-1$
}
-
+
@Override
protected EObject createInitialModel() {
- MApplication application = MApplicationFactory.INSTANCE.createApplication();
+ final MApplication application = MApplicationFactory.INSTANCE.createApplication();
try {
- application.setElementId(getModelFile().getProject().getName() + ".application");
- if( ((ModelFilePageImpl)getPages()[0]).includeDefaultAddons.getSelection() ) {
- String[][] addons = {
- { "org.eclipse.e4.core.commands.service", "bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon" },
- { "org.eclipse.e4.ui.contexts.service", "bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon" },
- { "org.eclipse.e4.ui.bindings.service", "bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon" },
- { "org.eclipse.e4.ui.workbench.commands.model", "bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon" },
- { "org.eclipse.e4.ui.workbench.contexts.model", "bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon" },
- { "org.eclipse.e4.ui.workbench.bindings.model", "bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon" },
- { "org.eclipse.e4.ui.workbench.handler.model", "bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon" }
-
+ application.setElementId(getModelFile().getProject().getName() + ".application"); //$NON-NLS-1$
+ if (((ModelFilePageImpl) getPages()[0]).includeDefaultAddons.getSelection()) {
+ final String[][] addons = {
+ {
+ "org.eclipse.e4.core.commands.service", "bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon" }, //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ "org.eclipse.e4.ui.contexts.service", "bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon" }, //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ "org.eclipse.e4.ui.bindings.service", "bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon" }, //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ "org.eclipse.e4.ui.workbench.commands.model", "bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon" }, //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ "org.eclipse.e4.ui.workbench.contexts.model", "bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon" }, //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ "org.eclipse.e4.ui.workbench.bindings.model", "bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon" }, //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ "org.eclipse.e4.ui.workbench.handler.model", "bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon" } //$NON-NLS-1$ //$NON-NLS-2$
+
};
-
- for( String[] a : addons ) {
- MAddon addon = MApplicationFactory.INSTANCE.createAddon();
+
+ for (final String[] a : addons) {
+ final MAddon addon = MApplicationFactory.INSTANCE.createAddon();
addon.setElementId(a[0]);
addon.setContributionURI(a[1]);
application.getAddons().add(addon);
}
}
- } catch (CoreException e) {
+ } catch (final CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (EObject) application;
}
-
+
@Override
protected NewModelFilePage createWizardPage(ISelection selection) {
- return new ModelFilePageImpl(selection,getDefaultFileName());
+ return new ModelFilePageImpl(selection, getDefaultFileName());
}
-
+
static class ModelFilePageImpl extends NewModelFilePage {
private Button includeDefaultAddons;
@@ -76,11 +83,11 @@
@Override
protected void createAdditionalControls(Composite parent) {
super.createAdditionalControls(parent);
-
+
new Label(parent, SWT.NONE);
-
+
includeDefaultAddons = new Button(parent, SWT.CHECK);
- includeDefaultAddons.setText("Include default addons");
+ includeDefaultAddons.setText(Messages.NewApplicationModelWizard_IncludeDefaultAddons);
includeDefaultAddons.setSelection(true);
}
}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java
index 50d1872..076f473 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- * Marco Descher <marco@descher.at> - Bug 392907, Bug 434371
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Marco Descher <marco@descher.at> - Bug 392907, Bug 434371
******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.model;
@@ -20,7 +20,7 @@
@Override
public String getDefaultFileName() {
- return "fragment.e4xmi";
+ return "fragment.e4xmi"; //$NON-NLS-1$
}
@Override
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java
index 4533ca4..00dc0e1 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.model;
@@ -14,6 +14,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
+import org.eclipse.e4.internal.tools.Messages;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.dialogs.IDialogPage;
@@ -45,19 +46,18 @@
private Text fileText;
- private ISelection selection;
-
- private String defaultFilename;
+ private final ISelection selection;
+
+ private final String defaultFilename;
/**
* Constructor for SampleNewWizardPage.
- *
- * @param pageName
+ *
*/
public NewModelFilePage(ISelection selection, String defaultFilename) {
- super("wizardPage");
- setTitle("New application model");
- setDescription("This wizard creates a new Eclipse 4 application model");
+ super("wizardPage"); //$NON-NLS-1$
+ setTitle(Messages.NewModelFilePage_NewApplicationModel);
+ setDescription(Messages.NewModelFilePage_TheWizardCreates);
this.selection = selection;
this.defaultFilename = defaultFilename;
}
@@ -65,26 +65,28 @@
/**
* @see IDialogPage#createControl(Composite)
*/
+ @Override
public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
+ final Composite container = new Composite(parent, SWT.NULL);
+ final GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 3;
layout.verticalSpacing = 9;
Label label = new Label(container, SWT.NULL);
- label.setText("&Container:");
+ label.setText(Messages.NewModelFilePage_Container);
containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
containerText.setLayoutData(gd);
containerText.addModifyListener(new ModifyListener() {
+ @Override
public void modifyText(ModifyEvent e) {
dialogChanged();
}
});
- Button button = new Button(container, SWT.PUSH);
- button.setText("Browse...");
+ final Button button = new Button(container, SWT.PUSH);
+ button.setText(Messages.NewModelFilePage_Browse);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -92,19 +94,20 @@
}
});
label = new Label(container, SWT.NULL);
- label.setText("&File name:");
+ label.setText(Messages.NewModelFilePage_FileName);
fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
gd = new GridData(GridData.FILL_HORIZONTAL);
fileText.setLayoutData(gd);
fileText.addModifyListener(new ModifyListener() {
+ @Override
public void modifyText(ModifyEvent e) {
dialogChanged();
}
});
-
+
new Label(container, SWT.NONE);
-
+
createAdditionalControls(container);
initialize();
dialogChanged();
@@ -112,33 +115,35 @@
}
protected void createAdditionalControls(Composite parent) {
-
+
}
-
+
/**
* Tests if the current workbench selection is a suitable container to use.
*/
private void initialize() {
if (selection != null && selection.isEmpty() == false
- && selection instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) selection;
- if (ssel.size() > 1)
+ && selection instanceof IStructuredSelection) {
+ final IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.size() > 1) {
return;
- Object obj = ssel.getFirstElement();
-
+ }
+ final Object obj = ssel.getFirstElement();
+
if (obj instanceof IResource) {
IContainer container;
- if (obj instanceof IContainer)
+ if (obj instanceof IContainer) {
container = (IContainer) obj;
- else
+ } else {
container = ((IResource) obj).getParent();
+ }
containerText.setText(container.getFullPath().toString());
- } else if( obj instanceof IJavaProject ) {
- IJavaProject container = (IJavaProject) obj;
+ } else if (obj instanceof IJavaProject) {
+ final IJavaProject container = (IJavaProject) obj;
try {
containerText.setText(container.getCorrespondingResource().getFullPath().toString());
- } catch(JavaModelException e) {
+ } catch (final JavaModelException e) {
e.printStackTrace();
}
}
@@ -152,11 +157,11 @@
*/
private void handleBrowse() {
- ContainerSelectionDialog dialog = new ContainerSelectionDialog(
- getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
- "Select new file container");
+ final ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+ Messages.NewModelFilePage_SelectTheNewContainer);
if (dialog.open() == Window.OK) {
- Object[] result = dialog.getResult();
+ final Object[] result = dialog.getResult();
if (result.length == 1) {
containerText.setText(((Path) result[0]).toString());
}
@@ -168,36 +173,36 @@
*/
private void dialogChanged() {
- IResource container = ResourcesPlugin.getWorkspace().getRoot()
- .findMember(new Path(getContainerName()));
- String fileName = getFileName();
+ final IResource container = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(new Path(getContainerName()));
+ final String fileName = getFileName();
if (getContainerName().length() == 0) {
- updateStatus("File container must be specified");
+ updateStatus(Messages.NewModelFilePage_FileContainerMustBeSpecified);
return;
}
if (container == null
- || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
- updateStatus("File container must exist");
+ || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
+ updateStatus(Messages.NewModelFilePage_FileContainerMustExists);
return;
}
if (!container.isAccessible()) {
- updateStatus("Project must be writable");
+ updateStatus(Messages.NewModelFilePage_ProjectMustBeWritable);
return;
}
if (fileName.length() == 0) {
- updateStatus("File name must be specified");
+ updateStatus(Messages.NewModelFilePage_FileNameMustBeSpecified);
return;
}
if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
- updateStatus("File name must be valid");
+ updateStatus(Messages.NewModelFilePage_FileNameMustBeValid);
return;
}
- int dotLoc = fileName.lastIndexOf('.');
+ final int dotLoc = fileName.lastIndexOf('.');
if (dotLoc != -1) {
- String ext = fileName.substring(dotLoc + 1);
- if (ext.equalsIgnoreCase("e4xmi") == false) {
- updateStatus("File extension must be \"e4xmi\"");
+ final String ext = fileName.substring(dotLoc + 1);
+ if (ext.equalsIgnoreCase("e4xmi") == false) { //$NON-NLS-1$
+ updateStatus(Messages.NewModelFilePage_FileExtensionMustBeE4XMI);
return;
}
}