mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Fix for 68028: Open Declaration into closed project causes PartInitException
This commit is contained in:
parent
7b219f7c9b
commit
9aebc8d6a2
4 changed files with 37 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2004-06-22 Bogdan Gheorghe
|
||||||
|
Fix for 68028: Open Declaration into closed project causes PartInitException
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/util/OpenIncludeAction.java
|
||||||
|
|
||||||
|
|
||||||
2004-06-21 Bogdan Gheorghe
|
2004-06-21 Bogdan Gheorghe
|
||||||
Fixed opening search external markers.
|
Fixed opening search external markers.
|
||||||
|
|
||||||
|
|
|
@ -298,6 +298,9 @@ OpenIncludeAction.tooltip=Open the Selected Include in the Editor
|
||||||
OpenIncludeAction.description=Open the selected include in the editor
|
OpenIncludeAction.description=Open the selected include in the editor
|
||||||
OpenIncludeAction.dialog.title=Open Include
|
OpenIncludeAction.dialog.title=Open Include
|
||||||
OpenIncludeAction.dialog.message=Select the file to open
|
OpenIncludeAction.dialog.message=Select the file to open
|
||||||
|
OpenIncludeAction.error = No Includes Found
|
||||||
|
OpenIncludeAction.error.description = No include files were found that matched that name.
|
||||||
|
|
||||||
|
|
||||||
# ------- SearchDialogAction ---------------
|
# ------- SearchDialogAction ---------------
|
||||||
SearchDialogAction.label=C/C++ Search...
|
SearchDialogAction.label=C/C++ Search...
|
||||||
|
@ -323,3 +326,8 @@ CreateFolderAction.text = F&older
|
||||||
|
|
||||||
# ------- Drag and Drop Message Text -----------
|
# ------- Drag and Drop Message Text -----------
|
||||||
CViewDragNDrop.txt = already exists. Would you like to overwrite it?
|
CViewDragNDrop.txt = already exists. Would you like to overwrite it?
|
||||||
|
|
||||||
|
# ------- EditorUtility Open Closed Project Text -----------
|
||||||
|
EditorUtility.closedproject = Project is closed
|
||||||
|
Editorutility.closedproject.description = The project {0} containing that declaration is closed.
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ import org.eclipse.jface.viewers.ISelectionProvider;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.jface.window.Window;
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.widgets.MessageBox;
|
||||||
import org.eclipse.ui.IEditorDescriptor;
|
import org.eclipse.ui.IEditorDescriptor;
|
||||||
import org.eclipse.ui.IEditorRegistry;
|
import org.eclipse.ui.IEditorRegistry;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
@ -97,6 +99,7 @@ public class OpenIncludeAction extends Action {
|
||||||
IPath fileToOpen;
|
IPath fileToOpen;
|
||||||
int nElementsFound= filesFound.size();
|
int nElementsFound= filesFound.size();
|
||||||
if (nElementsFound == 0) {
|
if (nElementsFound == 0) {
|
||||||
|
noElementsFound();
|
||||||
fileToOpen= null;
|
fileToOpen= null;
|
||||||
} else if (nElementsFound == 1) {
|
} else if (nElementsFound == 1) {
|
||||||
fileToOpen= (IPath) filesFound.get(0);
|
fileToOpen= (IPath) filesFound.get(0);
|
||||||
|
@ -123,6 +126,16 @@ public class OpenIncludeAction extends Action {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void noElementsFound() {
|
||||||
|
MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
|
||||||
|
errorMsg.setText(CUIPlugin.getResourceString("OpenIncludeAction.error")); //$NON-NLS-1$
|
||||||
|
errorMsg.setMessage (CUIPlugin.getResourceString("OpenIncludeAction.error.description")); //$NON-NLS-1$
|
||||||
|
errorMsg.open();
|
||||||
|
}
|
||||||
|
|
||||||
private void findFile(String[] includePaths, String name, ArrayList list) throws CoreException {
|
private void findFile(String[] includePaths, String name, ArrayList list) throws CoreException {
|
||||||
for (int i = 0; i < includePaths.length; i++) {
|
for (int i = 0; i < includePaths.length; i++) {
|
||||||
IPath path = new Path(includePaths[i] + "/" + name); //$NON-NLS-1$
|
IPath path = new Path(includePaths[i] + "/" + name); //$NON-NLS-1$
|
||||||
|
|
|
@ -8,6 +8,7 @@ package org.eclipse.cdt.internal.ui.util;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
@ -17,12 +18,12 @@ import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.resources.FileStorage;
|
import org.eclipse.cdt.core.resources.FileStorage;
|
||||||
import org.eclipse.cdt.internal.ui.cview.CViewMessages;
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
|
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
|
||||||
import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
|
import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IStorage;
|
import org.eclipse.core.resources.IStorage;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -118,7 +119,7 @@ public class EditorUtility {
|
||||||
|
|
||||||
private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
|
private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
|
||||||
if (!file.getProject().isAccessible()){
|
if (!file.getProject().isAccessible()){
|
||||||
closedProject();
|
closedProject(file.getProject());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,13 +149,16 @@ public class EditorUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param project
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static void closedProject() {
|
private static void closedProject(IProject project) {
|
||||||
MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
|
MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
|
||||||
errorMsg.setText("ARGHH!"); //$NON-NLS-1$
|
errorMsg.setText(CUIPlugin.getResourceString("EditorUtility.closedproject")); //$NON-NLS-1$
|
||||||
errorMsg.setMessage ("You tried to open that which cannot be opened..."); //$NON-NLS-1$
|
String desc= CUIPlugin.getResourceString("Editorutility.closedproject.description");
|
||||||
|
errorMsg.setMessage (MessageFormat.format(desc, new Object[]{project.getName()})); //$NON-NLS-1$
|
||||||
errorMsg.open();
|
errorMsg.open();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
|
private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue