Skip to content

Commit

Permalink
externalize hard-coded messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolayek committed Sep 3, 2020
1 parent 4706cea commit 07393f9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public boolean performFinish()
MessageDialog
.openError(
getShell(),
"Invalid platform directory",
"The platform directory is invalid. Please set the location to a valid directory (e.g. <path>/hybris/bin/platform) and make sure the platform has been built already (\"ant all\")." );
Messages.ImportWizard_invalid_platform_dir,
Messages.ImportWizard_invalid_platform_dir_info );
//TODO: set focus to the input field in question

// abort
Expand All @@ -124,8 +124,8 @@ public boolean performFinish()
MessageDialog
.openError(
getShell(),
"Unreadable or non-existing file specified",
"Please make sure the archive you selected is readable to the current user and exists." );
Messages.ImportWizard_wrong_src_zip,
Messages.ImportWizard_wrong_src_zip_info );

//TODO: set focus to the input field in question

Expand Down Expand Up @@ -161,7 +161,7 @@ private void attachSources()
}
catch( InvocationTargetException | InterruptedException e )
{
MessageDialog.openError( getShell(), "Error attaching sources", e.toString() );
MessageDialog.openError( getShell(), Messages.ImportWizard_error_attaching_srcs, e.toString() );
Thread.currentThread().interrupt();
}

Expand All @@ -186,8 +186,8 @@ private void importPlatform()
//Set platform home as workspace preference
try {
String platformDirStr = platformDir.getCanonicalPath();
Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
preferences.put("platform_home", platformDirStr);
Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences"); //$NON-NLS-1$
preferences.put("platform_home", platformDirStr); //$NON-NLS-1$
preferences.flush();
}
catch (IOException ioe) {
Expand All @@ -204,8 +204,8 @@ public void run( IProgressMonitor monitor ) throws InvocationTargetException
List<IProject> projects = Arrays.asList( ResourcesPlugin.getWorkspace().getRoot().getProjects() );
if( removeExistingProjects && projects != null && (!projects.isEmpty()) )
{
monitor.setTaskName( "Removing projects" );
monitor.beginTask( "Removing projects", projects.size() );
monitor.setTaskName( Messages.ImportWizard_removing_extension );
monitor.beginTask( Messages.ImportWizard_removing_extension, projects.size() ); //$NON-NLS-1$
int progress = 0;
for( IProject project: projects )
{
Expand Down Expand Up @@ -242,13 +242,11 @@ public void run( IProgressMonitor monitor ) throws InvocationTargetException
}
catch( InvocationTargetException | InterruptedException | RuntimeException e )
{
Activator.logError("Failed to import the platform",e);
Activator.logError(Messages.ImportWizard_error_on_import,e);
Throwable cause = e.getCause();

ErrorDialog.openError(this.page1.getControl().getShell(), "Error while importing SAP Commerce project", ""
+ "Error occured during importing project.\n"
+ "Try to reproduce issue running \"ant clean all\" in termminal\n"
+ "More details in stack trace below\n", createErrorStatus(cause));
ErrorDialog.openError(this.page1.getControl().getShell(), Messages.error_on_import,
Messages.error_on_import_info, createErrorStatus(cause));
enableAutoBuild( autobuildEnabled );
Thread.currentThread().interrupt();
}
Expand All @@ -269,7 +267,7 @@ protected boolean isAutoBuildEnabled()
{
IPreferencesService service = Platform.getPreferencesService();
String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
String key = "description.autobuilding";
String key = "description.autobuilding"; //$NON-NLS-1$
IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE};
return service.getBoolean( qualifier, key, false, contexts );
}
Expand All @@ -278,7 +276,7 @@ protected void enableAutoBuild( boolean enable )
{
String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
IEclipsePreferences node = InstanceScope.INSTANCE.getNode( qualifier );
node.putBoolean( "description.autobuilding", enable );
node.putBoolean( "description.autobuilding", enable ); //$NON-NLS-1$
try
{
node.flush();
Expand All @@ -297,14 +295,14 @@ protected void importPlatform( IProgressMonitor monitor, File platformDir , bool
}
catch( CoreException e )
{
Activator.logError("Failed to import the platform",e);
Activator.logError(Messages.error_on_import,e);
throw new InvocationTargetException( e );
}
}

protected void fixRuntimeEnvironment()
{
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( "platform" );
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( "platform" ); //$NON-NLS-1$
IJavaProject javaProject = JavaCore.create( project );
IVMInstall javaInstall = null;
try
Expand Down Expand Up @@ -335,7 +333,7 @@ private void setHeapSize( IVMInstall javaInstall )
if( javaVmParams == null || javaVmParams.length == 0 )
{
AbstractVMInstall abstractVMInstall = (AbstractVMInstall) javaInstall;
abstractVMInstall.setVMArgs("-Xmx1500M -XX:MaxPermSize=300M");
abstractVMInstall.setVMArgs("-Xmx1500M -XX:MaxPermSize=300M"); //$NON-NLS-1$
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.hybris.yps.hyeclipse.wizards;

import org.eclipse.osgi.util.NLS;

public class Messages extends NLS {
private static final String BUNDLE_NAME = "com.hybris.yps.hyeclipse.wizards.messages"; //$NON-NLS-1$
public static String error_on_import;
public static String error_on_import_info;
public static String ImportWizard_error_attaching_srcs;
public static String ImportWizard_error_on_import;
public static String ImportWizard_invalid_platform_dir;
public static String ImportWizard_invalid_platform_dir_info;
public static String ImportWizard_removing_extension;
public static String ImportWizard_wrong_src_zip;
public static String ImportWizard_wrong_src_zip_info;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

private Messages() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error_on_import_info=Error occured during importing project.\nTry to reproduce issue running "ant clean all" in termminal\nMore details in stack trace below\n
error_on_import=Failed to import the platform
ImportWizard_error_attaching_srcs=Error attaching sources
ImportWizard_error_on_import=Failed to import the platform
ImportWizard_invalid_platform_dir=Invalid platform directory
ImportWizard_invalid_platform_dir_info=The platform directory is invalid. Please set the location to a valid directory (e.g. <path>/hybris/bin/platform) and make sure the platform has been built already ("ant all").
ImportWizard_removing_extension=Removing extensions
ImportWizard_wrong_src_zip=Unreadable or non-existing file specified
ImportWizard_wrong_src_zip_info=Please make sure the archive you selected is readable to the current user and exists.

0 comments on commit 07393f9

Please sign in to comment.