Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2010-04-29 16:34:18 +0000
committerAlena Laskavaia2010-04-29 16:34:18 +0000
commit8ece4ead1a6fd27bfb1f2b4bdfa7fd2528fc022b (patch)
tree9e13a98309fcc65c9682609cc1e4b323a380fc20 /codan/org.eclipse.cdt.codan.ui
parent4fd94ed31f828a06a579ebfa19b152dcbc35dddf (diff)
downloadorg.eclipse.cdt-8ece4ead1a6fd27bfb1f2b4bdfa7fd2528fc022b.tar.gz
org.eclipse.cdt-8ece4ead1a6fd27bfb1f2b4bdfa7fd2528fc022b.tar.xz
org.eclipse.cdt-8ece4ead1a6fd27bfb1f2b4bdfa7fd2528fc022b.zip
- simplified API for problem details extensions
Diffstat (limited to 'codan/org.eclipse.cdt.codan.ui')
-rw-r--r--codan/org.eclipse.cdt.codan.ui/plugin.xml10
-rw-r--r--codan/org.eclipse.cdt.codan.ui/schema/codanProblemDetails.exsd11
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/GenericCodanProblemDetailsProvider.java36
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java150
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java43
5 files changed, 125 insertions, 125 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui/plugin.xml b/codan/org.eclipse.cdt.codan.ui/plugin.xml
index df5c37f82a4..2bb9831fd29 100644
--- a/codan/org.eclipse.cdt.codan.ui/plugin.xml
+++ b/codan/org.eclipse.cdt.codan.ui/plugin.xml
@@ -91,4 +91,14 @@
</key>
</extension>
-->
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.cdt.ui.CPerspective">
+
+ <showInPart id="org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"/>
+
+ <viewShortcut id="org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"/>
+ </perspectiveExtension>
+ </extension>
</plugin>
diff --git a/codan/org.eclipse.cdt.codan.ui/schema/codanProblemDetails.exsd b/codan/org.eclipse.cdt.codan.ui/schema/codanProblemDetails.exsd
index 1c998848138..87f6b9478f5 100644
--- a/codan/org.eclipse.cdt.codan.ui/schema/codanProblemDetails.exsd
+++ b/codan/org.eclipse.cdt.codan.ui/schema/codanProblemDetails.exsd
@@ -94,7 +94,13 @@ If ommitted provider would be called for all problem kinds.
<meta.section type="examples"/>
</appinfo>
<documentation>
- [Enter extension point usage example here.]
+ &lt;extension
+ point=&quot;org.eclipse.cdt.codan.ui.codanProblemDetails&quot;&gt;
+ &lt;problemDetails
+ class=&quot;org.eclipse.cdt.codan.examples.uicontrib.FlexlintHelpLink&quot;
+ &gt;
+ &lt;/problemDetails&gt;
+ &lt;/extension&gt;
</documentation>
</annotation>
@@ -112,7 +118,8 @@ If ommitted provider would be called for all problem kinds.
<meta.section type="implementation"/>
</appinfo>
<documentation>
- [Enter information about supplied implementation of this extension point.]
+ See
+org.eclipse.cdt.codan.examples.uicontrib.FlexlintHelpLink
</documentation>
</annotation>
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/GenericCodanProblemDetailsProvider.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/GenericCodanProblemDetailsProvider.java
new file mode 100644
index 00000000000..9e3d0d19025
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/GenericCodanProblemDetailsProvider.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * $QNXLicenseC:
+ * Copyright 2008, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software. Free development
+ * licenses are available for evaluation and non-commercial purposes. For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others. Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ *******************************************************************************/
+
+
+/*
+ * Created by: Elena Laskavaia
+ * Created on: 2010-04-29
+ * Last modified by: $Author$
+ */
+package org.eclipse.cdt.codan.internal.ui.views;
+
+import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
+
+/**
+ * This provides details for errors that do not have own details provider
+ */
+public class GenericCodanProblemDetailsProvider extends AbstractCodanProblemDetailsProvider {
+ @Override
+ public boolean isApplicable(String id) {
+ return true;
+ }
+}
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java
index 55c63219a04..5440117f14a 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java
@@ -1,18 +1,10 @@
package org.eclipse.cdt.codan.internal.ui.views;
-import java.net.URL;
import java.util.Collection;
import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.Action;
-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.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
@@ -21,29 +13,31 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
+/**
+ * Problems Details view show details for selected problem marker.
+ * Other plugins can contribute to override default behavior using codanProblemDetails extension point.
+ */
public class ProblemDetails extends ViewPart {
/**
* The ID of the view as specified by the extension.
*/
public static final String ID = "org.eclipse.cdt.codan.internal.ui.views.ProblemDetails";
private Composite area;
- private Action action1;
-
- private Label description;
- private Label location;
- private Link helpLabel;
+ /**
+ * Control for problem message, which can include location
+ */
+ private Link message;
+ /**
+ * Control for problem description which can include links to help or web-sites with extra info
+ */
+ private Link description;
+ private GenericCodanProblemDetailsProvider genProvider = new GenericCodanProblemDetailsProvider();
/**
* The constructor.
@@ -56,37 +50,43 @@ public class ProblemDetails extends ViewPart {
* to create the area and initialize it.
*/
public void createPartControl(Composite parent) {
- final String processViewId = "org.eclipse.ui.views.ProblemView";
+ final String problemsViewId = "org.eclipse.ui.views.ProblemView";
area = new Composite(parent, SWT.NONE);
area.setLayout(new GridLayout());
- description = new Label(area, SWT.WRAP);
- description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- location = new Label(area, SWT.WRAP);
- helpLabel = new Link(area, SWT.WRAP);
- helpLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- helpLabel.addSelectionListener(new SelectionAdapter() {
+ SelectionAdapter linkSelAdapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String link = e.text;
- if (link != null && link.startsWith("http")) {
+ if (link==null) return;
+ if (link.startsWith("http")) {
org.eclipse.swt.program.Program.launch(e.text);
+ return;
+ }
+ if (link.startsWith("file:")) {
+ // open in eclipse editor TODO
+ return;
+ }
+ if (link.startsWith("help:")) {
+ // open in eclipse help TODO
+ return;
}
}
- });
- // Create the help context id for the area's control
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(area, "org.eclipse.cdt.codan.ui.viewer");
- makeActions();
- hookContextMenu();
- contributeToActionBars();
+ };
+ message = new Link(area, SWT.WRAP);
+ message.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ message.addSelectionListener(linkSelAdapter);
+ description = new Link(area, SWT.WRAP);
+ description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ description.addSelectionListener(linkSelAdapter);
ISelectionService ser = (ISelectionService) getSite().getService(ISelectionService.class);
ser.addSelectionListener(new ISelectionListener() {
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (part.getSite().getId().equals(processViewId)) {
+ if (part.getSite().getId().equals(problemsViewId)) {
processSelection(selection);
}
}
});
- ISelection selection = ser.getSelection(processViewId);
+ ISelection selection = ser.getSelection(problemsViewId);
processSelection(selection);
}
@@ -102,11 +102,6 @@ public class ProblemDetails extends ViewPart {
marker = (IMarker) firstElement;
}
if (marker != null) {
- String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
- description.setText(message);
- String loc = marker.getResource().getFullPath().toOSString(); //$NON-NLS-1$
- int line = marker.getAttribute(IMarker.LINE_NUMBER, 0);
- location.setText(loc + ":" + line); //$NON-NLS-1$
queryProviders(marker);
area.layout();
}
@@ -114,7 +109,6 @@ public class ProblemDetails extends ViewPart {
}
private void queryProviders(IMarker marker) {
- cleanProversControl();
String id = marker.getAttribute(IMarker.PROBLEM, "id"); //$NON-NLS-1$
Collection<AbstractCodanProblemDetailsProvider> providers = ProblemDetailsExtensions.getProviders(id);
for (AbstractCodanProblemDetailsProvider provider : providers) {
@@ -122,76 +116,26 @@ public class ProblemDetails extends ViewPart {
provider.setMarker(marker);
if (provider.isApplicable(id)) {
applyProvider(provider);
- break;
+ return;
}
}
}
- }
-
- public void cleanProversControl() {
- helpLabel.setText("");
+ genProvider.setMarker(marker);
+ applyProvider(genProvider);
}
private void applyProvider(AbstractCodanProblemDetailsProvider provider) {
- String label = provider.getHelpLabel();
- final URL url = provider.getHelpURL();
- if (label != null) {
- helpLabel.setText(label);
- }
- if (url != null) {
- if (label == null) {
- label = url.toString();
- }
- helpLabel.setText("<a href=\"" + url + "\">" + label + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- private void hookContextMenu() {
- MenuManager menuMgr = new MenuManager("#PopupMenu");
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- ProblemDetails.this.fillContextMenu(manager);
- }
- });
- Menu menu = menuMgr.createContextMenu(area);
- area.setMenu(menu);
- //getSite().registerContextMenu(menuMgr, area);
- }
-
- private void contributeToActionBars() {
- IActionBars bars = getViewSite().getActionBars();
- fillLocalPullDown(bars.getMenuManager());
- fillLocalToolBar(bars.getToolBarManager());
- }
-
- private void fillLocalPullDown(IMenuManager manager) {
-
- }
-
- private void fillContextMenu(IMenuManager manager) {
- // Other plug-ins can contribute there actions here
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ setTextSafe(message, provider, provider.getStyledProblemMessage());
+ setTextSafe(description, provider, provider.getStyledProblemDescription());
}
- private void fillLocalToolBar(IToolBarManager manager) {
-
- }
-
- private void makeActions() {
- action1 = new Action() {
- public void run() {
- showMessage("Action 1 executed");
- }
- };
- action1.setText("Action 1");
- action1.setToolTipText("Action 1 tooltip");
- action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
-
- }
-
- private void showMessage(String message) {
- MessageDialog.openInformation(area.getShell(), "Problem Details", message);
+ protected void setTextSafe(Link control, AbstractCodanProblemDetailsProvider provider, String text) {
+ try {
+ control.setText(text);
+ } catch (Exception e) {
+ // this is more debug message
+ control.setText("failed to set text: " + provider.getClass() + " " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
/**
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java
index 4c063ca4fc0..ad21ac1f655 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java
@@ -17,12 +17,12 @@
/*
* Created by: Elena Laskavaia
* Created on: 2010-04-28
- * Last modified by: $Author$
+ * Last modified by: $Author: elaskavaia $
*/
package org.eclipse.cdt.codan.ui;
-import java.net.URL;
-
+import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.core.resources.IMarker;
/**
@@ -49,7 +49,10 @@ public abstract class AbstractCodanProblemDetailsProvider {
String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
return message;
}
-
+ protected String getProblemId(){
+ String id = marker.getAttribute(IMarker.PROBLEM, (String)null); //$NON-NLS-1$
+ return id;
+ }
/**
* return true if provider can provide details for given marker (previously set by setMarker)
* @param id - id of the problem
@@ -58,26 +61,26 @@ public abstract class AbstractCodanProblemDetailsProvider {
public abstract boolean isApplicable(String id);
/**
- * URL to external help for the problem, would be displayed as label, and as action
- * will go to given URL is not null. If label is null (getHelpLabel) URL would be used as label.
+ * Return styled problem message. String can include <a> tags to which would be
+ * visible as hyperlinks and newline characters (\n). Default message if
+ * marker message plus location.
*/
- public URL getHelpURL() {
- return null;
+ public String getStyledProblemMessage(){
+ String message = getProblemMessage();
+ String loc = marker.getResource().getFullPath().toOSString();
+ int line = marker.getAttribute(IMarker.LINE_NUMBER, 0);
+ return message + "\n"+loc+":"+line; //$NON-NLS-1$//$NON-NLS-2$
}
-
+
/**
- * Label text to use to navigate to a help. Would be shown as hyperlink. If helpURL is not
- * null would open a browser with given URL.
+ * Return styled problem description. String can include <a> tags to which would be
+ * visible as hyperlinks and newline characters (\n)
*/
- public String getHelpLabel() {
- return null;
+ public String getStyledProblemDescription(){
+ String id = getProblemId();
+ if (id==null) return ""; //$NON-NLS-1$
+ IProblem problem = CodanRuntime.getInstance().getChechersRegistry().getDefaultProfile().findProblem(id);
+ return problem.getDescription();
}
- /**
- * Return help context id. Only one getHelpURL or getHelpContextId can be used.
- * In case if help context id is not null hyperlink would open context help page.
- */
- public String getHelpContextId() {
- return null;
- }
}

Back to the top