1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 23:05:47 +02:00

[186779] Fix IRSESystemType.getAdapter()

This commit is contained in:
Martin Oberhuber 2007-05-14 13:33:45 +00:00
parent 5ba7489961
commit f431b44e9b
13 changed files with 54 additions and 34 deletions

View file

@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2006 IBM Corporation. All rights reserved.
* Copyright (c) 2006, 2007 IBM Corporation 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
@ -11,11 +11,12 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.internal.ui;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.ui.RSESystemTypeAdapter;
@ -23,8 +24,19 @@ public class RSESystemTypeAdapterFactory implements IAdapterFactory {
private RSESystemTypeAdapter adapter = new RSESystemTypeAdapter();
public RSESystemTypeAdapterFactory() {
super();
public Class[] getAdapterList()
{
return new Class[] {RSESystemTypeAdapter.class};
}
/**
* Called by our plugin's startup method to register our adaptable object types
* with the platform. We prefer to do it here to isolate/encapsulate all factory
* logic in this one place.
*/
public void registerWithManager(IAdapterManager manager)
{
manager.registerAdapters(this, IRSESystemType.class);
}
public Object getAdapter(Object adaptableObject, Class adapterType) {
@ -36,7 +48,4 @@ public class RSESystemTypeAdapterFactory implements IAdapterFactory {
}
}
public Class[] getAdapterList() {
return new Class[] {IRSESystemType.class};
}
}

View file

@ -24,6 +24,7 @@
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -1011,7 +1012,7 @@ public class SystemView extends SafeTreeViewer
IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes();
for (int i = 0; i < systemTypes.length; i++) {
IRSESystemType systemType = systemTypes[i];
Object adapter = systemType.getAdapter(IRSESystemType.class);
Object adapter = systemType.getAdapter(RSESystemTypeAdapter.class);
if (adapter instanceof RSESystemTypeAdapter) {
((RSESystemTypeAdapter)adapter).addCustomMenuGroups(menu);
}

View file

@ -23,6 +23,7 @@
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -135,7 +136,7 @@ public class SystemViewConnectionAdapter
// _Never_ add any action without the system type provider having said ok to this.
IHost host = (IHost)selection.getFirstElement();
IRSESystemType sysType = getSystemTypeForHost(host);
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
//updateAction.setValue(null); // reset
@ -174,7 +175,7 @@ public class SystemViewConnectionAdapter
private void addConnectOrDisconnectAction(SystemMenuManager menu, String menuGroup, IStructuredSelection selection) {
IHost host = (IHost)selection.getFirstElement();
IRSESystemType sysType = getSystemTypeForHost(host);
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
ISystemRegistry sysReg = RSECorePlugin.getTheSystemRegistry();
@ -225,7 +226,7 @@ public class SystemViewConnectionAdapter
// _Never_ add any action without the system type provider having said ok to this.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemCommonDeleteAction.class);
@ -242,7 +243,7 @@ public class SystemViewConnectionAdapter
// _Never_ add any action without the system type provider having said ok to this.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
boolean accepted = false;
@ -264,7 +265,7 @@ public class SystemViewConnectionAdapter
// _Never_ add any action without the system type provider having said ok to this.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemOpenExplorerPerspectiveAction.class);
@ -281,7 +282,7 @@ public class SystemViewConnectionAdapter
// _Never_ add any action without the system type provider having said ok to this.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, PropertyDialogAction.class);
@ -298,7 +299,7 @@ public class SystemViewConnectionAdapter
// _Never_ add any action without the system type provider having said ok to this.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemRefreshAction.class);
@ -315,7 +316,7 @@ public class SystemViewConnectionAdapter
// _Never_ add any action without the system type provider having said ok to this.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemCommonRenameAction.class);
@ -334,7 +335,7 @@ public class SystemViewConnectionAdapter
ImageDescriptor descriptor = null;
IRSESystemType systemType = getSystemTypeForHost(connection);
if (systemType != null) {
RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
if (anyConnected) {
descriptor = sysTypeAdapter.getLiveImageDescriptor(systemType);
} else {

View file

@ -18,6 +18,7 @@
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [185552] Remove remoteSystemsViewPreferencesActions extension point
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -677,7 +678,7 @@ public class SystemViewPart
IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes();
for (int i = 0; i < systemTypes.length; i++) {
IRSESystemType systemType = systemTypes[i];
Object adapter = systemType.getAdapter(IRSESystemType.class);
Object adapter = systemType.getAdapter(RSESystemTypeAdapter.class);
if (adapter instanceof RSESystemTypeAdapter) {
((RSESystemTypeAdapter)adapter).addCustomToolbarGroups(this);
}

View file

@ -22,6 +22,7 @@
* Martin Oberhuber (Wind River) - [186523] Move subsystemConfigurations from UI to core
* Martin Oberhuber (Wind River) - [185552] Remove remoteSystemsViewPreferencesActions extension point
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.ui;
@ -107,7 +108,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
// create the connection only if the local system type is enabled!
IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
if (systemType != null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
if (adapter != null && adapter.isEnabled(systemType)) {
ISystemProfileManager profileManager = SystemProfileManager.getDefault();
ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile();
@ -462,7 +463,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
ssfaf.registerWithManager(manager);
RSESystemTypeAdapterFactory rseSysTypeFactory = new RSESystemTypeAdapterFactory();
manager.registerAdapters(rseSysTypeFactory, IRSESystemType.class);
rseSysTypeFactory.registerWithManager(manager);
manager.registerAdapters(new SubSystemConfigurationProxyAdapterFactory(), ISubSystemConfigurationProxy.class);

View file

@ -19,6 +19,7 @@
* Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.ui;
@ -501,7 +502,7 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
if (!updateMode) {
return false;
}
RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(defaultSystemType.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(defaultSystemType.getAdapter(RSESystemTypeAdapter.class));
return sysTypeAdapter.isEnableOffline(defaultSystemType);
}

View file

@ -16,9 +16,9 @@
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.ui.propertypages;
import java.util.ArrayList;
@ -361,7 +361,7 @@ public class SystemTypeFieldEditor extends FieldEditor
public Object getValue(Object element, String property)
{
IRSESystemType row = (IRSESystemType)element;
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(row.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(row.getAdapter(RSESystemTypeAdapter.class));
Object value = ""; //$NON-NLS-1$
if (property.equals(P_NAME))
@ -387,7 +387,7 @@ public class SystemTypeFieldEditor extends FieldEditor
public void modify(Object element, String property, Object value)
{
IRSESystemType row = (IRSESystemType)(((TableItem)element).getData());
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(row.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(row.getAdapter(RSESystemTypeAdapter.class));
if (property.equals(P_ENABLED))
{
@ -424,7 +424,7 @@ public class SystemTypeFieldEditor extends FieldEditor
public String getColumnText(Object element, int columnIndex)
{
IRSESystemType currType = (IRSESystemType)element;
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(currType.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(currType.getAdapter(RSESystemTypeAdapter.class));
if (columnIndex == COLUMN_NAME)
return currType.getLabel();
@ -530,7 +530,7 @@ public class SystemTypeFieldEditor extends FieldEditor
// }
// // find this system type in the array...
// IRSESystemType matchingType = RSECorePlugin.getTheCoreRegistry().getSystemType(key);
// RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(matchingType.getAdapter(IRSESystemType.class));
// RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(matchingType.getAdapter(RSESystemTypeAdapter.class));
//
// // update this system type's attributes as per preferences...
// {

View file

@ -8,6 +8,7 @@
* Contributors:
* Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
@ -70,7 +71,7 @@ public class RSENewConnectionWizardDescriptor extends RSEWizardDescriptor implem
IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes();
for (int i = 0; i < systemTypes.length; i++) {
IRSESystemType systemType = systemTypes[i];
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
if (systemTypeMatcher.matches(systemType)
|| (adapter != null
&& adapter.acceptWizardDescriptor(getConfigurationElement().getName(), this))) {

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
@ -111,7 +112,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
}
// Second, double check if the system type passed the viewer filter but is disabled.
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
if (adapter != null && !adapter.isEnabled(systemType)) {
return false;
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
@ -62,7 +63,7 @@ public class RSENewConnectionWizardSelectionTreeElement extends RSEWizardSelecti
String key = getSystemType().getId() + "::" + getWizardRegistryElement().getId(); //$NON-NLS-1$
Image image = imageRegistry.get(key);
if (image == null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(getSystemType().getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(getSystemType().getAdapter(RSESystemTypeAdapter.class));
if (adapter != null) {
ImageDescriptor descriptor = adapter.getImageDescriptor(getSystemType());
image = descriptor.createImage();
@ -81,7 +82,7 @@ public class RSENewConnectionWizardSelectionTreeElement extends RSEWizardSelecti
// not come up with a description itself.
String description = super.getDescription();
if (description == null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(getSystemType().getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(getSystemType().getAdapter(RSESystemTypeAdapter.class));
if (adapter != null) {
description = adapter.getDescription(getSystemType());
}

View file

@ -17,6 +17,7 @@
* David Dykstal (IBM) - 142806: refactoring persistence framework
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.ui.internal.model;
@ -192,7 +193,7 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
// delegate the creation of the host object instance to the system type provider!!!
if (systemType != null) {
Object adapter = systemType.getAdapter(IRSESystemType.class);
Object adapter = systemType.getAdapter(RSESystemTypeAdapter.class);
if (adapter instanceof RSESystemTypeAdapter) {
conn = ((RSESystemTypeAdapter)adapter).createNewHostInstance(profile);
}

View file

@ -14,6 +14,7 @@
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.ui.internal.model;
@ -185,7 +186,7 @@ public class SystemNewConnectionPromptObject implements ISystemPromptableObject,
}
if (enabled) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
if (adapter != null && !adapter.isEnabled(systemType)) {
enabled = false;
}
@ -224,7 +225,7 @@ public class SystemNewConnectionPromptObject implements ISystemPromptableObject,
if (hasChildren())
return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWCONNECTION_ID);
else {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemTypes[0].getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemTypes[0].getAdapter(RSESystemTypeAdapter.class));
return adapter.getImageDescriptor(systemTypes[0]);
}
}

View file

@ -25,6 +25,7 @@
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
********************************************************************************/
package org.eclipse.rse.ui.internal.model;
@ -268,7 +269,7 @@ public class SystemRegistry implements ISystemRegistry, ISystemRegistryUI, ISyst
IHost con = connections[i];
IRSESystemType sysType = con.getSystemType();
if (sysType != null) { // sysType can be null if workspace contains a host that is no longer defined by the workbench
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(IRSESystemType.class));
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(RSESystemTypeAdapter.class));
// Note: System types without registered subsystems get disabled by the adapter itself!
// There is no need to re-check this here again.
if (adapter.isEnabled(sysType)) result.add(con);