mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
convertSelectionToProject() new methiod.
Only reset document if Project change.
This commit is contained in:
parent
131fa95091
commit
5ff7d8b5e9
1 changed files with 48 additions and 39 deletions
|
@ -126,31 +126,12 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
|
||||||
fConsoleManager.addConsoleListener(this);
|
fConsoleManager.addConsoleListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IProject setProject(ISelection selection) {
|
protected void setProject(ISelection selection) {
|
||||||
if ( selection == null ) {
|
selProject = convertSelectionToProject(selection);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
IStructuredSelection ssel = (IStructuredSelection) selection;
|
protected void setProject(IProject project) {
|
||||||
IAdaptable input = (IAdaptable) ssel.getFirstElement();
|
selProject = project;
|
||||||
if (input != null) {
|
|
||||||
IResource resource = null;
|
|
||||||
if (input instanceof IResource) {
|
|
||||||
resource = (IResource) input;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resource = (IResource) input.getAdapter(IResource.class);
|
|
||||||
}
|
|
||||||
if (resource != null) {
|
|
||||||
selProject = resource.getProject();
|
|
||||||
return selProject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ClassCastException e) {
|
|
||||||
}
|
|
||||||
selProject = null;
|
|
||||||
return selProject;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IProject getProject() {
|
protected IProject getProject() {
|
||||||
|
@ -240,16 +221,6 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
|
||||||
actionBars.getToolBarManager().add(fClearOutputAction);
|
actionBars.getToolBarManager().add(fClearOutputAction);
|
||||||
actionBars.updateActionBars();
|
actionBars.updateActionBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the console
|
|
||||||
*/
|
|
||||||
void clear() {
|
|
||||||
if (selProject != null) {
|
|
||||||
fConsoleManager.getConsole(selProject).clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reveals (makes visible) the end of the current document
|
* Reveals (makes visible) the end of the current document
|
||||||
*/
|
*/
|
||||||
|
@ -282,10 +253,15 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
|
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
|
||||||
setProject(selection);
|
IProject newProject = convertSelectionToProject(selection);
|
||||||
|
IProject oldProject = getProject();
|
||||||
|
if (oldProject == null ||
|
||||||
|
(newProject != null && !newProject.equals(oldProject))) {
|
||||||
|
setProject(newProject);
|
||||||
setDocument();
|
setDocument();
|
||||||
setTitle();
|
setTitle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void consoleChange(IBuildConsoleEvent event) {
|
public void consoleChange(IBuildConsoleEvent event) {
|
||||||
if ( event.getType() == IBuildConsoleEvent.CONSOLE_START ) {
|
if ( event.getType() == IBuildConsoleEvent.CONSOLE_START ) {
|
||||||
|
@ -300,4 +276,37 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IProject convertSelectionToProject(ISelection selection) {
|
||||||
|
IProject project = null;
|
||||||
|
if ( selection == null ) {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
IStructuredSelection ssel = (IStructuredSelection) selection;
|
||||||
|
IAdaptable input = (IAdaptable) ssel.getFirstElement();
|
||||||
|
if (input != null) {
|
||||||
|
IResource resource = null;
|
||||||
|
if (input instanceof IResource) {
|
||||||
|
resource = (IResource) input;
|
||||||
|
} else {
|
||||||
|
resource = (IResource) input.getAdapter(IResource.class);
|
||||||
|
}
|
||||||
|
if (resource != null) {
|
||||||
|
project = resource.getProject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
}
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the console
|
||||||
|
*/
|
||||||
|
void clear() {
|
||||||
|
if (selProject != null) {
|
||||||
|
fConsoleManager.getConsole(selProject).clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue