X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/model/VariableContextManager.java b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/model/VariableContextManager.java index 686413e..93127ad 100644 --- a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/model/VariableContextManager.java +++ b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/model/VariableContextManager.java @@ -1,20 +1,20 @@ package net.sourceforge.phpdt.externaltools.internal.model; /********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. All rights reserved. -This file is made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html -**********************************************************************/ + Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + This file is made available under the terms of the Common Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/cpl-v10.html + **********************************************************************/ -import java.util.Map; +//import java.util.Map; import net.sourceforge.phpdt.externaltools.variable.ExpandVariableContext; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; +//import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IEditorInput; @@ -27,35 +27,39 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder; +//import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder; /** - * Maintains the context used to expand variables. The context is based on - * the selected resource, unless a build is in progress - in which case - * the context is based on the project being built.. + * Maintains the context used to expand variables. The context is based on the + * selected resource, unless a build is in progress - in which case the context + * is based on the project being built.. */ -public class VariableContextManager implements IWindowListener, ISelectionListener { +public class VariableContextManager implements IWindowListener, + ISelectionListener { // singleton private static VariableContextManager fgDefault; - + private IResource fSelectedResource = null; - + private boolean fBuilding = false; + private IProject fProject = null; + private int fKind; - + private VariableContextManager() { IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench != null) { //may be running headless + if (workbench != null) { // may be running headless workbench.addWindowListener(this); - IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow(); + IWorkbenchWindow activeWindow = workbench + .getActiveWorkbenchWindow(); if (activeWindow != null) { windowActivated(activeWindow); } - } + } } - + /** * Returns the singleton resource selection manager * @@ -63,22 +67,22 @@ public class VariableContextManager implements IWindowListener, ISelectionListen */ public static VariableContextManager getDefault() { if (fgDefault == null) { - fgDefault = new VariableContextManager(); + fgDefault = new VariableContextManager(); } return fgDefault; } - + /** * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow) */ public void windowActivated(IWorkbenchWindow window) { fSelectedResource = null; - ISelectionService service = window.getSelectionService(); + ISelectionService service = window.getSelectionService(); service.addSelectionListener(this); IWorkbenchPage page = window.getActivePage(); if (page != null) { IWorkbenchPart part = page.getActivePart(); - if (part != null) { + if (part != null) { ISelection selection = service.getSelection(); if (selection != null) { selectionChanged(part, selection); @@ -108,31 +112,36 @@ public class VariableContextManager implements IWindowListener, ISelectionListen } /** - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, + * org.eclipse.jface.viewers.ISelection) */ public void selectionChanged(IWorkbenchPart part, ISelection selection) { IResource selectedResource = null; if (selection instanceof IStructuredSelection) { - Object result = ((IStructuredSelection)selection).getFirstElement(); + Object result = ((IStructuredSelection) selection) + .getFirstElement(); if (result instanceof IResource) { selectedResource = (IResource) result; } else if (result instanceof IAdaptable) { - selectedResource = (IResource)((IAdaptable) result).getAdapter(IResource.class); + selectedResource = (IResource) ((IAdaptable) result) + .getAdapter(IResource.class); } } - + if (selectedResource == null) { - // If the active part is an editor, get the file resource used as input. + // If the active part is an editor, get the file resource used as + // input. if (part instanceof IEditorPart) { IEditorPart editorPart = (IEditorPart) part; IEditorInput input = editorPart.getEditorInput(); - selectedResource = (IResource) input.getAdapter(IResource.class); - } + selectedResource = (IResource) input + .getAdapter(IResource.class); + } } - + fSelectedResource = selectedResource; } - + /** * Returns the active variable context. The context is that of the selected * resource, or a project being built. @@ -146,7 +155,7 @@ public class VariableContextManager implements IWindowListener, ISelectionListen return new ExpandVariableContext(fSelectedResource); } } - + /** * Notification that the given project is being built. * @@ -154,18 +163,19 @@ public class VariableContextManager implements IWindowListener, ISelectionListen * @param kind * @see ExternalToolBuilder#build(int, Map, IProgressMonitor) */ - public void buildStarted(IProject project, int kind) { - fBuilding = true; - fProject = project; - fKind = kind; - } - +// public void buildStarted(IProject project, int kind) { +// fBuilding = true; +// fProject = project; +// fKind = kind; +// } + /** * Notification the building the current project has completed. + * * @see ExternalToolBuilder#build(int, Map, IProgressMonitor) */ - public void buildEnded() { - fBuilding = false; - fProject= null; - } +// public void buildEnded() { +// fBuilding = false; +// fProject = null; +// } }