Skip to content

Commit

Permalink
string externalization and added action to view
Browse files Browse the repository at this point in the history
  • Loading branch information
alirana01 committed Sep 13, 2023
1 parent 3519ab9 commit 931da92
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
Expand Down Expand Up @@ -54,7 +53,6 @@
import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.core.util.GcovUtility;
import com.espressif.idf.core.util.IDFUtil;
import com.espressif.idf.core.util.StringUtil;

/**
* Gcov file view that can be opened by right clicking on the project. It is used to show the gcno/gcda files as one
Expand Down Expand Up @@ -116,22 +114,24 @@ public void handleEvent(Event event)

// Create Toolbar and Buttons
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
Action refreshAction = new Action("Refresh")
Action refreshAction = new Action(Messages.GcovFileView_Refresh_Button)
{
public void run()
{
refreshList();
}
};
Action selectProjectAction = new Action("Select Project")
Action selectProjectAction = new Action(Messages.GcovFileView_SelectProject_Button)
{
public void run()
{
openProjectSelectionDialog();
refreshList();
}
};

mgr.add(refreshAction);
mgr.add(selectProjectAction);

// Initial population of the list
refreshList();
Expand All @@ -149,7 +149,7 @@ public void selectionChanged(IWorkbenchPart part, ISelection selection)
setSelectedProject((IProject) obj);
}
}

private void openProjectSelectionDialog()
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Expand All @@ -168,7 +168,8 @@ private void openProjectSelectionDialog()
setSelectedProject((IProject) dialog.getFirstResult());
}

private void createTableItem(Image image, String fileName, String filePath, String gcnoDate, String gcdaDate, String gcnoSize, String gcdaSize, Object data)
private void createTableItem(Image image, String fileName, String filePath, String gcnoDate, String gcdaDate,
String gcnoSize, String gcdaSize, Object data)
{
int index = 0;
TableItem item = new TableItem(table, SWT.NONE);
Expand All @@ -179,7 +180,7 @@ private void createTableItem(Image image, String fileName, String filePath, Stri
item.setText(index++, gcdaDate);
item.setText(index++, gcnoSize);
item.setText(index++, gcdaSize);

item.setData(data);
}

Expand All @@ -195,7 +196,7 @@ private String getFileSize(java.nio.file.Path path)
return Messages.Table_Unknown;
}
}

private void verifyProjectSelection()
{
if (getSelectedProject() == null)
Expand Down Expand Up @@ -228,7 +229,7 @@ private void verifyProjectSelection()
}
}
}

private void refreshList()
{
for (TableItem item : table.getItems())
Expand All @@ -251,7 +252,7 @@ public boolean visit(IResource resource)
if (resource instanceof IFile)
{
IFile file = (IFile) resource;
if ("gcno".equals(file.getFileExtension()))
if ("gcno".equals(file.getFileExtension())) //$NON-NLS-1$
{
String parentDir = file.getParent().getRawLocation().toString();
String partnerFile = parentDir + "/" //$NON-NLS-1$
Expand All @@ -270,11 +271,13 @@ public boolean visit(IResource resource)
.fetchInfo();
String dateGcda = DateFormat.getDateTimeInstance()
.format(new Date(fileInfo.getLastModified()));

String gcnoSize = getFileSize(Paths.get(file.getRawLocationURI()));
String gcdaSize = getFileSize(Paths.get(partnerFile));

createTableItem(image, file.getName().substring(0, file.getName().indexOf(".gcno")), file.getParent().getFullPath().toString(), dateGcno, dateGcda, gcnoSize, gcdaSize, file);
createTableItem(image, file.getName().substring(0, file.getName().indexOf(".gcno")), //$NON-NLS-1$
file.getParent().getFullPath().toString(), dateGcno, dateGcda, gcnoSize,
gcdaSize, file);
}
}
}
Expand Down Expand Up @@ -379,8 +382,7 @@ public int compare(TableItem item1, TableItem item2)
// Repopulate the table
populateTable(copiedData);
}



private List<TableRowData> createTableDataCopy(TableItem[] items)
{
List<TableRowData> copiedData = new ArrayList<>();
Expand All @@ -396,10 +398,10 @@ private List<TableRowData> createTableDataCopy(TableItem[] items)
rowData.itemData = item.getData();
copiedData.add(rowData);
}

return copiedData;
}

private void populateTable(List<TableRowData> tableRowData)
{
for (TableRowData rowData : tableRowData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Messages extends NLS
public static String TableCol_SizeGCDA;
public static String Dialog_SelectProject_Title;
public static String Table_Unknown;
public static String GcovFileView_Refresh_Button;
public static String GcovFileView_SelectProject_Button;

static
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ TableCol_SizeGCNO=Size GCNO
TableCol_SizeGCDA=Size GCDA
Dialog_SelectProject_Title=Select a Project
Table_Unknown=Unknown
GcovFileView_Refresh_Button=Refresh
GcovFileView_SelectProject_Button=Select Project

0 comments on commit 931da92

Please sign in to comment.