Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 98685 Details for
Bug 228577
[rseterminal] Clean up RSE Terminal impl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch fixing more issues and adding Javadoc
bug228577_terminalCore3.diff.txt (text/plain), 11.68 KB, created by
Martin Oberhuber
on 2008-05-05 14:39:09 EDT
(
hide
)
Description:
Patch fixing more issues and adding Javadoc
Filename:
MIME Type:
Creator:
Martin Oberhuber
Created:
2008-05-05 14:39:09 EDT
Size:
11.68 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.subsystems.terminals.core >Index: src/org/eclipse/rse/subsystems/terminals/core/elements/TerminalElement.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.terminals.core/src/org/eclipse/rse/subsystems/terminals/core/elements/TerminalElement.java,v >retrieving revision 1.3 >diff -u -r1.3 TerminalElement.java >--- src/org/eclipse/rse/subsystems/terminals/core/elements/TerminalElement.java 24 Apr 2008 01:14:10 -0000 1.3 >+++ src/org/eclipse/rse/subsystems/terminals/core/elements/TerminalElement.java 5 May 2008 18:26:45 -0000 >@@ -1,13 +1,15 @@ > /******************************************************************************** >- * Copyright (c) 2008 MontaVista Software, Inc. >- * 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 >+ * Copyright (c) 2008 MontaVista Software, 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: > * Yu-Fen Kuo (MontaVista) - initial API and implementation > * Anna Dushistova (MontaVista) - initial API and implementation > * Yu-Fen Kuo (MontaVista) - [227572] RSE Terminal doesn't reset the "connected" state when the shell exits >+ * Martin Oberhuber (Wind River) - [228577] [rseterminal] Further cleanup > ********************************************************************************/ > package org.eclipse.rse.subsystems.terminals.core.elements; > >@@ -15,34 +17,44 @@ > import org.eclipse.rse.internal.services.terminals.ITerminalShell; > import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem; > >+/** >+ * An element in the RSE Tree that resembles a Terminal connection. >+ */ > public class TerminalElement extends AbstractResource { > private String name; > private ITerminalShell terminalShell; > >+ /** >+ * Constructor. >+ */ > public TerminalElement(String name, > ITerminalServiceSubSystem terminalServiceSubSystem) { > super(terminalServiceSubSystem); > this.name = name; > } > >- public String getName() { >+ /** >+ * Return the name of this element, which will also be used as the label in >+ * the tree. >+ */ >+ public final String getName() { > return name; > } > >- > public String toString() { > return getName(); > } > > public boolean equals(Object obj) { >- if (obj instanceof TerminalElement) { >- if (obj == this) >- return true; >- return name.equals(((TerminalElement) obj).getName()) >- && terminalShell == ((TerminalElement) obj) >- .getTerminalShell(); >- } >- return super.equals(obj); >+ if (obj == this) >+ return true; >+ if (!(obj instanceof TerminalElement)) >+ return false; >+ TerminalElement other = (TerminalElement) obj; >+ return name.equals(other.getName()) >+ && getSubSystem().equals(other.getSubSystem()) >+ && (terminalShell == null ? other.getTerminalShell() == null >+ : terminalShell.equals(other.getTerminalShell())); > } > > public int hashCode() { >@@ -51,10 +63,16 @@ > return name.hashCode() ; > } > >+ /** >+ * Return the back-end connection of this terminal instance. >+ */ > public ITerminalShell getTerminalShell() { > return terminalShell; > } > >+ /** >+ * Set the back-end connection of this terminal instance. >+ */ > public void setTerminalShell(ITerminalShell terminalShell) { > this.terminalShell = terminalShell; > } >Index: src/org/eclipse/rse/subsystems/terminals/core/TerminalServiceSubSystem.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.terminals.core/src/org/eclipse/rse/subsystems/terminals/core/TerminalServiceSubSystem.java,v >retrieving revision 1.4 >diff -u -r1.4 TerminalServiceSubSystem.java >--- src/org/eclipse/rse/subsystems/terminals/core/TerminalServiceSubSystem.java 5 May 2008 17:49:59 -0000 1.4 >+++ src/org/eclipse/rse/subsystems/terminals/core/TerminalServiceSubSystem.java 5 May 2008 18:26:45 -0000 >@@ -1,18 +1,21 @@ > /******************************************************************************** >- * Copyright (c) 2008 MontaVista Software, Inc. >- * 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 >+ * Copyright (c) 2008 MontaVista Software, 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: > * Yu-Fen Kuo (MontaVista) - initial API and implementation > * Yu-Fen Kuo (MontaVista) - [227572] RSE Terminal doesn't reset the "connected" state when the shell exits > * Anna Dushistova (MontaVista) - [228577] [rseterminal] Clean up RSE Terminal impl >+ * Martin Oberhuber (Wind River) - [228577] [rseterminal] Further cleanup > ********************************************************************************/ > > package org.eclipse.rse.subsystems.terminals.core; > > import java.util.ArrayList; >+import java.util.Iterator; > > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.rse.core.RSECorePlugin; >@@ -28,38 +31,38 @@ > import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement; > import org.eclipse.swt.widgets.Display; > >-public final class TerminalServiceSubSystem extends SubSystem implements >+/** >+ * A Subsystem that has terminal instances as children. >+ */ >+public class TerminalServiceSubSystem extends SubSystem implements > ITerminalServiceSubSystem, ICommunicationsListener { > >- protected ITerminalService _hostService = null; >+ private ITerminalService _hostService = null; > > private ArrayList children = new ArrayList(); > >- public class Refresh implements Runnable { >- private TerminalServiceSubSystem _ss; >- >- public Refresh(TerminalServiceSubSystem ss) { >- _ss = ss; >- } >- >- public void run() { >- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); >- registry.fireEvent(new SystemResourceChangeEvent(_ss, >- ISystemResourceChangeEvents.EVENT_REFRESH, _ss)); >- } >- } >- >- protected TerminalServiceSubSystem(IHost host, >- IConnectorService connectorService) { >- super(host, connectorService); >- } >- >+ /** >+ * Constructor. >+ */ > public TerminalServiceSubSystem(IHost host, > IConnectorService connectorService, ITerminalService hostService) { > super(host, connectorService); > _hostService = hostService; > } > >+ private void fireAsyncRefresh(final Object target) { >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); >+ registry.fireEvent(new SystemResourceChangeEvent(target, ISystemResourceChangeEvents.EVENT_REFRESH, target)); >+ >+ } >+ }); >+ } >+ >+ /** >+ * Return the Terminal Service associated with this subsystem. >+ */ > public ITerminalService getTerminalService() { > return _hostService; > } >@@ -69,10 +72,12 @@ > } > > public void addChild(TerminalElement element) { >- synchronized (children) { >- children.add(element); >+ if (element != null) { >+ synchronized (children) { >+ children.add(element); >+ } >+ fireAsyncRefresh(this); > } >- Display.getDefault().asyncExec(new Refresh(this)); > } > > public void removeChild(TerminalElement element) { >@@ -80,39 +85,40 @@ > synchronized (children) { > children.remove(element); > } >- Display.getDefault().asyncExec(new Refresh(this)); >+ fireAsyncRefresh(this); > } > } > > public void removeChild(String terminalTitle) { > removeChild(getChild(terminalTitle)); > } >+ > public TerminalElement getChild(String terminalTitle) { >- Object[] children = getChildren(); >- for (int i = 0, e = children.length; i < e; i++) { >- TerminalElement element = (TerminalElement)children[i]; >- if (element.getName().equals(terminalTitle)) >- return element; >- } >+ synchronized (children) { >+ for (Iterator it = children.iterator(); it.hasNext();) { >+ TerminalElement element = (TerminalElement) it.next(); >+ if (element.getName().equals(terminalTitle)) >+ return element; >+ } >+ } > return null; > } >+ > public Object[] getChildren() { >- Object[] result; > synchronized (children) { >- result = (Object[]) children >- .toArray(new Object[children.size()]); >+ return children.toArray(); > } >- return result; > } > > public boolean hasChildren() { > synchronized (children) { >- if (children.size() > 0) >- return true; >- return false; >+ return !children.isEmpty(); > } > } > >+ /** >+ * Set the terminal service associated with this subsystem. >+ */ > public void setTerminalService(ITerminalService service) { > _hostService = service; > } >@@ -141,23 +147,27 @@ > public boolean isPassiveCommunicationsListener() { > return true; > } >- public void cancelAllTerminals() { >- if (children.size() == 0) >- return; >- Object[] terminals = getChildren(); >- for (int i = terminals.length-1; i >= 0; i--) { >- TerminalElement element = (TerminalElement)terminals[i]; >- try { >- removeTerminalElement(element); >- } catch (Exception e) { >- RSECorePlugin.getDefault().getLogger().logError("Error removing terminal", e); //$NON-NLS-1$ >- } >- } >- synchronized(children){ >- children.clear(); >- } >- Display.getDefault().asyncExec(new Refresh(this)); > >+ /** >+ * Set the terminal service associated with this subsystem. >+ */ >+ public void cancelAllTerminals() { >+ Object[] terminals; >+ synchronized (children) { >+ terminals = getChildren(); >+ children.clear(); >+ } >+ if (terminals.length > 0) { >+ for (int i = terminals.length - 1; i >= 0; i--) { >+ TerminalElement element = (TerminalElement) terminals[i]; >+ try { >+ removeTerminalElement(element); >+ } catch (Exception e) { >+ RSECorePlugin.getDefault().getLogger().logError("Error removing terminal", e); //$NON-NLS-1$ >+ } >+ } >+ fireAsyncRefresh(this); >+ } > } > > private void removeTerminalElement(TerminalElement element) { >@@ -165,6 +175,7 @@ > ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); > registry.fireEvent(new SystemResourceChangeEvent(element, ISystemResourceChangeEvents.EVENT_COMMAND_SHELL_REMOVED, null)); > } >+ > public void initializeSubSystem(IProgressMonitor monitor) { > super.initializeSubSystem(monitor); > getConnectorService().addCommunicationsListener(this);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 228577
:
98604
|
98633
| 98685