]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.export.ui/src/org/simantics/export/ui/OptionsPage.java
Externalize strings in org.simantics.export.ui
[simantics/platform.git] / bundles / org.simantics.export.ui / src / org / simantics / export / ui / OptionsPage.java
index 9d2cea02042eb8432d75f52c03c1a08323a57dce..499974cadab747aa1f244d8613856a3ba41bd7fc 100644 (file)
@@ -11,6 +11,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.layout.GridData;
@@ -65,11 +66,11 @@ import org.simantics.utils.ui.dialogs.ShowMessage;
  */
 public class OptionsPage extends WizardPage {
 
-       public static String S_OUTPUT_OPTIONS = "Output Options";
+       public static String S_OUTPUT_OPTIONS = Messages.OptionsPage_OutputOptions;
        public static LabelReference P_OUTPUT_OPTIONS = new LabelReference( S_OUTPUT_OPTIONS );
        
        /** A reference to combo box selection */
-       public static String S_PUBLISH = "Publish to";
+       public static String S_PUBLISH = Messages.OptionsPage_PublishTo;
        public static ChildReference P_PUBLISH = ChildReference.compile(P_OUTPUT_OPTIONS, new LabelReference(S_PUBLISH));
        
        ExportContext ctx; 
@@ -83,7 +84,7 @@ public class OptionsPage extends WizardPage {
        String selectedPublisherId;
        
        public OptionsPage(ExportContext ctx) throws ExportException {
-               super("Options page", "Select export options", null);
+               super(Messages.OptionsPage_OptionsPage, Messages.OptionsPage_SelectExportOptions, null);
                
                this.ctx = ctx;
        }
@@ -100,7 +101,7 @@ public class OptionsPage extends WizardPage {
                public void handleEvent(Event event) {
                        updatingForm = true;
                        try {
-                               Preferences contentScopePrefs = ctx.store.node( "Selection-"+selectionHash );
+                               Preferences contentScopePrefs = ctx.store.node( "Selection-"+selectionHash ); //$NON-NLS-1$
                                Preferences workspaceScopePrefs = ctx.store;
                                
                                Composite outputOptions = (Composite) form.getControl(composite, P_OUTPUT_OPTIONS);
@@ -152,16 +153,16 @@ public class OptionsPage extends WizardPage {
                                updatingForm = false;
                                validate();
                        } catch ( BindingException e ) {
-                               setErrorMessage( e.getClass().getName()+": "+ e.getMessage() );
+                               setErrorMessage( e.getClass().getName()+": "+ e.getMessage() ); //$NON-NLS-1$
                    ExceptionUtils.logError(e);                 
                        } catch (AccessorConstructionException e) {
-                               setErrorMessage( e.getClass().getName()+": "+ e.getMessage() );
+                               setErrorMessage( e.getClass().getName()+": "+ e.getMessage() ); //$NON-NLS-1$
                    ExceptionUtils.logError(e);                 
                        } catch (AccessorException e) {
-                               setErrorMessage( e.getClass().getName()+": "+ e.getMessage() );
+                               setErrorMessage( e.getClass().getName()+": "+ e.getMessage() ); //$NON-NLS-1$
                    ExceptionUtils.logError(e);                 
                        } catch (ExportException e) {
-                               setErrorMessage( e.getClass().getName()+": "+ e.getMessage() );
+                               setErrorMessage( e.getClass().getName()+": "+ e.getMessage() ); //$NON-NLS-1$
                    ExceptionUtils.logError(e);                 
                        } finally {
                                updatingForm = false;
@@ -243,7 +244,7 @@ public class OptionsPage extends WizardPage {
                        
                        for ( Format format : formats ) {
                                if ( format.isGroupFormat() && contentByFormat.getValues(format).size()>1 ) {
-                                       outputOptions.addComponent("Merge "+format.fileext()+" content into one file", Datatypes.BOOLEAN);
+                                       outputOptions.addComponent(NLS.bind(Messages.OptionsPage_Merge, format.fileext()), Datatypes.BOOLEAN); //$NON-NLS-2$
                                }
                                
                                if ( format.isContainerFormat() ) {
@@ -261,8 +262,8 @@ public class OptionsPage extends WizardPage {
                                        }
                                        
                                        if ( attachmentCount > 0 ) { 
-                                               outputOptions.addComponent("Include attachments to "+format.fileext(), Datatypes.BOOLEAN);
-                                               outputOptions.addComponent("Export attachments of "+format.fileext()+" to separate files", Datatypes.BOOLEAN);
+                                               outputOptions.addComponent(NLS.bind(Messages.OptionsPage_IncludeAttachmentTo, format.fileext()), Datatypes.BOOLEAN);
+                                               outputOptions.addComponent(NLS.bind(Messages.OptionsPage_ExportAttachmentOf, format.fileext()), Datatypes.BOOLEAN); 
                                        }
                                }
                        }
@@ -325,8 +326,8 @@ public class OptionsPage extends WizardPage {
                        {
                                selection = contents;
                                Preferences workspaceScopePrefs = ctx.store;
-                               Preferences contentScopePrefs = ctx.store.node( "Selection-"+selectionHash );
-                               selectedPublisherId = ctx.store.get("publisherId", "");         
+                               Preferences contentScopePrefs = ctx.store.node( "Selection-"+selectionHash ); //$NON-NLS-1$
+                               selectedPublisherId = ctx.store.get("publisherId", "");          //$NON-NLS-1$ //$NON-NLS-2$
                                Publisher publisher = ctx.eep.getPublisher(selectedPublisherId);
                                if ( publisher != null ) {
                                        
@@ -361,17 +362,17 @@ public class OptionsPage extends WizardPage {
                        
                } catch (BindingException e) {
             ExceptionUtils.logError(e);                        
-                       ShowMessage.showError("Unexpected error", e.getClass().getName()+" "+e.getMessage());
+                       ShowMessage.showError(Messages.OptionsPage_UnExpectedError, e.getClass().getName()+" "+e.getMessage()); //$NON-NLS-2$
                        throw new RuntimeBindingException(e);
                } catch (ExportException e) {
             ExceptionUtils.logError(e);                        
-                       ShowMessage.showError("Unexpected error", e.getClass().getName()+" "+e.getMessage());
+                       ShowMessage.showError(Messages.OptionsPage_UnExpectedError, e.getClass().getName()+" "+e.getMessage()); //$NON-NLS-2$
                } catch (DatatypeConstructionException e) {
             ExceptionUtils.logError(e);                        
-                       ShowMessage.showError("Unexpected error", e.getClass().getName()+" "+e.getMessage());
+                       ShowMessage.showError(Messages.OptionsPage_UnExpectedError, e.getClass().getName()+" "+e.getMessage()); //$NON-NLS-2$
                } catch (AccessorConstructionException e) {
             ExceptionUtils.logError(e);                        
-                       ShowMessage.showError("Unexpected error", e.getClass().getName()+" "+e.getMessage());
+                       ShowMessage.showError(Messages.OptionsPage_UnExpectedError, e.getClass().getName()+" "+e.getMessage()); //$NON-NLS-2$
                } catch (AccessorException e) {
             ExceptionUtils.logError(e);                        
                        // TODO Auto-generated catch block
@@ -491,7 +492,7 @@ public class OptionsPage extends WizardPage {
                        result.accessor = Accessors.getAccessor(result.options);
                        result.contents = selection;
                        result.type = (RecordType) options.type();
-                       result.publisherId = "file";
+                       result.publisherId = "file"; //$NON-NLS-1$
                        
                        List<ExportAction> actions = new ArrayList<ExportAction>();
                        List<Content> manifest = new ArrayList<Content>(); 
@@ -522,7 +523,7 @@ public class OptionsPage extends WizardPage {
                        
                        String publisherLabel = ExporterUtils.getUnionValue(result.accessor, P_PUBLISH);
                        Publisher publisher = ctx.eep.getPublisherByLabel(publisherLabel);
-                       result.publisherId = publisher==null?"":publisher.id();                 
+                       result.publisherId = publisher==null?"":publisher.id();                  //$NON-NLS-1$
                        
                } catch (BindingException e) {
                        throw new ExportException(e);                   
@@ -554,7 +555,7 @@ public class OptionsPage extends WizardPage {
                }
                
 
-               setErrorMessage( errs.isEmpty() ? null : CollectionUtils.toString(errs, ", ") );
+               setErrorMessage( errs.isEmpty() ? null : CollectionUtils.toString(errs, ", ") ); //$NON-NLS-1$
                setPageComplete( errs.isEmpty() );
        }
                
@@ -572,14 +573,14 @@ public class OptionsPage extends WizardPage {
                        RecordAccessor ra = Accessors.getAccessor(options);
                        String publisherId = ExporterUtils.getUnionValue(ra, P_PUBLISH); 
                        Publisher publisher = ctx.eep.getPublisherByLabel(publisherId);
-                       if ( publisher!=null ) workspaceScopePrefs.put("publisherId", publisher.id());
+                       if ( publisher!=null ) workspaceScopePrefs.put("publisherId", publisher.id()); //$NON-NLS-1$
                        
                        if ( ra.type().hasComponent(P_OUTPUT_OPTIONS.label) ) {
                                RecordAccessor rao = ra.getComponent( P_OUTPUT_OPTIONS );
                                                                
-                               Pattern merge_pattern = Pattern.compile("Merge ([^\\s]*) content into one file");
-                               Pattern include_pattern = Pattern.compile("Include attachments to ([^\\s]*)");
-                               Pattern export_pattern = Pattern.compile("Export attachments of ([^\\s]*) to separate files");
+                               Pattern merge_pattern = Pattern.compile("Merge ([^\\s]*) content into one file"); //$NON-NLS-1$
+                               Pattern include_pattern = Pattern.compile("Include attachments to ([^\\s]*)"); //$NON-NLS-1$
+                               Pattern export_pattern = Pattern.compile("Export attachments of ([^\\s]*) to separate files"); //$NON-NLS-1$
                                
                                for (int i=0; i<rao.count(); i++) {
                                        String name = rao.type().getComponent(i).name;
@@ -590,7 +591,7 @@ public class OptionsPage extends WizardPage {
                                                String fileExt = m.group(1);
                                                Format format = ctx.eep.getFormatByExt(fileExt);
                                                Boolean value = (Boolean) rao.getFieldValue(i, Bindings.BOOLEAN);
-                                               String key = format.id()+"_merge";
+                                               String key = format.id()+"_merge"; //$NON-NLS-1$
                                                contentScopePrefs.putBoolean(key, value);
                                                workspaceScopePrefs.putBoolean(key, value);
                                        }
@@ -600,7 +601,7 @@ public class OptionsPage extends WizardPage {
                                                String fileExt = m.group(1);
                                                Format format = ctx.eep.getFormatByExt(fileExt);
                                                Boolean value = (Boolean) rao.getFieldValue(i, Bindings.BOOLEAN);
-                                               String key = format.id()+"_include_attachments";
+                                               String key = format.id()+"_include_attachments"; //$NON-NLS-1$
                                                contentScopePrefs.putBoolean(key, value);
                                                workspaceScopePrefs.putBoolean(key, value);
                                        }
@@ -610,7 +611,7 @@ public class OptionsPage extends WizardPage {
                                                String fileExt = m.group(1);
                                                Format format = ctx.eep.getFormatByExt(fileExt);
                                                Boolean value = (Boolean) rao.getFieldValue(i, Bindings.BOOLEAN);
-                                               String key = format.id()+"_export_attachments";
+                                               String key = format.id()+"_export_attachments"; //$NON-NLS-1$
                                                contentScopePrefs.putBoolean(key, value);
                                                workspaceScopePrefs.putBoolean(key, value);
                                        }
@@ -639,7 +640,7 @@ public class OptionsPage extends WizardPage {
                //Preferences workspaceScopePrefs = ctx.store;
         try {
                        RecordAccessor ra = Accessors.getAccessor(options);             
-                       String publisherId = workspaceScopePrefs.get("publisherId", "");
+                       String publisherId = workspaceScopePrefs.get("publisherId", ""); //$NON-NLS-1$ //$NON-NLS-2$
                        Publisher publisher = ctx.eep.getPublisher(publisherId);
                        if ( publisher != null ) ExporterUtils.setUnionValue(ra, P_PUBLISH, publisher.label());
                        
@@ -648,7 +649,7 @@ public class OptionsPage extends WizardPage {
                                                                
                                for (Format format : ctx.eep.formats()) {
                                        if ( format.isGroupFormat() ) {
-                                               String key = format.id()+"_merge";
+                                               String key = format.id()+"_merge"; //$NON-NLS-1$
                                                Boolean value = null;
                                                if ( containsKey(contentScopePrefs, key) ) {
                                                        value = contentScopePrefs.getBoolean(key, false); 
@@ -657,7 +658,7 @@ public class OptionsPage extends WizardPage {
                                                }
                                                                                        
                                                if ( value != null ) {
-                                                       String key2 = "Merge "+format.fileext()+" content into one file";
+                                                       String key2 = "Merge "+format.fileext()+" content into one file"; //$NON-NLS-1$ //$NON-NLS-2$
                                                        int index = rao.type().getComponentIndex2(key2);
                                                        if ( index>=0 ) {
                                                                rao.setFieldValue(index, Bindings.BOOLEAN, value);
@@ -666,7 +667,7 @@ public class OptionsPage extends WizardPage {
                                        }
                                        
                                        if ( format.isContainerFormat() ) {
-                                               String key = format.id()+"_include_attachments";
+                                               String key = format.id()+"_include_attachments"; //$NON-NLS-1$
                                                Boolean value = null;
                                                if ( containsKey(contentScopePrefs, key) ) {
                                                        value = contentScopePrefs.getBoolean(key, false); 
@@ -675,7 +676,7 @@ public class OptionsPage extends WizardPage {
                                                }
                                                                                        
                                                if ( value != null ) {
-                                                       String key2 = "Include attachments to "+format.fileext();
+                                                       String key2 = "Include attachments to "+format.fileext(); //$NON-NLS-1$
                                                        int index = rao.type().getComponentIndex2(key2);
                                                        if ( index>=0 ) {
                                                                rao.setFieldValue(index, Bindings.BOOLEAN, value);
@@ -684,7 +685,7 @@ public class OptionsPage extends WizardPage {
                                        }
                                        
                                        if ( format.isContainerFormat() ) {
-                                               String key = format.id()+"_export_attachments";
+                                               String key = format.id()+"_export_attachments"; //$NON-NLS-1$
                                                Boolean value = null;
                                                if ( containsKey(contentScopePrefs, key) ) {
                                                        value = contentScopePrefs.getBoolean(key, false); 
@@ -693,7 +694,7 @@ public class OptionsPage extends WizardPage {
                                                }
                                                                                        
                                                if ( value != null ) {
-                                                       String key2 = "Export attachments of "+format.fileext()+" to separate files";
+                                                       String key2 = "Export attachments of"+format.fileext()+" to separate files"; //$NON-NLS-2$
                                                        int index = rao.type().getComponentIndex2(key2);
                                                        if ( index>=0 ) {
                                                                rao.setFieldValue(index, Bindings.BOOLEAN, value);
@@ -717,7 +718,7 @@ public class OptionsPage extends WizardPage {
        public void savePrefs() throws ExportException {
                try {
                        int oldSelectionHash = selectionHash;                   
-                       Preferences contentScopePrefs = ctx.store.node( "Selection-"+oldSelectionHash );
+                       Preferences contentScopePrefs = ctx.store.node( "Selection-"+oldSelectionHash ); //$NON-NLS-1$
                        Preferences workspaceScopePrefs = ctx.store;
                                        
                        RecordBinding binding = ctx.databoard.getMutableBinding( form.type() );
@@ -767,11 +768,11 @@ public class OptionsPage extends WizardPage {
                                
                                for (Format format : ctx.eep.formats()) {
                                        if ( format.isContainerFormat() ) {
-                                               String key = "Include attachments to "+format.fileext();
+                                               String key = "Include attachments to "+format.fileext(); //$NON-NLS-1$
                                                int index = rao.type().getComponentIndex2(key);
                                                if ( index>=0 ) rao.setFieldValue(index, Bindings.BOOLEAN, true);
                                                
-                                               key = "Export attachments of "+format.fileext()+" to separate files";;
+                                               key = "Export attachments of "+format.fileext()+" to separate files";; //$NON-NLS-1$ //$NON-NLS-2$
                                                index = rao.type().getComponentIndex2(key);
                                                if ( index>=0 ) rao.setFieldValue(index, Bindings.BOOLEAN, true);
                                        }