Skip to content

Commit

Permalink
Exported strings to the messages file for dynamic language
Browse files Browse the repository at this point in the history
  • Loading branch information
alirana01 committed Sep 7, 2023
1 parent 530ad63 commit 0e4a3ca
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.Collator;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
Expand Down Expand Up @@ -55,9 +55,9 @@
import com.espressif.idf.core.util.IDFUtil;

/**
* Gcov file view that can be opened by right clicking on the project.
* It is used to show the gcno/gcda files as one unit for the selected project
* User can launch the eclipse's default gcov viewer by double clicking on the entries
* Gcov file view that can be opened by right clicking on the project. It is used to show the gcno/gcda files as one
* unit for the selected project User can launch the eclipse's default gcov viewer by double clicking on the entries
*
* @author Ali Azam Rana
*
*/
Expand All @@ -76,7 +76,8 @@ public void createPartControl(Composite parent)
table.setLinesVisible(true);
table.setHeaderVisible(true);

String[] titles = { "File Name", "Path", "Last Modified GCNO", "Last Modified GCDA", "Size GCNO", "Size GCDA" };
String[] titles = { Messages.TableCol_FileName, Messages.TableCol_Path, Messages.TableCol_LastModifiedGCNO,
Messages.TableCol_LastModifiedGCDA, Messages.TableCol_SizeGCNO, Messages.TableCol_SizeGCDA };
for (int i = 0; i < titles.length; i++)
{
TableColumn column = new TableColumn(table, SWT.NONE);
Expand All @@ -93,7 +94,7 @@ public void handleEvent(Event event)
Point pt = new Point(event.x, event.y);
TableItem item = table.getItem(pt);
IFile file = (IFile) item.getData();

if (item != null && file != null)
{
try
Expand Down Expand Up @@ -150,7 +151,7 @@ private void refreshList()
ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getSelectionService();
IStructuredSelection structuredSelection = (IStructuredSelection) selectionService
.getSelection("org.eclipse.ui.navigator.ProjectExplorer");
.getSelection("org.eclipse.ui.navigator.ProjectExplorer"); //$NON-NLS-1$

if (structuredSelection != null && !structuredSelection.isEmpty())
{
Expand All @@ -166,7 +167,7 @@ private void refreshList()
{
setSelectedProject(GcovUtility.getSelectedProject());
}

// If no project is selected, ask the user to choose one
if (getSelectedProject() == null)
{
Expand All @@ -175,7 +176,7 @@ private void refreshList()
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
new org.eclipse.ui.model.WorkbenchLabelProvider());
dialog.setElements(root.getProjects());
dialog.setTitle("Select a Project");
dialog.setTitle(Messages.Dialog_SelectProject_Title);

// only continue if the user pressed "OK"
if (dialog.open() != Window.OK)
Expand Down Expand Up @@ -203,49 +204,48 @@ public boolean visit(IResource resource)
if ("gcno".equals(file.getFileExtension()))
{
String parentDir = file.getParent().getRawLocation().toString();
String partnerFile = parentDir + "/"
+ file.getName().substring(0, file.getName().indexOf(".gcno")) + ".gcda";
String partnerFile = parentDir + "/" //$NON-NLS-1$
+ file.getName().substring(0, file.getName().indexOf(".gcno")) + ".gcda"; //$NON-NLS-1$ //$NON-NLS-2$
if (Files.exists(Paths.get(partnerFile)))
{
TableItem item = new TableItem(table, SWT.NONE);
Image image = PlatformUI.getWorkbench().getEditorRegistry()
.getImageDescriptor(file.getName()).createImage();
item.setImage(0, image);
item.setText(0, file.getName().substring(0, file.getName().indexOf(".gcno")));
item.setText(0, file.getName().substring(0, file.getName().indexOf(".gcno"))); //$NON-NLS-1$
item.setText(1, file.getParent().getFullPath().toString());

// gcno
IFileInfo fileInfo = EFS.getLocalFileSystem().getStore(file.getLocationURI())
.fetchInfo();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String date = sdf.format(new Date(fileInfo.getLastModified()));
String date = DateFormat.getDateTimeInstance().format(new Date(fileInfo.getLastModified()));
item.setText(2, date);

// gcda
fileInfo = EFS.getLocalFileSystem().getStore(Path.fromOSString(partnerFile))
.fetchInfo();
item.setText(3, sdf.format(new Date(fileInfo.getLastModified())));
item.setText(3, DateFormat.getDateTimeInstance().format(new Date(fileInfo.getLastModified())));

java.nio.file.Path path = Paths.get(file.getRawLocationURI());
try
{
long size = Files.size(path);
item.setText(4, String.valueOf(size) + " bytes");
item.setText(4, String.valueOf(size) + " bytes"); //$NON-NLS-1$
}
catch (Exception e)
{
item.setText(4, "Unknown");
item.setText(4, Messages.Table_Unknown);
}

path = Paths.get(partnerFile);
try
{
long size = Files.size(path);
item.setText(5, String.valueOf(size) + " bytes");
item.setText(5, String.valueOf(size) + " bytes"); //$NON-NLS-1$
}
catch (Exception e)
{
item.setText(5, "Unknown");
item.setText(5, Messages.Table_Unknown);
}

item.setData(file);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright 2023 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.ui.gcov;

import org.eclipse.osgi.util.NLS;

public class Messages extends NLS
{
private static final String BUNDLE_NAME = "com.espressif.idf.ui.gcov.messages"; //$NON-NLS-1$

public static String TableCol_FileName;
public static String TableCol_Path;
public static String TableCol_LastModifiedGCNO;
public static String TableCol_LastModifiedGCDA;
public static String TableCol_SizeGCNO;
public static String TableCol_SizeGCDA;
public static String Dialog_SelectProject_Title;
public static String Table_Unknown;

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,8 @@
TableCol_FileName=File Name
TableCol_Path=Path
TableCol_LastModifiedGCNO=Last Modified GCNO
TableCol_LastModifiedGCDA=Last Modified GCDA
TableCol_SizeGCNO=Size GCNO
TableCol_SizeGCDA=Size GCDA
Dialog_SelectProject_Title=Select a Project
Table_Unknown=Unknown

0 comments on commit 0e4a3ca

Please sign in to comment.