1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

Externalize Strings.

This commit is contained in:
Ken Ryall 2008-03-28 21:15:46 +00:00
parent bb792ef3b0
commit 0a8de13225
8 changed files with 134 additions and 44 deletions

View file

@ -50,7 +50,7 @@ class ExecutablesContentProvider extends ColumnLabelProvider implements IStructu
// once the list of executables has been calculated. this can
// take a while and we don't want
// to block the UI.
Job refreshJob = new Job("Fetching executables") {
Job refreshJob = new Job(Messages.ExecutablesContentProvider_FetchingExecutables) {
@Override
protected IStatus run(IProgressMonitor monitor) {
@ -102,7 +102,7 @@ class ExecutablesContentProvider extends ColumnLabelProvider implements IStructu
else if (cell.getColumnIndex() == 2)
cellText = exe.getPath().toOSString();
else if (cell.getColumnIndex() == 3) {
cellText = "";
cellText = ""; //$NON-NLS-1$
IPath path = exe.getPath();
if (path != null && path.toFile().exists()) {
long fileLength = path.toFile().length();
@ -110,7 +110,7 @@ class ExecutablesContentProvider extends ColumnLabelProvider implements IStructu
}
cell.setImage(null);
} else if (cell.getColumnIndex() == 4) {
cellText = "";
cellText = ""; //$NON-NLS-1$
IPath path = exe.getPath();
if (path != null && path.toFile().exists()) {
long modified = path.toFile().lastModified();
@ -118,7 +118,7 @@ class ExecutablesContentProvider extends ColumnLabelProvider implements IStructu
}
cell.setImage(null);
} else if (cell.getColumnIndex() == 5) {
cellText = "";
cellText = ""; //$NON-NLS-1$
String fileExtension = exe.getPath().getFileExtension();
if (fileExtension != null)
cellText = fileExtension;

View file

@ -123,14 +123,14 @@ public class ExecutablesView extends ViewPart {
* names and should not be localized. Display names are set when the columns
* are created in the sub views.
*/
private String[] columnNames = { "Executable Name", "Executable Project", "Executable Location", "Executable Size", "Executable Date",
"Executable Type", "Source File Name", "Source File Location", "Source File Original Location", "Source File Size", "Source File Date",
"Source File Type" };
private String[] columnNames = { Messages.ExecutablesView_ExeName, Messages.ExecutablesView_ExeProject, Messages.ExecutablesView_ExeLocation, Messages.ExecutablesView_ExeSize, Messages.ExecutablesView_ExeData,
Messages.ExecutablesView_ExeType, Messages.ExecutablesView_SrcName, Messages.ExecutablesView_SrcLocation, Messages.ExecutablesView_SrcOrgLocation, Messages.ExecutablesView_SrcSize, Messages.ExecutablesView_SrcDate,
Messages.ExecutablesView_SrcType };
/**
* Not all the columns are visible by default. Here are the ones that are.
*/
private String defaultVisibleColumns = "Executable Name,Executable Project,Executable Location,Source File Name,Source File Location";
private String defaultVisibleColumns = Messages.ExecutablesView_DefaultColumns;
private TreeColumn[] allColumns = new TreeColumn[columnNames.length];
/**
@ -180,7 +180,7 @@ public class ExecutablesView extends ViewPart {
}
public ConfigureColumnsAction() {
setText("Configure Columns");
setText(Messages.ExecutablesView_ConfigureColumns);
setId(CDebugUIPlugin.getUniqueIdentifier() + ".ConfigureColumnsAction"); //$NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, CONFIGURE_COLUMNS_ACTION);
}
@ -192,14 +192,14 @@ public class ExecutablesView extends ViewPart {
*/
public void run() {
ListSelectionDialog dialog = new ListSelectionDialog(ExecutablesView.this.getExecutablesViewer().getTree().getShell(), this,
new ColumnContentProvider(), new ColumnLabelProvider(), "Select the columns to show");
new ColumnContentProvider(), new ColumnLabelProvider(), Messages.ExecutablesView_SelectColumns);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, CONFIGURE_COLUMNS_DIALOG);
String[] visibleColumns = getVisibleColumns();
List<String> initialSelection = new ArrayList<String>(visibleColumns.length);
for (int i = 0; i < visibleColumns.length; i++) {
initialSelection.add(visibleColumns[i]);
}
dialog.setTitle("Configure COlumns");
dialog.setTitle(Messages.ExecutablesView_ConfigureColumns);
dialog.setInitialElementSelections(initialSelection);
if (dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
@ -281,10 +281,10 @@ public class ExecutablesView extends ViewPart {
// Initialize the list of visible columns
if (memento.getString(P_VISIBLE_COLUMNS).length() > 0) {
String[] visibleColumns = memento.getString(P_VISIBLE_COLUMNS).split(",");
String[] visibleColumns = memento.getString(P_VISIBLE_COLUMNS).split(","); //$NON-NLS-1$
setVisibleColumns(visibleColumns);
} else {
setVisibleColumns(defaultVisibleColumns.split(","));
setVisibleColumns(defaultVisibleColumns.split(",")); //$NON-NLS-1$
}
sourceFilesViewer.packColumns();
@ -300,7 +300,7 @@ public class ExecutablesView extends ViewPart {
StringBuffer visibleColumns = new StringBuffer();
for (int i = 0; i < ids.length; i++) {
if (i > 0)
visibleColumns.append(",");
visibleColumns.append(","); //$NON-NLS-1$
visibleColumns.append(ids[i]);
}
memento.putString(P_VISIBLE_COLUMNS, visibleColumns.toString());
@ -351,7 +351,7 @@ public class ExecutablesView extends ViewPart {
private Action createConfigureColumnsAction() {
ConfigureColumnsAction action = new ConfigureColumnsAction();
action.setToolTipText("Columns");
action.setToolTipText(Messages.ExecutablesView_Columns);
action.setImageDescriptor(ExecutablesView.DESC_COLUMNS);
action.setDisabledImageDescriptor(ExecutablesView.DESC_COLUMNS_DISABLED);
action.setEnabled(true);
@ -361,7 +361,7 @@ public class ExecutablesView extends ViewPart {
protected void importExecutables(final String[] fileNames) {
if (fileNames.length > 0) {
Job importJob = new Job("Import Executables") {
Job importJob = new Job(Messages.ExecutablesView_ImportExecutables) {
@Override
public IStatus run(IProgressMonitor monitor) {
@ -374,24 +374,24 @@ public class ExecutablesView extends ViewPart {
}
private Action createImportAction() {
Action action = new Action("Import") {
Action action = new Action(Messages.ExecutablesView_Import) {
public void run() {
FileDialog dialog = new FileDialog(getViewSite().getShell(), SWT.NONE);
dialog.setText("Select an executable file");
dialog.setText(Messages.ExecutablesView_SelectExeFile);
String res = dialog.open();
if (res != null) {
if (Platform.getOS().equals(Platform.OS_MACOSX) && res.endsWith(".app")) {
if (Platform.getOS().equals(Platform.OS_MACOSX) && res.endsWith(".app")) { //$NON-NLS-1$
// On Mac OS X the file dialog will let you select the
// package but not the executable inside.
Path macPath = new Path(res);
res = res + "/Contents/MacOS/" + macPath.lastSegment();
res = res + "/Contents/MacOS/" + macPath.lastSegment(); //$NON-NLS-1$
res = res.substring(0, res.length() - 4);
}
importExecutables(new String[] { res });
}
}
};
action.setToolTipText("Import an executable file");
action.setToolTipText(Messages.ExecutablesView_ImportExe);
action.setImageDescriptor(ExecutablesView.DESC_IMPORT);
action.setDisabledImageDescriptor(ExecutablesView.DESC_IMPORT_DISABLED);
action.setEnabled(true);
@ -399,12 +399,12 @@ public class ExecutablesView extends ViewPart {
}
private Action createRefreshAction() {
Action action = new Action("Refresh") {
Action action = new Action(Messages.ExecutablesView_Refresh) {
public void run() {
ExecutablesManager.getExecutablesManager().scheduleRefresh(null, 0);
}
};
action.setToolTipText("Refresh the list of executables");
action.setToolTipText(Messages.ExecutablesView_RefreshList);
action.setImageDescriptor(ExecutablesView.DESC_REFRESH);
action.setDisabledImageDescriptor(ExecutablesView.DESC_REFRESH_DISABLED);
action.setEnabled(true);

View file

@ -107,37 +107,37 @@ public class ExecutablesViewer extends BaseViewer implements IExecutablesChangeL
private void createColumns() {
nameColumn = new TreeColumn(getTree(), SWT.NONE);
nameColumn.setWidth(100);
nameColumn.setText("Executable Name");
nameColumn.setText(Messages.ExecutablesViewer_ExecutableName);
nameColumn.setMoveable(true);
nameColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.NAME));
projectColumn = new TreeColumn(getTree(), SWT.NONE);
projectColumn.setWidth(100);
projectColumn.setMoveable(true);
projectColumn.setText("Project");
projectColumn.setText(Messages.ExecutablesViewer_Project);
projectColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.PROJECT));
locationColumn = new TreeColumn(getTree(), SWT.NONE);
locationColumn.setWidth(100);
locationColumn.setText("Location");
locationColumn.setText(Messages.ExecutablesViewer_Location);
locationColumn.setMoveable(true);
locationColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.LOCATION));
sizeColumn = new TreeColumn(getTree(), SWT.NONE);
sizeColumn.setWidth(100);
sizeColumn.setText("Size");
sizeColumn.setText(Messages.ExecutablesViewer_Size);
sizeColumn.setMoveable(true);
sizeColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.SIZE));
modifiedColumn = new TreeColumn(getTree(), SWT.NONE);
modifiedColumn.setWidth(100);
modifiedColumn.setText("Modified");
modifiedColumn.setText(Messages.ExecutablesViewer_Modified);
modifiedColumn.setMoveable(true);
modifiedColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.MODIFIED));
typeColumn = new TreeColumn(getTree(), SWT.NONE);
typeColumn.setWidth(100);
typeColumn.setText("Type");
typeColumn.setText(Messages.ExecutablesViewer_Type);
typeColumn.setMoveable(true);
typeColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.TYPE));
@ -216,7 +216,7 @@ public class ExecutablesViewer extends BaseViewer implements IExecutablesChangeL
protected ViewerComparator getViewerComparator(int sortType) {
if (sortType == ExecutablesView.PROJECT) {
return new ExecutablesViewerComparator(sortType, column_order[ExecutablesView.PROJECT]) {
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") //$NON-NLS-1$
public int compare(Viewer viewer, Object e1, Object e2) {
Executable entry1 = (Executable) e1;
Executable entry2 = (Executable) e2;
@ -236,7 +236,7 @@ public class ExecutablesViewer extends BaseViewer implements IExecutablesChangeL
public void executablesChanged(IExecutablesChangeEvent event) {
// Executables have changed so refresh the view.
final ExecutablesViewer viewer = this;
UIJob refreshJob = new UIJob("Refresh Executables View") {
UIJob refreshJob = new UIJob(Messages.ExecutablesViewer_RefreshExecutablesView) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {

View file

@ -36,7 +36,7 @@ class ExecutablesViewerComparator extends ViewerComparator {
return 0;
}
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") //$NON-NLS-1$
public int compare(Viewer viewer, Object e1, Object e2) {
if (category(e1) == 1 && category(e2) == 1) {
@ -64,9 +64,9 @@ class ExecutablesViewerComparator extends ViewerComparator {
if (sortType == ExecutablesView.TYPE) {
String ext1 = getPath(e1).getFileExtension();
String s1 = ext1 != null ? ext1.toUpperCase() : "";
String s1 = ext1 != null ? ext1.toUpperCase() : ""; //$NON-NLS-1$
String ext2 = getPath(e2).getFileExtension();
String s2 = ext2 != null ? ext2.toUpperCase() : "";
String s2 = ext2 != null ? ext2.toUpperCase() : ""; //$NON-NLS-1$
return getComparator().compare(s1, s2) * columnOrder;
}
}

View file

@ -0,0 +1,52 @@
package org.eclipse.cdt.debug.internal.ui.views.executables;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.executables.messages"; //$NON-NLS-1$
public static String ExecutablesContentProvider_FetchingExecutables;
public static String ExecutablesView_Columns;
public static String ExecutablesView_ConfigureColumns;
public static String ExecutablesView_DefaultColumns;
public static String ExecutablesView_ExeData;
public static String ExecutablesView_ExeLocation;
public static String ExecutablesView_ExeName;
public static String ExecutablesView_ExeProject;
public static String ExecutablesView_ExeSize;
public static String ExecutablesView_ExeType;
public static String ExecutablesView_Import;
public static String ExecutablesView_ImportExe;
public static String ExecutablesView_ImportExecutables;
public static String ExecutablesView_Refresh;
public static String ExecutablesView_RefreshList;
public static String ExecutablesView_SelectColumns;
public static String ExecutablesView_SelectExeFile;
public static String ExecutablesView_SrcDate;
public static String ExecutablesView_SrcLocation;
public static String ExecutablesView_SrcName;
public static String ExecutablesView_SrcOrgLocation;
public static String ExecutablesView_SrcSize;
public static String ExecutablesView_SrcType;
public static String ExecutablesViewer_ExecutableName;
public static String ExecutablesViewer_Location;
public static String ExecutablesViewer_Modified;
public static String ExecutablesViewer_Project;
public static String ExecutablesViewer_RefreshExecutablesView;
public static String ExecutablesViewer_Size;
public static String ExecutablesViewer_Type;
public static String SourceFilesContentProvider_NoFilesFound;
public static String SourceFilesViewer_RefreshSourceFiles;
public static String SourceFilesViewer_Location;
public static String SourceFilesViewer_Modified;
public static String SourceFilesViewer_Original;
public static String SourceFilesViewer_Size;
public static String SourceFilesViewer_SourceFileName;
public static String SourceFilesViewer_Type;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -37,7 +37,7 @@ public class SourceFilesContentProvider extends CElementContentProvider {
Executable executable = (Executable) inputElement;
ITranslationUnit[] sourceFiles = executable.getSourceFiles();
if (sourceFiles.length == 0)
return new String[] { "No source files found in " + executable.getName() };
return new String[] { Messages.SourceFilesContentProvider_NoFilesFound + executable.getName() };
else
return sourceFiles;
}

View file

@ -126,37 +126,37 @@ public class SourceFilesViewer extends BaseViewer implements ISourceLookupPartic
private void createColumns() {
nameColumn = new TreeColumn(sourceFilesTree, SWT.NONE);
nameColumn.setWidth(100);
nameColumn.setText("Source File Name");
nameColumn.setText(Messages.SourceFilesViewer_SourceFileName);
nameColumn.setMoveable(true);
nameColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.NAME));
locationColumn = new TreeColumn(sourceFilesTree, SWT.NONE);
locationColumn.setWidth(100);
locationColumn.setText("Location");
locationColumn.setText(Messages.SourceFilesViewer_Location);
locationColumn.setMoveable(true);
locationColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.LOCATION));
originalLocationColumn = new TreeColumn(sourceFilesTree, SWT.NONE);
originalLocationColumn.setWidth(100);
originalLocationColumn.setText("Original");
originalLocationColumn.setText(Messages.SourceFilesViewer_Original);
originalLocationColumn.setMoveable(true);
originalLocationColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.ORG_LOCATION));
sizeColumn = new TreeColumn(sourceFilesTree, SWT.NONE);
sizeColumn.setWidth(100);
sizeColumn.setText("Size");
sizeColumn.setText(Messages.SourceFilesViewer_Size);
sizeColumn.setMoveable(true);
sizeColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.SIZE));
modifiedColumn = new TreeColumn(sourceFilesTree, SWT.NONE);
modifiedColumn.setWidth(100);
modifiedColumn.setText("Modified");
modifiedColumn.setText(Messages.SourceFilesViewer_Modified);
modifiedColumn.setMoveable(true);
modifiedColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.MODIFIED));
typeColumn = new TreeColumn(sourceFilesTree, SWT.NONE);
typeColumn.setWidth(100);
typeColumn.setText("Type");
typeColumn.setText(Messages.SourceFilesViewer_Type);
typeColumn.setMoveable(true);
typeColumn.addSelectionListener(new ColumnSelectionAdapter(ExecutablesView.TYPE));
}
@ -165,7 +165,7 @@ public class SourceFilesViewer extends BaseViewer implements ISourceLookupPartic
if (sortType == ExecutablesView.ORG_LOCATION) {
return new ExecutablesViewerComparator(sortType, column_order[ExecutablesView.ORG_LOCATION]) {
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") //$NON-NLS-1$
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 instanceof ITranslationUnit && e2 instanceof ITranslationUnit) {
ITranslationUnit entry1 = (ITranslationUnit) e1;
@ -252,14 +252,14 @@ public class SourceFilesViewer extends BaseViewer implements ISourceLookupPartic
}
public String getSourceName(Object object) throws CoreException {
return "";
return ""; //$NON-NLS-1$
}
public void init(ISourceLookupDirector director) {
}
public void sourceContainersChanged(ISourceLookupDirector director) {
UIJob refreshJob = new UIJob("Refresh Source Files") {
UIJob refreshJob = new UIJob(Messages.SourceFilesViewer_RefreshSourceFiles) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {

View file

@ -0,0 +1,38 @@
ExecutablesContentProvider_FetchingExecutables=Fetching executables
ExecutablesView_Columns=Columns
ExecutablesView_ConfigureColumns=Configure Columns
ExecutablesView_DefaultColumns=Executable Name,Executable Project,Executable Location,Source File Name,Source File Location
ExecutablesView_ExeData=Executable Date
ExecutablesView_ExeLocation=Executable Location
ExecutablesView_ExeName=Executable Name
ExecutablesView_ExeProject=Executable Project
ExecutablesView_ExeSize=Executable Size
ExecutablesView_ExeType=Executable Type
ExecutablesView_Import=Import
ExecutablesView_ImportExe=Import an executable file
ExecutablesView_ImportExecutables=Import Executables
ExecutablesView_Refresh=Refresh
ExecutablesView_RefreshList=Refresh the list of executables
ExecutablesView_SelectColumns=Select the columns to show
ExecutablesView_SelectExeFile=Select an executable file
ExecutablesView_SrcDate=Source File Date
ExecutablesView_SrcLocation=Source File Location
ExecutablesView_SrcName=Source File Name
ExecutablesView_SrcOrgLocation=Source File Original Location
ExecutablesView_SrcSize=Source File Size
ExecutablesView_SrcType=Source File Type
ExecutablesViewer_ExecutableName=Executable Name
ExecutablesViewer_Location=Location
ExecutablesViewer_Modified=Modified
ExecutablesViewer_Project=Project
ExecutablesViewer_RefreshExecutablesView=Refresh Executables View
ExecutablesViewer_Size=Size
ExecutablesViewer_Type=Type
SourceFilesContentProvider_NoFilesFound=No source files found in
SourceFilesViewer_RefreshSourceFiles=Refresh Source Files
SourceFilesViewer_Location=Location
SourceFilesViewer_Modified=Modified
SourceFilesViewer_Original=Original
SourceFilesViewer_Size=Size
SourceFilesViewer_SourceFileName=Source File Name
SourceFilesViewer_Type=Type