Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,5 @@ protected void refreshPanel() {
componentDetailsPanel.pack();
}

protected abstract void createBrowserJCEF(Composite parent);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package com.jfrog.ide.eclipse.ui.issues;

import java.nio.file.Paths;

import org.eclipse.swt.widgets.Composite;

import com.jfrog.ide.common.nodes.FileIssueNode;
import com.jfrog.ide.common.nodes.ScaIssueNode;
import com.jfrog.ide.common.parse.Applicability;
import com.jfrog.ide.eclipse.log.Logger;
import com.jfrog.ide.eclipse.ui.ComponentDetails;
import com.jfrog.ide.eclipse.ui.webview.WebviewManager;

/**
* @author yahavi
* ComponentIssueDetails provides a detailed view of security issues using a webview.
* It uses WebviewManager to handle all webview operations and communication.
*/
public class ComponentIssueDetails extends ComponentDetails {

private static ComponentIssueDetails instance;
private static final Logger log = Logger.getInstance();

private WebviewManager webviewManager;

public static ComponentIssueDetails createComponentIssueDetails(Composite parent) {
instance = new ComponentIssueDetails(parent);
Expand All @@ -25,28 +31,80 @@ public static ComponentIssueDetails getInstance() {

private ComponentIssueDetails(Composite parent) {
super(parent, "Issue Details");
initializeWebviewManager();
}

@Override
public void createDetailsView(FileIssueNode node) {
createCommonInfo(node);
if (node instanceof ScaIssueNode ) {
ScaIssueNode scaNode = (ScaIssueNode) node;
Applicability applicability = scaNode.getApplicability();
addSection("Component Name:", scaNode.getComponentName());
addSection("Component Version:", scaNode.getComponentVersion());
addSection("Fixed Versions:", scaNode.getFixedVersions());
addSection("Applicability:", applicability != null ? applicability.getValue() : "");
} else {
addSection("Location:", "row: " + node.getRowStart() + " col: " + node.getColStart());
addSection("Reason:", node.getReason());
if (webviewManager == null || !webviewManager.isReady()) {
log.warn("WebviewManager not ready. Cannot display issue.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not ready means we're waiting for something - are we waiting? doing a retry after some time? otherwise - let's alter the message

return;
}

try {
webviewManager.displayIssue(node);
refreshPanel();
} catch (Exception e) {
log.error("Error creating details view: " + e.getMessage(), e);
}
refreshPanel();
}

@Override
protected void createBrowserJCEF(Composite parent) {
try {
if (webviewManager == null) {
log.error("WebviewManager not initialized");
return;
}

String webviewUrl = getWebviewUrl();
if (webviewUrl == null) {
log.error("Could not find webview resources");
return;
}

webviewManager.createBrowser(parent, webviewUrl);
log.debug("Webview browser created successfully");

} catch (Exception e) {
log.error("Error in createBrowserJCEF: " + e.getMessage(), e);
}
}

/**
* Initializes the WebviewManager with proper configuration.
*/
private void initializeWebviewManager() {
try {
webviewManager = new WebviewManager();
webviewManager.initialize();

log.debug("WebviewManager initialized successfully");

} catch (Exception e) {
log.error("Failed to initialize WebviewManager: " + e.getMessage(), e);
}
}

/**
* Gets the webview URL. This method can be customized to load from different sources.
*/
private String getWebviewUrl() {
return Paths.get(System.getProperty("user.dir"), "bundle", "src", "main", "resources", "jfrog-ide-webview", "index.html").toString();
}

public static void disposeComponentDetails() {
if (instance != null) {
instance.dispose();
}
}

@Override
public void dispose() {
if (webviewManager != null) {
webviewManager.dispose();
webviewManager = null;
}
super.dispose();
}
}
Loading
Loading