This commit was manufactured by cvs2svn to create branch 'BreakpointGroups'.

Cherrypick from master 2004-09-08 21:51:19 UTC Kevin Barnes <krbarnes> 'Bug 56252 - [Generic Console] no support for enabled/disabled lifecycles':
    org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/JavaConsoleTrackerPropertyTester.java
    org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsolePageParticipant.java
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/JavaConsoleTrackerPropertyTester.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/JavaConsoleTrackerPropertyTester.java
new file mode 100644
index 0000000..060e3a0
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/JavaConsoleTrackerPropertyTester.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.views.console;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.ui.console.IOConsole;
+
+/**
+ * Tests if a process type matches the expected value.
+ * 
+ * @since 3.1
+ */
+public class JavaConsoleTrackerPropertyTester extends PropertyTester {
+
+    /* (non-Javadoc)
+     * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+     */
+    public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+        boolean testPassed = false;
+        IOConsole console = (IOConsole) receiver;
+        IProcess process = (IProcess) console.getAttribute(IDebugUIConstants.ATTR_CONSOLE_PROCESS);
+        if (process != null) {
+            String type = process.getAttribute(IProcess.ATTR_PROCESS_TYPE);
+            testPassed = (type != null && type.equals(expectedValue));
+        }
+        return testPassed;
+    }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsolePageParticipant.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsolePageParticipant.java
new file mode 100644
index 0000000..876875b
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsolePageParticipant.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.views.console;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsolePageParticipantDelegate;
+import org.eclipse.ui.console.IConsoleView;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.ShowInContext;
+
+/**
+ * Creates and manages process console specific actions
+ * 
+ * @since 3.1
+ */
+public class ProcessConsolePageParticipant implements IConsolePageParticipantDelegate, IShowInSource, IShowInTargetList, IDebugEventSetListener, ISelectionListener {
+
+	// scroll lock
+	private boolean fIsLocked = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK);
+	
+	// actions
+	private ConsoleTerminateAction fTerminate;
+	private ConsoleRemoveAllTerminatedAction fRemoveTerminated;
+
+    private ProcessConsole fConsole;
+
+    private IPageSite fSite;
+
+    private IConsoleView fView;
+		
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.console.IConsolePageParticipantDelegate#init(org.eclipse.ui.part.IPageSite)
+     */
+    public void init(IPageSite site, IConsole console) {
+        fSite = site;
+        fConsole = (ProcessConsole) console;
+        fConsole.setAutoScroll(!fIsLocked);
+        
+        fRemoveTerminated = new ConsoleRemoveAllTerminatedAction();
+        fTerminate = new ConsoleTerminateAction(fConsole);
+        
+        fView = (IConsoleView)site.getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW);
+        
+        DebugPlugin.getDefault().addDebugEventListener(this);
+        fSite.getPage().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.console.IConsolePageParticipantDelegate#dispose()
+     */
+    public void dispose() {
+        fSite.getPage().removeSelectionListener(this);
+		DebugPlugin.getDefault().removeDebugEventListener(this);
+
+		if (fRemoveTerminated != null) {
+			fRemoveTerminated.dispose();
+		}
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.console.IConsolePageParticipantDelegate#contextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
+     */
+    public void contextMenuAboutToShow(IMenuManager menu) {
+        menu.add(fTerminate);
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.console.IConsolePageParticipantDelegate#configureToolBar(org.eclipse.jface.action.IToolBarManager)
+     */
+    public void configureToolBar(IToolBarManager mgr) {
+		mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fTerminate);
+		mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fRemoveTerminated);
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+     */
+    public Object getAdapter(Class required) {
+        if (IShowInSource.class.equals(required)) {
+            return this;
+        }
+        if (IShowInTargetList.class.equals(required)) {
+            return this; 
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.IShowInSource#getShowInContext()
+     */
+    public ShowInContext getShowInContext() {
+        IProcess process = getProcess();
+        if (process == null) {
+            return null;
+        } 
+        IDebugTarget target = (IDebugTarget)process.getAdapter(IDebugTarget.class);
+        ISelection selection = null;
+        if (target == null) {
+            selection = new StructuredSelection(process);
+        } else {
+            selection = new StructuredSelection(target);
+        }
+        return new ShowInContext(null, selection);
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.IShowInTargetList#getShowInTargetIds()
+     */
+    public String[] getShowInTargetIds() {
+        return new String[] {IDebugUIConstants.ID_DEBUG_VIEW};
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
+     */
+    public void handleDebugEvents(DebugEvent[] events) {
+        for (int i = 0; i < events.length; i++) {
+            DebugEvent event = events[i];
+            if (event.getSource().equals(getProcess())) {
+                Runnable r = new Runnable() {
+                    public void run() {
+                        fTerminate.update();
+                    }
+                };
+                
+                DebugUIPlugin.getStandardDisplay().asyncExec(r);           
+            }
+        }
+    }
+    
+    protected IProcess getProcess() {
+        return fConsole.getProcess();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+     */
+    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+        if (getProcess().equals(DebugUITools.getCurrentProcess())) {
+            fView.display(fConsole);
+        }
+	}
+}