Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5dc14fa9ac89bbb86f2f5087e0d79574f18ab847 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*******************************************************************************
 * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
 * This program and the accompanying materials are made available under the terms
 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tcf.te.tcf.ui.views.scriptpad.events;

import java.util.EventObject;

import org.eclipse.tcf.te.tcf.core.scripting.events.ScriptEvent;
import org.eclipse.tcf.te.tcf.ui.views.scriptpad.console.Console;
import org.eclipse.tcf.te.tcf.ui.views.scriptpad.console.Factory;
import org.eclipse.tcf.te.ui.events.AbstractEventListener;

/**
 * Script Pad console event listener
 */
public class EventListener extends AbstractEventListener {

	/* (non-Javadoc)
	 * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
	 */
	@Override
	public void eventFired(EventObject event) {
		if (event instanceof ScriptEvent) {
			ScriptEvent scriptEvent = (ScriptEvent)event;

			// Get the event type
			ScriptEvent.Type type = scriptEvent.getType();

			switch (type) {
				case START:
					Factory.showConsole();
					break;
				case OUTPUT:
					Console console = Factory.getConsole();
					if (console != null) {
						ScriptEvent.Message message = scriptEvent.getMessage();
						if (message != null) console.appendMessage(message.type, message.text);
					}
					break;
				case STOP:
					break;
			}
		}
	}

}

Back to the top