Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add project label to report view header #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -3,39 +3,51 @@
import java.util.HashMap;
import java.util.LinkedList;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Auto import reorganization.

import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.part.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.*;
import org.eclipse.ui.ide.IDE;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;

import com.google.common.base.Optional;


import org.codechecker.eclipse.plugin.report.BugPathItem;
import org.codechecker.eclipse.plugin.report.SearchList;
import org.codechecker.eclipse.plugin.Logger;
import org.codechecker.eclipse.plugin.config.CodeCheckerContext;
import org.codechecker.eclipse.plugin.config.filter.Filter;
import org.codechecker.eclipse.plugin.config.filter.FilterConfiguration;
import org.codechecker.eclipse.plugin.report.BugPathItem;
import org.codechecker.eclipse.plugin.report.SearchList;
import org.codechecker.eclipse.plugin.views.report.list.action.NewInstanceAction;
import org.codechecker.eclipse.plugin.views.report.list.action.ShowFilterConfigurationDialog;
import org.codechecker.eclipse.plugin.views.report.list.action.showas.CheckerGroupAction;
import org.codechecker.eclipse.plugin.views.report.list.action.showas.CheckerTreeAction;
import org.codechecker.eclipse.plugin.views.report.list.provider.content.TreeCheckerContentProvider;
import org.codechecker.eclipse.plugin.views.report.list.provider.label.BasicViewLabelProvider;
import org.codechecker.eclipse.plugin.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.ViewPart;

import com.google.common.base.Optional;

public class ReportListView extends ViewPart {

Expand All @@ -48,17 +60,20 @@ public class ReportListView extends ViewPart {
private String currentFilename;
private IProject currentProject;
private ShowFilterConfigurationDialog showfilterconfigurationdialog;

private Label message;
private Composite client;
public ReportListView() {
}

public void createPartControl(Composite parent) {

this.parent = parent;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a client area to place widgets to. There is a new message Label to display the project name

parent.setLayout(new GridLayout(1, true));
client = new Composite(parent, parent.getStyle());
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(client);
message = new Label(client, SWT.FLAT);

viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer = new TreeViewer(client, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new TreeCheckerContentProvider(this));
viewer.setLabelProvider(new BasicViewLabelProvider(this));
viewer.setInput(new EmptyModel());
Expand All @@ -78,7 +93,7 @@ public void createPartControl(Composite parent) {
hookDoubleClickAction();
contributeToActionBars();

parent.pack();
client.pack();
}

private void hookContextMenu() {
Expand Down Expand Up @@ -240,6 +255,7 @@ public void clearModel() {
}

public void refresh(Object parent) {
client.layout();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will trigger the invalidation.

viewer.refresh();
}

Expand Down Expand Up @@ -276,6 +292,7 @@ private void reloadReports(String currentFileName) {
//Optional<Long> runId = Optional.absent();

CodeCheckerContext.getInstance().runReportJob(this, currentFileName);
refresh(parent);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This had to be added, otherwise the label wouldn't display correctly.

}

/**
Expand All @@ -285,6 +302,8 @@ public void onEditorChanged(IProject project, String filename) {
Logger.log(IStatus.INFO, "OnEditorchanged:"+project.getName());
if (project != currentProject) {
this.currentProject = project;
message.setText(new StringBuilder().append("Showing reports for: ").append(currentProject.getName())
.append(" project.").toString());
//CodeCheckerContext.getInstance().runRunListJob(this);
}
if (!getViewerRefresh()) {
Expand Down Expand Up @@ -322,5 +341,4 @@ public void setViewerRefresh(boolean viewerRefresh) {

static class EmptyModel {
}

}