1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00
start of string cleanup
improved error handling with targets
This commit is contained in:
David Inglis 2004-02-24 02:04:02 +00:00
parent 181ceb45e7
commit f25407a2dc
20 changed files with 120 additions and 105 deletions

View file

@ -102,3 +102,6 @@ LexicalSortingAction.tooltip=Sort
LexicalSortingAction.tooltip.on=Do Not Sort
LexicalSortingAction.tooltip.off=Sort
MakeUIPlugin.update_project=Update make projects
MakeUIPlugin.update_project_message=Older \'make\' projects have been detected in your workspace. \n These projects are no longer supported, would you like to convert these now?
MakePreferencePage.description=Make Project Preferences

View file

@ -43,7 +43,7 @@ public class MakeUIImages {
public static final String IMG_OBJS_BUILD_TARGET = NAME_PREFIX + "target_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_BUILD_TARGET = createManaged(OBJ, IMG_OBJS_BUILD_TARGET);
public static final String IMG_OBJS_ERROR = NAME_PREFIX + "error_obj.gif";
public static final String IMG_OBJS_ERROR = NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJ_ERROR = createManaged(OBJ, IMG_OBJS_ERROR);
@ -71,9 +71,9 @@ public class MakeUIImages {
public static final String IMG_OBJS_MAKEFILE_INCLUDE = NAME_PREFIX + "include_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_MAKEFILE_INCLUDE = createManaged(OBJ, IMG_OBJS_MAKEFILE_INCLUDE);
public static final String IMG_TOOLS_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif";
public static final String IMG_TOOLS_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$
public static final String IMG_TOOLS_MAKEFILE_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif";
public static final String IMG_TOOLS_MAKEFILE_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$
private static ImageDescriptor createManaged(String prefix, String name) {
return createManaged(imageRegistry, prefix, name);
@ -109,9 +109,9 @@ public class MakeUIImages {
*/
public static void setImageDescriptors(IAction action, String type, String relPath) {
relPath = relPath.substring(NAME_PREFIX_LENGTH);
action.setDisabledImageDescriptor(create("d" + type + "/", relPath)); //$NON-NLS-1$
action.setHoverImageDescriptor(create("c" + type + "/", relPath)); //$NON-NLS-1$
action.setImageDescriptor(create("e" + type + "/", relPath)); //$NON-NLS-1$
action.setDisabledImageDescriptor(create("d" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$
action.setHoverImageDescriptor(create("c" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$
action.setImageDescriptor(create("e" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$
}
/**

View file

@ -221,10 +221,8 @@ public class MakeUIPlugin extends AbstractUIPlugin implements IStartup {
if (MessageDialog
.openQuestion(
getShell(),
"Update make projects",
"Older 'make' projects have been detected in your workspace. \n"
+ "These projects are no longer supported, "
+ "would you like to convert these now?")
MakeUIPlugin.getResourceString("MakeUIPlugin.update_project"), //$NON-NLS-1$
MakeUIPlugin.getResourceString("MakeUIPlugin.update_project_message")) //$NON-NLS-1$
== true) {
ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell());
UpdateMakeProjectAction.run(false, pd, oldProject);

View file

@ -32,7 +32,8 @@ import org.eclipse.ui.IFileEditorInput;
public class AddBuildTargetAction extends Action {
MakefileContentOutlinePage fOutliner;
static final ITargetRule[] EMPTY_TARGET_RULES = {};
static final ITargetRule[] EMPTY_TARGET_RULES = {
};
public AddBuildTargetAction(MakefileContentOutlinePage outliner) {
super("Add To Build Target");
@ -41,7 +42,9 @@ public class AddBuildTargetAction extends Action {
fOutliner = outliner;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
@ -67,20 +70,21 @@ public class AddBuildTargetAction extends Action {
}
String buildName = sbBuildName.toString();
String makefileTarget = sbMakefileTarget.toString();
IMakeTarget target = manager.findTarget(file.getParent(), buildName);
if (target == null) {
IMakeTarget target;
try {
target = manager.findTarget(file.getParent(), buildName);
if (target == null) {
String[] ids = manager.getTargetBuilders(file.getProject());
if (ids.length > 0) {
target = manager.createTarget(file.getProject(), buildName, ids[0]);
target.setBuildTarget(makefileTarget);
manager.addTarget(file.getParent(), target);
}
}
} catch (CoreException e) {
MakeUIPlugin.errorDialog(shell, "Internal Error", "", e);
target = null;
}
}
// Always popup the dialog.
if (target != null) {
@ -107,7 +111,6 @@ public class AddBuildTargetAction extends Action {
return true;
}
private IFile getFile() {
Object input = fOutliner.getInput();
if (input instanceof IFileEditorInput) {

View file

@ -42,7 +42,7 @@ public class MakePreferencePage extends PreferencePage implements IWorkbenchPref
public MakePreferencePage() {
setPreferenceStore(MakeUIPlugin.getDefault().getPreferenceStore());
setDescription("Make Project Preferences");
setDescription(MakeUIPlugin.getResourceString("MakePreferencePage.description")); //$NON-NLS-1$
fOptionBlock = new MakeProjectOptionBlock(this);
}

View file

@ -72,7 +72,7 @@ public class MakePropertyPage extends PropertyPage implements ICOptionContainer
*/
public boolean performOk() {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
public void run(IProgressMonitor monitor) {
fOptionBlock.performApply(monitor);
}
};

View file

@ -17,7 +17,7 @@ import org.eclipse.jface.text.ITextViewer;
* Used to scan and detect for SQL keywords
*/
public class WordPartDetector {
String wordPart = "";
String wordPart = ""; //$NON-NLS-1$
int offset;
/**

View file

@ -13,8 +13,8 @@ package org.eclipse.cdt.make.ui;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
public interface IMakeHelpContextIds {
public static final String PREFIX = MakeUIPlugin.getUniqueIdentifier() + ".";
public static final String PREFIX = MakeUIPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$
public static final String MAKE_PATH_SYMBOL_SETTINGS = PREFIX + "cdt_paths_symbols_page";
public static final String MAKE_BUILDER_SETTINGS = PREFIX + "cdt_make_builder_page";
public static final String MAKE_PATH_SYMBOL_SETTINGS = PREFIX + "cdt_paths_symbols_page"; //$NON-NLS-1$
public static final String MAKE_BUILDER_SETTINGS = PREFIX + "cdt_make_builder_page"; //$NON-NLS-1$
}

View file

@ -47,6 +47,7 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
try {
return MakeCorePlugin.getDefault().getTargetManager().getTargetBuilderProjects();
} catch (CoreException e) {
// ignore
}
} else if (obj instanceof IContainer) {
ArrayList children = new ArrayList();
@ -59,6 +60,7 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
}
children.addAll(Arrays.asList(MakeCorePlugin.getDefault().getTargetManager().getTargets((IContainer) obj)));
} catch (CoreException e) {
// ignore
}
return children.toArray();
}
@ -164,8 +166,6 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
return;
}
// Get the affected resource
IResource resource = delta.getResource();
IResourceDelta[] affectedChildren = delta.getAffectedChildren(IResourceDelta.CHANGED);
// Not interested in Content changes.
@ -180,6 +180,9 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
processDelta(affectedChildren[i]);
}
// Get the affected resource
IResource resource = delta.getResource();
// Handle removed children. Issue one update for all removals.
affectedChildren = delta.getAffectedChildren(IResourceDelta.REMOVED);
if (affectedChildren.length > 0) {

View file

@ -48,7 +48,7 @@ public class MakeLabelProvider extends LabelProvider implements ITableLabelProvi
} else if (obj instanceof IContainer) {
return fLableProvider.getText(obj);
}
return "";
return ""; //$NON-NLS-1$
}
public void dispose() {
@ -77,6 +77,6 @@ public class MakeLabelProvider extends LabelProvider implements ITableLabelProvi
}
}
}
return "";
return ""; //$NON-NLS-1$
}
}

View file

@ -96,7 +96,7 @@ public class TargetListViewerPart extends StructuredViewerPart {
break;
}
} catch (CoreException e) {
MakeUIPlugin.errorDialog(getControl().getShell(), "Error", "Error", e);
MakeUIPlugin.errorDialog(getControl().getShell(), "Error", "An error occurred performing the selected action", e);
}
}

View file

@ -1,11 +1,10 @@
/*
/***********************************************************************************************************************************
* Created on 25-Jul-2003
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
* Contributors: QNX Software Systems - Initial API and implementation
**********************************************************************************************************************************/
package org.eclipse.cdt.make.ui.actions;
import org.eclipse.cdt.make.core.IMakeTarget;
@ -28,9 +27,10 @@ public class BuildTargetAction extends AbstractTargetAction {
BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container);
String name = null;
try {
name = (String) container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"));
name = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$
} catch (CoreException e) {
}
try {
if (name != null) {
IPath path = new Path(name);
name = path.segment(path.segmentCount() - 1);
@ -48,19 +48,17 @@ public class BuildTargetAction extends AbstractTargetAction {
if (dialog.open() == Window.OK) {
IMakeTarget target = dialog.getTarget();
if (target != null) {
try {
IPath path = target.getContainer().getProjectRelativePath().removeFirstSegments(container.getProjectRelativePath().segmentCount());
IPath path =
target.getContainer().getProjectRelativePath().removeFirstSegments(
container.getProjectRelativePath().segmentCount());
path = path.append(target.getName());
container.setSessionProperty(
new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"),
container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), //$NON-NLS-1$
path.toString());
} catch (CoreException e1) {
}
}
} catch (CoreException e) {
}
}
}
}

View file

@ -162,7 +162,7 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
}
IContainer container = (IContainer) proxy.requestResource();
monitor.subTask(container.getProjectRelativePath().toString());
QualifiedName qName = new QualifiedName("org.eclipse.cdt.make", "goals");
QualifiedName qName = new QualifiedName("org.eclipse.cdt.make", "goals"); //$NON-NLS-1$ //$NON-NLS-2$
String goal = container.getPersistentProperty(qName);
if (goal != null) {
goal = goal.trim();
@ -213,11 +213,11 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
IMakeBuilderInfo newInfo = MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
final int LOCATION = 0, FULL_ARGS = 1, INC_ARGS = 2, STOP_ERORR = 3, USE_DEFAULT = 4;
QualifiedName[] qName = new QualifiedName[USE_DEFAULT + 1];
qName[LOCATION] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildLocation");
qName[FULL_ARGS] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildFullArguments");
qName[INC_ARGS] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildIncrementalArguments");
qName[STOP_ERORR] = new QualifiedName(CCorePlugin.PLUGIN_ID, "stopOnError");
qName[USE_DEFAULT] = new QualifiedName(CCorePlugin.PLUGIN_ID, "useDefaultBuildCmd");
qName[LOCATION] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildLocation"); //$NON-NLS-1$
qName[FULL_ARGS] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildFullArguments"); //$NON-NLS-1$
qName[INC_ARGS] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildIncrementalArguments"); //$NON-NLS-1$
qName[STOP_ERORR] = new QualifiedName(CCorePlugin.PLUGIN_ID, "stopOnError"); //$NON-NLS-1$
qName[USE_DEFAULT] = new QualifiedName(CCorePlugin.PLUGIN_ID, "useDefaultBuildCmd"); //$NON-NLS-1$
String property = project[i].getPersistentProperty(qName[LOCATION]);
if (property != null) {

View file

@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
@ -46,8 +47,8 @@ import org.eclipse.ui.help.WorkbenchHelp;
public class BuildPathInfoBlock extends AbstractCOptionPage {
private static final int PROJECT_LIST_MULTIPLIER = 10;
private static final String PREF_SYMBOLS = "ScannerSymbols";
private static final String PREF_INCLUDES = "ScannerIncludes";
private static final String PREF_SYMBOLS = "ScannerSymbols"; //$NON-NLS-1$
private static final String PREF_INCLUDES = "ScannerIncludes"; //$NON-NLS-1$
private static final String PREFIX = "BuildPathInfoBlock"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
private static final String PATHS = PREFIX + ".paths"; //$NON-NLS-1$
@ -330,7 +331,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
private String[] parseStringToList(String syms) {
if (syms != null && syms.length() > 0) {
StringTokenizer tok = new StringTokenizer(syms, ";");
StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
ArrayList list = new ArrayList(tok.countTokens());
while (tok.hasMoreElements()) {
list.add(tok.nextToken());
@ -357,7 +358,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
selItem,
null);
String newItem = null;
if (dialog.open() == InputDialog.OK) {
if (dialog.open() == Window.OK) {
newItem = dialog.getValue();
if (newItem != null && !newItem.equals(selItem)) {
pathList.setItem(index, newItem);
@ -384,7 +385,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
selItem,
null);
String newItem = null;
if (dialog.open() == InputDialog.OK) {
if (dialog.open() == Window.OK) {
newItem = dialog.getValue();
if (newItem != null && !newItem.equals(selItem)) {
symbolList.setItem(index, newItem);
@ -490,7 +491,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
// Popup an entry dialog
InputDialog dialog = new InputDialog(shell, MakeUIPlugin.getResourceString(PATH_TITLE), MakeUIPlugin.getResourceString(PATH_LABEL), "", null); //$NON-NLS-1$
String path = null;
if (dialog.open() == InputDialog.OK) {
if (dialog.open() == Window.OK) {
path = dialog.getValue();
}
if (path != null && path.length() > 0) {
@ -504,7 +505,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
// Popup an entry dialog
InputDialog dialog = new InputDialog(shell, MakeUIPlugin.getResourceString(SYMBOL_TITLE), MakeUIPlugin.getResourceString(SYMBOL_LABEL), "", null); //$NON-NLS-1$
String symbol = null;
if (dialog.open() == InputDialog.OK) {
if (dialog.open() == Window.OK) {
symbol = dialog.getValue();
}
if (symbol != null && symbol.length() > 0) {

View file

@ -169,8 +169,9 @@ public class MakeTargetDialog extends Dialog {
if (newName.equals("")) {
fStatusLine.setErrorMessage("Must specify a target name.");
getButton(IDialogConstants.OK_ID).setEnabled(false);
} else if (
fTarget != null
} else
try {
if (fTarget != null
&& fTarget.getName().equals(newName)
|| fTargetManager.findTarget(fContainer, newName) == null) {
fStatusLine.setErrorMessage(null);
@ -179,6 +180,10 @@ public class MakeTargetDialog extends Dialog {
fStatusLine.setErrorMessage("Target with that name already exits");
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
} catch (CoreException ex) {
fStatusLine.setErrorMessage(ex.getLocalizedMessage());
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
}
});
}
@ -288,10 +293,13 @@ public class MakeTargetDialog extends Dialog {
private String generateUniqueName(String targetString) {
String newName = targetString;
int i = 0;
try {
while (fTargetManager.findTarget(fContainer, newName) != null) {
i++;
newName = targetString + " (" + Integer.toString(i) + ")";
}
} catch (CoreException e) {
}
return newName;
}

View file

@ -20,6 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@ -219,8 +220,8 @@ public class SettingsBlock extends AbstractCOptionPage {
getShell(),
getContainer().getProject(),
true,
"Selection Locations to build from.");
if (dialog.open() == ContainerSelectionDialog.OK) {
"Selection Location to build from.");
if (dialog.open() == Window.OK) {
Object[] selection = dialog.getResult();
if (selection.length > 0) {
buildLocation.setText(((IPath) selection[0]).toOSString());

View file

@ -27,7 +27,7 @@ public class AddTargetAction extends SelectionListenerAction {
this.shell = shell;
setToolTipText("Add Build Target");
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_ADD);
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_ADD); //$NON-NLS-1$
}
public void run() {
@ -36,7 +36,7 @@ public class AddTargetAction extends SelectionListenerAction {
MakeTargetDialog dialog = new MakeTargetDialog(shell, (IContainer) getStructuredSelection().getFirstElement());
dialog.open();
} catch (CoreException e) {
MakeUIPlugin.errorDialog(shell, "Internal Error", "", e);
MakeUIPlugin.errorDialog(shell, "Internal Error", "Internal Error", e);
}
}

View file

@ -26,7 +26,7 @@ public class BuildTargetAction extends SelectionListenerAction {
this.shell = shell;
setToolTipText("Build Target");
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_BUILD);
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_BUILD); //$NON-NLS-1$
}
public void run() {

View file

@ -31,7 +31,7 @@ public class DeleteTargetAction extends SelectionListenerAction {
this.shell = shell;
setToolTipText("Delete Build Target");
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_DELETE);
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_DELETE); //$NON-NLS-1$
}
/**

View file

@ -27,7 +27,7 @@ public class EditTargetAction extends SelectionListenerAction {
this.shell = shell;
setToolTipText("Edit Build Target");
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_EDIT);
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_EDIT); //$NON-NLS-1$
}
public void run() {
@ -37,7 +37,7 @@ public class EditTargetAction extends SelectionListenerAction {
dialog = new MakeTargetDialog(shell, (IMakeTarget) getStructuredSelection().getFirstElement());
dialog.open();
} catch (CoreException e) {
MakeUIPlugin.errorDialog(shell, "Internal Error", "", e);
MakeUIPlugin.errorDialog(shell, "Internal Error", "Error editing target.", e);
}
}
}