1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 23:15:24 +02:00

- added javadoc, externalized strings, fixed copyright

This commit is contained in:
Alena Laskavaia 2010-05-01 00:41:56 +00:00
parent ff3f6bc722
commit a54f3f21a7
16 changed files with 164 additions and 101 deletions

View file

@ -6,4 +6,6 @@ CodeAnalysisProperties.name = Code Analysis
CodeAnalysisPreferences.name = Code Analysis
CodeAnalysisPreferencesBuild.name = Launching
category.name = Code Analysis
command.name = Run Code Analysis
command.name = Run Code Analysis
view.name = Problem Details
extension-point.name = Codan Problem Details

View file

@ -76,10 +76,10 @@
class="org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"
icon="icons/problemDetails.gif"
id="org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"
name="Problem Details">
name="%view.name">
</view>
</extension>
<extension-point id="codanProblemDetails" name="Codan Problem Details" schema="schema/codanProblemDetails.exsd"/>
<extension-point id="codanProblemDetails" name="%extension-point.name" schema="schema/codanProblemDetails.exsd"/>
<!--
<extension
point="org.eclipse.ui.bindings">

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui;
import org.eclipse.cdt.codan.core.CodanCorePlugin;

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2009,2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui;
import org.eclipse.osgi.util.NLS;
/**
* UI Messages
*/
public class CodnaUIMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.internal.ui"; //$NON-NLS-1$
public static String CustomizeProblemComposite_TabParameters;
public static String CustomizeProblemComposite_TabScope;
public static String CustomizeProblemDialog_Message;
public static String CustomizeProblemDialog_Title;
public static String Job_TitleRunningAnalysis;
public static String ParametersComposite_None;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, CodnaUIMessages.class);
}
private CodnaUIMessages() {
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.codan.internal.ui.actions;
import java.util.Iterator;
import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.internal.ui.CodnaUIMessages;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@ -33,7 +34,7 @@ public class RunCodeAnalysis implements IObjectActionDelegate {
}
public void run(IAction action) {
Job job = new Job("Running Code Analysis") {
Job job = new Job(CodnaUIMessages.Job_TitleRunningAnalysis) {
@SuppressWarnings("unchecked")
@Override
protected IStatus run(final IProgressMonitor monitor) {

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.codan.internal.ui.actions;
import java.util.Iterator;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
@ -82,17 +83,16 @@ public class ToggleNatureAction implements IObjectActionDelegate {
}
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
CodanUIActivator.log(e);
}
return false;
}
/**
* Toggles sample nature on a project
* Toggles codan nature on a project
*
* @param project
* to have sample nature added or removed
* to have codan nature added or removed
*/
public void toggleNature(IProject project, boolean add) {
try {
@ -109,11 +109,10 @@ public class ToggleNatureAction implements IObjectActionDelegate {
description.setNatureIds(newNatures);
project.setDescription(description, null);
return;
} else {
// already there no need to add
add = false;
break;
}
// already there no need to add
add = false;
break;
}
}
if (add) {
@ -125,6 +124,7 @@ public class ToggleNatureAction implements IObjectActionDelegate {
project.setDescription(description, null);
}
} catch (CoreException e) {
CodanUIActivator.log(e);
}
}
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.codan.internal.ui.dialogs;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.internal.ui.CodnaUIMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -21,7 +22,7 @@ import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
/**
* @author Alena
* Composite for problem customisable parameters
*
*/
public class CustomizeProblemComposite extends Composite {
@ -55,7 +56,7 @@ public class CustomizeProblemComposite extends Composite {
*/
private void createParamtersTab(TabFolder tabFolder) {
TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
tabItem1.setText("Parameters");
tabItem1.setText(CodnaUIMessages.CustomizeProblemComposite_TabParameters);
parametersTab = new Composite(tabFolder, SWT.NONE);
tabItem1.setControl(parametersTab);
parametersTab.setLayout(new GridLayout());
@ -68,12 +69,12 @@ public class CustomizeProblemComposite extends Composite {
*/
private void createScopeTab(TabFolder tabFolder) {
TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
tabItem1.setText("Scope");
tabItem1.setText(CodnaUIMessages.CustomizeProblemComposite_TabScope);
Composite comp = new Composite(tabFolder, SWT.NONE);
tabItem1.setControl(comp);
comp.setLayout(new GridLayout());
Label label = new Label(comp, SWT.NONE);
label.setText("Scope: TODO");
label.setText("Scope: TODO"); //$NON-NLS-1$
label.setLayoutData(new GridData(GridData.FILL_BOTH));
}
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.codan.internal.ui.dialogs;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.internal.ui.CodnaUIMessages;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@ -50,9 +51,9 @@ public class CustomizeProblemDialog extends TitleAreaDialog {
*/
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText("Customize Problem...");
getShell().setText(CodnaUIMessages.CustomizeProblemDialog_Title);
setTitle(problem.getName());
setMessage("Edit problem parameters, scope and launch options");
setMessage(CodnaUIMessages.CustomizeProblemDialog_Message);
Composite area = (Composite) super.createDialogArea(parent);
comp = new CustomizeProblemComposite(area, problem);
GridData ld = new GridData(GridData.FILL_BOTH);

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.codan.internal.ui.dialogs;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.internal.ui.CodnaUIMessages;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
@ -74,7 +75,7 @@ public class ParametersComposite extends Composite {
IProblemParameterInfo info = problem.getParameterInfo();
if (info == null) {
Label label = new Label(this, 0);
label.setText("No Parameters");
label.setText(CodnaUIMessages.ParametersComposite_None);
}
initPrefStore(info);
page.setPreferenceStore(pref);

View file

@ -0,0 +1,6 @@
CustomizeProblemComposite_TabParameters=Parameters
CustomizeProblemComposite_TabScope=Scope
CustomizeProblemDialog_Message=Edit problem parameters, scope and launch options
CustomizeProblemDialog_Title=Customize Problem...
Job_TitleRunningAnalysis=Running Code Analysis
ParametersComposite_None=No Parameters

View file

@ -1,4 +1,4 @@
OverlayPage.Use_Workspace_Settings=Use &workspace settings
OverlayPage.Use_Project_Settings=Use pr&oject settings
OverlayPage.Configure_Workspace_Settings=&Configure Workspace Settings ...
OverlayPage.Configure_Workspace_Settings=&Configure Workspace Settings...
PropertyStore.Cannot_write_resource_property=Cannot write resource property

View file

@ -1,26 +1,13 @@
/*******************************************************************************
* $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.
* $
* Copyright (c) 2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
/*
* 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;

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.views;
import java.util.Collection;
@ -21,13 +31,14 @@ 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.
* Other plugins can contribute to override default behaviour 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";
public static final String ID = "org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"; //$NON-NLS-1$
private Composite area;
/**
* Control for problem message, which can include location
@ -50,7 +61,7 @@ public class ProblemDetails extends ViewPart {
* to create the area and initialize it.
*/
public void createPartControl(Composite parent) {
final String problemsViewId = "org.eclipse.ui.views.ProblemView";
final String problemsViewId = "org.eclipse.ui.views.ProblemView"; //$NON-NLS-1$
area = new Composite(parent, SWT.NONE);
area.setLayout(new GridLayout());
SelectionAdapter linkSelAdapter = new SelectionAdapter() {
@ -58,15 +69,15 @@ public class ProblemDetails extends ViewPart {
public void widgetSelected(SelectionEvent e) {
String link = e.text;
if (link==null) return;
if (link.startsWith("http")) {
if (link.startsWith("http")) { //$NON-NLS-1$
org.eclipse.swt.program.Program.launch(e.text);
return;
}
if (link.startsWith("file:")) {
if (link.startsWith("source:")) { //$NON-NLS-1$
// open in eclipse editor TODO
return;
}
if (link.startsWith("help:")) {
if (link.startsWith("help:")) { //$NON-NLS-1$
// open in eclipse help TODO
return;
}
@ -133,7 +144,7 @@ public class ProblemDetails extends ViewPart {
try {
control.setText(text);
} catch (Exception e) {
// this is more debug message
// this is debug message
control.setText("failed to set text: " + provider.getClass() + " " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@ -142,6 +153,6 @@ public class ProblemDetails extends ViewPart {
* Passing the focus request to the area's control.
*/
public void setFocus() {
area.setFocus();
message.setFocus();
}
}

View file

@ -1,24 +1,13 @@
/*******************************************************************************
* $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.
* $
* Copyright (c) 2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
/*
* Created by: Elena Laskavaia
* Created on: 2010-04-28
* Last modified by: $Author$
*/
package org.eclipse.cdt.codan.internal.ui.views;
import java.util.ArrayList;
@ -37,7 +26,7 @@ import org.eclipse.core.runtime.Platform;
* Class that can load extension for problemDetails
*/
public class ProblemDetailsExtensions {
private static final String ALL = "*";//$NON-NLS-1$
public static final String ALL = "*";//$NON-NLS-1$
private static final String EXTENSION_POINT_NAME = "codanProblemDetails"; //$NON-NLS-1$
private static boolean extensionsLoaded;
private static HashMap<String, Collection<?>> map = new HashMap<String, Collection<?>>();
@ -89,6 +78,11 @@ public class ProblemDetailsExtensions {
collection.add(configurationElement);
}
/**
* Remove provider from the list
* @param id - codan problem id or ALL
* @param el - details provider (class extending AbstractCodanProblemDetailsProvider) or ElementConfiguration (user internally)
*/
@SuppressWarnings("rawtypes")
public static void removeExtension(String id, Object el) {
Collection collection = getCollection(id);
@ -131,6 +125,11 @@ public class ProblemDetailsExtensions {
return collection;
}
/**
* Add extension (details provider) using API
* @param id - codan problem id or ALL
* @param provider - class extending AbstractCodanProblemDetailsProvider
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void addExtension(String id, AbstractCodanProblemDetailsProvider provider) {
Collection collection = getCollection(id);

View file

@ -1,24 +1,13 @@
/*******************************************************************************
* $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.
* $
* Copyright (c) 2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
/*
* Created by: Elena Laskavaia
* Created on: 2010-04-28
* Last modified by: $Author: elaskavaia $
*/
package org.eclipse.cdt.codan.ui;
import org.eclipse.cdt.codan.core.CodanRuntime;
@ -26,7 +15,11 @@ import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.core.resources.IMarker;
/**
* Abstract class that provides stubs for problems details
* Abstract class that provides stubs for problems details.
* This class intended to be extended by the users of codanProblemDetails extension point.
* One instance of this class would exists at runtime. To query for results, framework
* would synchronize on this class object, set setMarker then call other getStyled* methods
* to obtain data.
*/
public abstract class AbstractCodanProblemDetailsProvider {
protected IMarker marker;
@ -41,31 +34,46 @@ public abstract class AbstractCodanProblemDetailsProvider {
this.marker = marker;
}
/**
* Get marker associated with this provider
* @return
*/
public IMarker getMarker() {
return marker;
}
/**
* Convenience method to return marker message
* @return
*/
protected String getProblemMessage() {
String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
return message;
}
/**
* Convenience method to return codan problem id
* @return
*/
protected String getProblemId() {
String id = marker.getAttribute(IMarker.PROBLEM, (String) null); //$NON-NLS-1$
String id = marker.getAttribute(IMarker.PROBLEM, (String) null);
return id;
}
/**
* return true if provider can provide details for given marker (previously set by setMarker)
* @param id - id of the problem
* @return
* @return true if details are available for given marker
*/
public abstract boolean isApplicable(String id);
/**
* Return styled problem message. String can include <a> tags to which would be
* Return styled problem message. This text would be used in Link widget.
* String can include <a> tags to which would be
* visible as hyperlinks and newline characters (\n). Default message if
* marker message plus location.
* marker message plus location. Ampersand (&) should be escape because
* it is interpreted as mnemonic for control navigation (can use espaceForLink method). <br>
* This method intended to be overriden by the client.
*/
public String getStyledProblemMessage() {
String message = escapeForLink(getProblemMessage());
@ -78,8 +86,15 @@ public abstract class AbstractCodanProblemDetailsProvider {
}
/**
* Return styled problem description. String can include <a> tags to which would be
* visible as hyperlinks and newline characters (\n)
* Return styled problem description. This text would be used in Link widget.
* String can include <a> tags to which would be
* visible as hyperlinks and newline characters (\n).
* Ampersand (&) should be escape because
* it is interpreted as mnemonic for control navigation (can use espaceForLink method).
*
* Default implementation return desciption of codan problem. <br>
* This method intended to be overriden by the client.
*
*/
public String getStyledProblemDescription() {
String id = getProblemId();
@ -94,6 +109,6 @@ public abstract class AbstractCodanProblemDetailsProvider {
* such as & (mnemonic)
*/
protected String escapeForLink(String text) {
return text.replaceAll("&", "&&"); //$NON-NLS-2$
return text.replaceAll("&", "&&"); //$NON-NLS-1$//$NON-NLS-2$
}
}

View file

@ -8,7 +8,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command to run code analysis AbstractHandler, an IHandler base class.
* Command to run code analysis on selected resources
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
@ -17,10 +17,6 @@ public class RunCodanCommand extends AbstractHandler {
public RunCodanCommand() {
}
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
RunCodeAnalysis action = new RunCodeAnalysis();