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

[202630][api][persistence] SystemProfileManager.getDefaultPrivateSystemProfile() is inconsistent with ensureDefaultPrivateProfile()

https://bugs.eclipse.org/bugs/show_bug.cgi?id=202630
This commit is contained in:
David Dykstal 2008-03-14 17:39:14 +00:00
parent af25ae2828
commit 29da955c06
12 changed files with 383 additions and 545 deletions

View file

@ -3,7 +3,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2004, 2007. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." />
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2004, 2008. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." />
<link rel="stylesheet" type="text/css" href="../book.css" />
<title> Remote System Explorer Profiles </title>
</head>
@ -13,30 +13,27 @@
</a> <h1 class="topictitle1"> Remote System Explorer Profiles </h1>
<div>
<p>
When you define your first connection to your remote server, you will also define your first profile. All Remote System Explorer resources such as connections, filters, and filter pools are owned by a profile. Profiles help you manage these resources when you have a lot of connections. The Remote System Explorer creates a unique profile per team member (that person's <em>private profile</em>), plus a common profile called <i> Team</i>. The intent is to be able to share the Team profile in the future with other members of your team. You can also create your own profiles.
All Remote System Explorer resources such as connections, filters, and filter pools are owned by a profile. Profiles help you manage these resources when you have a lot of connections. The Remote System Explorer creates two profiles when starting up for the first time: a <em>private profile</em>, usually named after the host name of the machine that creates the workspace, and a profile called <i> Team</i>. The intent is to be able to share the Team profile in the future with other members of your team. You can also create your own profiles.
</p>
<div class="p">
Profiles contain:
<ul>
<li>
Connections -- including subsystem properties. User IDs and passwords are not shared.
Connections -- including subsystem properties. User IDs and passwords are not shared.
</li>
<li>
Filters, filter pools, and filters pool references
</li>
<li>
User-defined actions
</li>
<li>
Compile commands
Other artifacts associated with a profile
</li>
</ul>
</div>
<p>
Profiles can be active, or inactive. By default, only your private profile and the Team profile are active. The Remote System Explorer displays all connections from all active profiles and, within a connection, allows filter pools to be referenced from any active profile. Further, the user actions and compile commands shown in the right-click menu for a remote resource are from all active profiles.
Profiles can be active or inactive. The Remote System Explorer displays all connections from all active profiles and, within a connection, allows filter pools to be referenced from any active profile. Further, the user actions and compile commands shown in the right-click menu for a remote resource are from all active profiles.
</p>
<p>
Your first profile will be for your local workstation. When you complete the steps for your first connection, you can decide whether to use your personal profile or the Team profile so that in the future you can share resources and information with other people.
Your private profile cannot be deleted or made inactive.
</p>
<div class="p">
<!-- TODO rework

View file

@ -16,6 +16,7 @@
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* David Dykstal (IBM) - [197036] removed createHost() shortcut (should use ISystemRegistry),
* cleaned javadoc for getFilterPools()
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
*******************************************************************************/
package org.eclipse.rse.core.model;
@ -96,7 +97,8 @@ public interface ISystemProfile extends IRSEModelObject {
/**
* Activates or deactivates a profile. If the profile is already in the
* requested state, this will do nothing.
* requested state, this will do nothing. The default private system profile
* cannot be deactivated and such a request will be ignored.
* @param flag true to activate the profile, false to deactivate it.
* @see ISystemProfile#isActive()
*/

View file

@ -13,6 +13,7 @@
*
* Contributors:
* David Dykstal (IBM) - [197036] added commitSystemProfile operation to interface
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
*******************************************************************************/
package org.eclipse.rse.core.model;
@ -38,7 +39,8 @@ public interface ISystemProfileManager {
public ISystemProfile createSystemProfile(String name, boolean makeActive);
/**
* Toggle an existing profile's state between active and inactive
* Toggle an existing profile's state between active and inactive.
* The default private profile cannot be deactivated and such a request will be ignored.
* @param profile the profile to (in)activate
* @param makeActive the state to make this profile
*/
@ -97,7 +99,7 @@ public interface ISystemProfileManager {
public void renameSystemProfile(ISystemProfile profile, String newName);
/**
* Delete the given profile
* Delete the given profile. The default private profile cannot be deleted and such a request will be ignored.
* @param profile the name of the profile to delete.
* @param persist true if the deletion is meant to be persisted as well, false if the deletion is just in the
* model.

View file

@ -24,6 +24,7 @@
* are able to delay the creation of subsystems.
* David Dykstal (IBM) - [217556] remove service subsystem types
* Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
********************************************************************************/
package org.eclipse.rse.core.model;
@ -188,6 +189,7 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
/**
* Delete a SystemProfile. Prior to physically deleting the profile, we delete all
* the connections it has, all the subsystems they have.
* The default private profile cannot be deleted and such a request will be ignored.
* <p>
* As well, all the filter pools for this profile are deleted, and subsequently any
* cross references from subsystems in connections in other profiles are removed.
@ -197,7 +199,9 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
public void deleteSystemProfile(ISystemProfile profile) throws Exception;
/**
* Make or unmake the given profile active
* Make or unmake the given profile active.
* The default private profile cannot be deactivated and such
* a request will be ignored.
*/
public void setSystemProfileActive(ISystemProfile profile, boolean makeActive);

View file

@ -17,6 +17,7 @@
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* David Dykstal (IBM) - [197036] changed getFilterPools to not force the loading of subsystem configurations
* removed createHost, migrated commit logic to SystemProfileManager
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
*******************************************************************************/
package org.eclipse.rse.internal.core.model;
@ -28,6 +29,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.model.IHost;
@ -129,13 +131,33 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
{
return isActive;
}
/**
* Reset whether this profile is currently active.
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfile#setActive(boolean)
*/
public void setActive(boolean active)
{
this.isActive = active;
setDirty(true);
public void setActive(boolean activate) {
if (activate) {
activate();
} else {
deactivate();
}
}
private void activate() {
if (!isActive) {
isActive = true;
setDirty(true);
RSEPreferencesManager.addActiveProfile(getName());
}
}
private void deactivate() {
ISystemProfile defaultProfile = mgr.getDefaultPrivateSystemProfile();
if (isActive && this != defaultProfile) {
isActive = false;
setDirty(true);
RSEPreferencesManager.deleteActiveProfile(getName());
}
}
/**
@ -176,13 +198,18 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
return RSECoreMessages.RESID_MODELOBJECTS_PROFILE_DESCRIPTION;
}
/**
* @generated This field/method will be replaced during code generation.
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfile#setName(java.lang.String)
*/
public void setName(String newName)
{
name = newName;
setDirty(true);
public void setName(String newName) {
String oldName = name;
if (!newName.equals(oldName)) {
name = newName;
setDirty(true);
if (isActive) {
RSEPreferencesManager.renameActiveProfile(oldName, newName);
}
}
}
/**

View file

@ -19,6 +19,7 @@
* - [189219] [team] Inactive Profiles become active after workbench restart
* David Dykstal (IBM) - [197036] added implementation of run() for commit transaction support
* David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
*******************************************************************************/
package org.eclipse.rse.internal.core.model;
@ -151,10 +152,7 @@ public class SystemProfileManager implements ISystemProfileManager {
deleteSystemProfile(existingProfile, false); // replace the existing one with a new profile
}
ISystemProfile newProfile = internalCreateSystemProfile(name);
newProfile.setActive(makeActive);
if (makeActive) {
RSEPreferencesManager.addActiveProfile(name);
}
newProfile.setActive(makeActive);
newProfile.commit();
return newProfile;
}
@ -163,11 +161,6 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see org.eclipse.rse.core.model.ISystemProfileManager#makeSystemProfileActive(org.eclipse.rse.core.model.ISystemProfile, boolean)
*/
public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive) {
boolean wasActive = isSystemProfileActive(profile.getName());
if (wasActive && !makeActive)
RSEPreferencesManager.deleteActiveProfile(profile.getName());
else if (makeActive && !wasActive)
RSEPreferencesManager.addActiveProfile(profile.getName());
profile.setActive(makeActive);
profile.commit();
}
@ -236,12 +229,8 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see org.eclipse.rse.core.model.ISystemProfileManager#renameSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
*/
public void renameSystemProfile(ISystemProfile profile, String newName) {
boolean isActive = isSystemProfileActive(profile.getName());
String oldName = profile.getName();
profile.setName(newName);
if (isActive) {
RSEPreferencesManager.renameActiveProfile(oldName, newName);
}
// Commit the profile to reflect the name change
RSECorePlugin.getThePersistenceManager().commitProfile(profile, 5000);
// Delete the profile by the old name, which is done in a separate job.
@ -252,19 +241,17 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see org.eclipse.rse.core.model.ISystemProfileManager#deleteSystemProfile(org.eclipse.rse.core.model.ISystemProfile, boolean)
*/
public void deleteSystemProfile(ISystemProfile profile, boolean persist) {
String oldName = profile.getName();
boolean isActive = isSystemProfileActive(oldName);
_profiles.remove(profile);
if (isActive) {
RSEPreferencesManager.deleteActiveProfile(oldName);
}
if (persist) {
IRSEPersistenceProvider provider = profile.getPersistenceProvider();
RSECorePlugin.getThePersistenceManager().deleteProfile(provider, oldName);
}
if (profile == defaultProfile) {
defaultProfile = null;
ensureDefaultPrivateProfile();
if (profile != defaultProfile) {
String oldName = profile.getName();
boolean isActive = isSystemProfileActive(oldName);
_profiles.remove(profile);
if (isActive) {
RSEPreferencesManager.deleteActiveProfile(oldName);
}
if (persist) {
IRSEPersistenceProvider provider = profile.getPersistenceProvider();
RSECorePlugin.getThePersistenceManager().deleteProfile(provider, oldName);
}
}
}
@ -504,6 +491,7 @@ public class SystemProfileManager implements ISystemProfileManager {
logger.logWarning("Only one Profile Team exists - there is no Default Profile"); //$NON-NLS-1$
createDefaultPrivateProfile();
}
defaultProfile.setActive(true); // ensure that the default profile is active
}
private void ensureDefaultTeamProfile() {

View file

@ -44,6 +44,7 @@
* rewrote getSubSystemConfigurationsBySystemType to be able to delay the creation (and loading) of subsystem configurations
* David Dykstal (IBM) - [217556] remove service subsystem types
* Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
********************************************************************************/
package org.eclipse.rse.internal.core.model;
@ -620,149 +621,99 @@ public class SystemRegistry implements ISystemRegistry
return newProfile;
}
/**
* Delete a SystemProfile. Prior to physically deleting the profile, we delete all
* the connections it has (first disconnecting if they are connected), and all the subsystems they have.
* <p>
* As well, all the filter pools for this profile are deleted, and subsequently any
* cross references from subsystems in connections in other profiles are removed.
* <p>
* A delete event is fired for every connection deleted.
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#deleteSystemProfile(org.eclipse.rse.core.model.ISystemProfile)
*/
public void deleteSystemProfile(ISystemProfile profile) throws Exception
{
// step 0: load the world!
loadAll(); // force the world into memory!
// step 1: delete subsystems and connections
IHost[] connections = getHostsByProfile(profile);
//SystemConnectionPool pool = getConnectionPool(profile);
for (int idx = 0; idx < connections.length; idx++)
{
deleteHost(connections[idx]);
}
// step 2: bring to life every factory and ask it to delete all filter pools for this profile
if (subsystemConfigurationProxies != null)
{
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
{
ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
if (factory != null)
factory.deletingSystemProfile(profile);
public void deleteSystemProfile(ISystemProfile profile) throws Exception {
ISystemProfileManager manager = getSystemProfileManager();
ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
if (profile != defaultProfile) {
// load everything
loadAll();
// remove connections
IHost[] connections = getHostsByProfile(profile);
for (int idx = 0; idx < connections.length; idx++) {
deleteHost(connections[idx]);
}
// remove filter pools for this profile
if (subsystemConfigurationProxies != null) {
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++) {
ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
if (factory != null) factory.deletingSystemProfile(profile);
}
}
// remove the profile
manager.deleteSystemProfile(profile, true);
// fire events
if (connections.length > 0) { // defect 42112
fireEvent(new SystemResourceChangeEvent(connections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this));
}
fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE, profile, null);
}
// last step... physically blow away the profile...
getSystemProfileManager().deleteSystemProfile(profile, true);
////Listening to Events now
//SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
if (connections.length > 0) // defect 42112
fireEvent(new SystemResourceChangeEvent(connections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this));
fireModelChangeEvent(
ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED,
ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE,
profile, null);
}
/**
* Make or unmake the given profile active.
* If switching to inactive, we force a disconnect for all subsystems of all connections in this profile.
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#setSystemProfileActive(org.eclipse.rse.core.model.ISystemProfile, boolean)
*/
public void setSystemProfileActive(ISystemProfile profile, boolean makeActive)
{
// Test if there are any filter pools in this profile that are referenced by another active profile...
Vector activeReferenceVector = new Vector();
if (!makeActive && (subsystemConfigurationProxies != null))
{
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
{
//if (subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) // don't bother if not yet alive
{
public void setSystemProfileActive(ISystemProfile profile, boolean makeActive) {
ISystemProfileManager manager = getSystemProfileManager();
ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
if (profile != defaultProfile) {
// Test if there are any filter pools in this profile that are referenced by another active profile...
Vector activeReferenceVector = new Vector();
if (!makeActive && (subsystemConfigurationProxies != null)) {
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++) {
ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
if (factory != null)
{
if (factory != null) {
ISubSystem[] activeReferences = factory.testForActiveReferences(profile);
if (activeReferences != null)
for (int jdx = 0; jdx < activeReferences.length; jdx++)
activeReferenceVector.addElement(activeReferences[jdx]);
if (activeReferences != null) for (int jdx = 0; jdx < activeReferences.length; jdx++)
activeReferenceVector.addElement(activeReferences[jdx]);
}
}
}
}
if (activeReferenceVector.size() > 0)
{
//RSEG1069: De-Activativing profile {0} for which there are subsystems containing references to filter pools:
String msg = NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REFS, profile.getName());
RSECorePlugin.getDefault().getLogger().logWarning(msg);
for (int idx = 0; idx < activeReferenceVector.size(); idx++)
{
//\ \ {refname} in connection {1} in profile {2}
ISubSystem activeReference = (ISubSystem) activeReferenceVector.elementAt(idx);
msg = " " + activeReference.getName(); //$NON-NLS-1$
msg += NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REF,
activeReference.getHost().getAliasName(),
activeReference.getSystemProfileName());
if (activeReferenceVector.size() > 0) {
String msg = NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REFS, profile.getName());
RSECorePlugin.getDefault().getLogger().logWarning(msg);
for (int idx = 0; idx < activeReferenceVector.size(); idx++) {
ISubSystem activeReference = (ISubSystem) activeReferenceVector.elementAt(idx);
msg = " " + activeReference.getName(); //$NON-NLS-1$
msg += NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REF, activeReference.getHost().getAliasName(), activeReference.getSystemProfileName());
RSECorePlugin.getDefault().getLogger().logWarning(msg);
}
ISubSystem firstSubSystem = (ISubSystem) activeReferenceVector.elementAt(0);
String connectionName = firstSubSystem.getHost().getSystemProfileName() + "." + firstSubSystem.getHost().getAliasName(); //$NON-NLS-1$
msg = NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED, profile.getName(), connectionName);
RSECorePlugin.getDefault().getLogger().logWarning(msg);
}
ISubSystem firstSubSystem = (ISubSystem) activeReferenceVector.elementAt(0);
String connectionName = firstSubSystem.getHost().getSystemProfileName() + "." + firstSubSystem.getHost().getAliasName(); //$NON-NLS-1$
//RSEG1069: Warning. Profile '%1' should be active. Active connection '%2' contains a reference to it.
msg = NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED, profile.getName(), connectionName);
RSECorePlugin.getDefault().getLogger().logWarning(msg);
//// I think it should be sufficient to log this as warning rather than open a dialog
//SystemMessage sysMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED);
//sysMsg.makeSubstitution(profile.getName(), connectionName);
//SystemMessageDialog msgDlg = new SystemMessageDialog(null, sysMsg);
//msgDlg.open();
}
getSystemProfileManager().makeSystemProfileActive(profile, makeActive);
// To be safe, we tell each subsystem factory about the change in status.
// At a minimum, each factory may have to load the subsystems for connections that
// are suddenly active.
if (subsystemConfigurationProxies != null)
{
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
{
if (subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) // don't bother if not yet alive
{
ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
if (factory != null)
factory.changingSystemProfileActiveStatus(profile, makeActive);
getSystemProfileManager().makeSystemProfileActive(profile, makeActive);
// Each factory may have to load the subsystems for connections that are suddenly active.
if (subsystemConfigurationProxies != null) {
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++) {
if (subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) { // don't bother if not yet alive
ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
if (factory != null) factory.changingSystemProfileActiveStatus(profile, makeActive);
}
}
}
}
IHost[] affectedConnections = getHostsByProfile(profile);
//System.out.println("Affected Connection Count: " + affectedConnections.length);
// delete...
if (!makeActive) // better disconnect all connections before we lose sight of them
{
if ((affectedConnections != null) && (affectedConnections.length > 0))
{
for (int idx = 0; idx < affectedConnections.length; idx++)
{
disconnectAllSubSystems(affectedConnections[idx]);
// notify the hosts that are affected by this change
IHost[] affectedConnections = getHostsByProfile(profile);
// delete...
if (!makeActive) { // better disconnect all connections before we lose sight of them
if ((affectedConnections != null) && (affectedConnections.length > 0)) {
for (int idx = 0; idx < affectedConnections.length; idx++) {
disconnectAllSubSystems(affectedConnections[idx]);
}
SystemResourceChangeEvent event = new SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this);
fireEvent(event);
}
SystemResourceChangeEvent event = new SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this);
}
// add...
else if ((affectedConnections != null) && (affectedConnections.length > 0)) {
SystemResourceChangeEvent event = new SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_ADD_MANY, this);
fireEvent(event);
}
fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE, profile, null);
}
// add...
else if ((affectedConnections != null) && (affectedConnections.length > 0))
{
SystemResourceChangeEvent event = new SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_ADD_MANY, this);
fireEvent(event);
}
////Listening to Events now
//SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
fireModelChangeEvent(
ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED,
ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE,
profile, null);
}
// private profile methods...
@ -2905,7 +2856,7 @@ public class SystemRegistry implements ISystemRegistry
proxies[idx].getSubSystemConfiguration();
}
// step 0_b: force every subsystem of every connection to be active!
// step 0_b: force every subsystem of every connection to be active
IHost[] connections = getHosts();
for (int idx = 0; idx < connections.length; idx++)
getSubSystems(connections[idx]);

View file

@ -1,89 +0,0 @@
/********************************************************************************
* Copyright (c) 2002, 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
********************************************************************************/
package org.eclipse.rse.internal.ui.view.team;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell;
/**
* The action allows users to activate/de-activate a selected profile.
* @deprecated
* TODO: delete this action after next MRI rev, as it will be replaced by
* {@link org.eclipse.rse.internal.ui.view.team.SystemTeamViewActiveProfileAction} and
* {@link org.eclipse.rse.internal.ui.view.team.SystemTeamViewMakeInActiveProfileAction}.
*/
public class SystemTeamViewActiveProfileAction extends SystemBaseAction
{
/**
* Constructor
*/
public SystemTeamViewActiveProfileAction(Shell parent)
{
super(SystemResources.ACTION_PROFILE_ACTIVATE_LABEL,SystemResources.ACTION_PROFILE_ACTIVATE_TOOLTIP,
RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_MAKEPROFILEACTIVE_ID),
parent);
allowOnMultipleSelection(true); // as requested by WSDD team
setContextMenuGroup(ISystemContextMenuConstants.GROUP_CHANGE);
setHelp(RSEUIPlugin.HELPPREFIX+"actnactp"); //$NON-NLS-1$
setChecked(false);
}
/**
* @see SystemBaseAction#updateSelection(IStructuredSelection)
*/
public boolean updateSelection(IStructuredSelection selection)
{
ISystemProfile profile = (ISystemProfile)getFirstSelection();
if (profile == null)
return false;
ISystemProfileManager mgr = SystemProfileManager.getDefault();
// todo... we need to have two actions, one to make active, and one to make inactive.
while (profile != null)
{
setChecked(mgr.isSystemProfileActive(profile.getName()));
profile = (ISystemProfile)getNextSelection();
}
return true;
}
/**
* This is the method called when the user selects this action.
*/
public void run()
{
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISystemProfile profile = (ISystemProfile)getFirstSelection();
boolean check = isChecked();
while (profile != null)
{
sr.setSystemProfileActive(profile, check);
profile = (ISystemProfile)getNextSelection();
}
}
}

View file

@ -12,9 +12,11 @@
*
* Contributors:
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
********************************************************************************/
package org.eclipse.rse.internal.ui.view.team;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemProfile;
@ -28,25 +30,22 @@ import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell;
/**
* The action allows users to activate all selected profiles
*/
public class SystemTeamViewMakeActiveProfileAction extends SystemBaseAction
public class SystemTeamViewMakeActiveProfileAction extends SystemBaseAction
{
/**
* Constructor
*/
public SystemTeamViewMakeActiveProfileAction(Shell parent)
{
super(SystemResources.ACTION_PROFILE_MAKEACTIVE_LABEL,SystemResources.ACTION_PROFILE_MAKEACTIVE_TOOLTIP,
RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_MAKEPROFILEACTIVE_ID),
parent);
allowOnMultipleSelection(true);
public SystemTeamViewMakeActiveProfileAction(Shell parent) {
super(SystemResources.ACTION_PROFILE_MAKEACTIVE_LABEL, SystemResources.ACTION_PROFILE_MAKEACTIVE_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptor(
ISystemIconConstants.ICON_SYSTEM_MAKEPROFILEACTIVE_ID), parent);
allowOnMultipleSelection(true);
setContextMenuGroup(ISystemContextMenuConstants.GROUP_CHANGE);
setHelp(RSEUIPlugin.HELPPREFIX+"ActionMakeActive"); //$NON-NLS-1$
setHelp(RSEUIPlugin.HELPPREFIX + "ActionMakeActive"); //$NON-NLS-1$
}
/**
@ -55,38 +54,38 @@ public class SystemTeamViewMakeActiveProfileAction extends SystemBaseAction
* that every selected profile is already active.
* @see SystemBaseAction#updateSelection(IStructuredSelection)
*/
public boolean updateSelection(IStructuredSelection selection)
{
Object currsel = getFirstSelection();
if (!(currsel instanceof ISystemProfile))
return false;
ISystemProfile profile = (ISystemProfile)currsel;
ISystemProfileManager mgr = SystemProfileManager.getDefault();
boolean allActive = true;
while (profile != null)
{
if (!mgr.isSystemProfileActive(profile.getName()))
allActive = false;
currsel = getNextSelection();
if ((currsel!=null) && !(currsel instanceof ISystemProfile))
return false;
profile = (ISystemProfile)currsel;
}
return !allActive;
public boolean updateSelection(IStructuredSelection selection) {
ISystemProfileManager manager = SystemProfileManager.getDefault();
ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
boolean enabled = false;
if (!getSelection().isEmpty()) {
enabled = true;
Object currsel = getFirstSelection();
while (currsel != null && enabled) {
if (currsel instanceof ISystemProfile) {
ISystemProfile profile = (ISystemProfile) currsel;
if (profile.isActive() || profile == defaultProfile) {
enabled = false;
}
} else {
enabled = false;
}
currsel = getNextSelection();
}
}
return enabled;
}
/**
* This is the method called when the user selects this action.
* It walks through all the selected profiles and make them all active
*/
public void run()
{
public void run() {
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISystemProfile profile = (ISystemProfile)getFirstSelection();
while (profile != null)
{
ISystemProfile profile = (ISystemProfile) getFirstSelection();
while (profile != null) {
sr.setSystemProfileActive(profile, true);
profile = (ISystemProfile)getNextSelection();
}
}
profile = (ISystemProfile) getNextSelection();
}
}
}

View file

@ -12,9 +12,11 @@
*
* Contributors:
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
********************************************************************************/
package org.eclipse.rse.internal.ui.view.team;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemProfile;
@ -28,25 +30,22 @@ import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell;
/**
* The action allows users to de-activate all selected profiles
*/
public class SystemTeamViewMakeInActiveProfileAction extends SystemBaseAction
public class SystemTeamViewMakeInActiveProfileAction extends SystemBaseAction
{
/**
* Constructor
*/
public SystemTeamViewMakeInActiveProfileAction(Shell parent)
{
super(SystemResources.ACTION_PROFILE_MAKEINACTIVE_LABEL,SystemResources.ACTION_PROFILE_MAKEINACTIVE_TOOLTIP,
RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_MAKEPROFILEINACTIVE_ID),
parent);
allowOnMultipleSelection(true);
public SystemTeamViewMakeInActiveProfileAction(Shell parent) {
super(SystemResources.ACTION_PROFILE_MAKEINACTIVE_LABEL, SystemResources.ACTION_PROFILE_MAKEINACTIVE_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptor(
ISystemIconConstants.ICON_SYSTEM_MAKEPROFILEINACTIVE_ID), parent);
allowOnMultipleSelection(true);
setContextMenuGroup(ISystemContextMenuConstants.GROUP_CHANGE);
setHelp(RSEUIPlugin.HELPPREFIX+"ActionMakeInactive"); //$NON-NLS-1$
setHelp(RSEUIPlugin.HELPPREFIX + "ActionMakeInactive"); //$NON-NLS-1$
}
/**
@ -55,40 +54,38 @@ public class SystemTeamViewMakeInActiveProfileAction extends SystemBaseAction
* that every selected profile is already inactive.
* @see SystemBaseAction#updateSelection(IStructuredSelection)
*/
public boolean updateSelection(IStructuredSelection selection)
{
Object currsel = getFirstSelection();
if (!(currsel instanceof ISystemProfile))
return false;
ISystemProfile profile = (ISystemProfile)currsel;
ISystemProfileManager mgr = SystemProfileManager.getDefault();
boolean allInActive = true;
while (profile != null)
{
if (mgr.isSystemProfileActive(profile.getName()))
allInActive = false;
currsel = getNextSelection();
if ((currsel!=null) && !(currsel instanceof ISystemProfile))
return false;
profile = (ISystemProfile)currsel;
}
return !allInActive;
public boolean updateSelection(IStructuredSelection selection) {
ISystemProfileManager manager = SystemProfileManager.getDefault();
ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
boolean enabled = false;
if (!getSelection().isEmpty()) {
enabled = true;
Object currsel = getFirstSelection();
while (currsel != null && enabled) {
if (currsel instanceof ISystemProfile) {
ISystemProfile profile = (ISystemProfile) currsel;
if (!profile.isActive() || profile == defaultProfile) {
enabled = false;
}
} else {
enabled = false;
}
currsel = getNextSelection();
}
}
return enabled;
}
/**
* This is the method called when the user selects this action.
* It walks through all the selected profiles and make them all inactive
*/
public void run()
{
// TODO: test if attempting to disable all profiles, and issue an error
// that at least one needs to be active. Or, at least a warning.
public void run() {
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISystemProfile profile = (ISystemProfile)getFirstSelection();
while (profile != null)
{
ISystemProfile profile = (ISystemProfile) getFirstSelection();
while (profile != null) {
sr.setSystemProfileActive(profile, false);
profile = (ISystemProfile)getNextSelection();
}
}
profile = (ISystemProfile) getNextSelection();
}
}
}

View file

@ -19,6 +19,7 @@
* Rupen Mardirossian (IBM) - [187741] Implemented the handleDoubleClick method
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
********************************************************************************/
package org.eclipse.rse.internal.ui.view.team;
@ -1026,31 +1027,29 @@ public class SystemTeamViewPart
{
return true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.ui.ISystemDeleteTarget#canDelete()
*/
public boolean canDelete()
{
boolean ok = true;
IStructuredSelection selection= getStructuredSelection();
Iterator elements= selection.iterator();
ISystemProfileManager mgr = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager();
int nbrActiveProfiles = mgr.getActiveSystemProfiles().length;
int activeCount = 0;
while (ok && elements.hasNext())
{
Object currObj = elements.next();
if (!(currObj instanceof ISystemProfile))
{
ok = false;
//System.out.println("selection: "+currObj.getClass().getName());
public boolean canDelete() {
boolean ok = false;
IStructuredSelection selection = getStructuredSelection();
if (!selection.isEmpty()) {
ok = true;
ISystemProfileManager manager = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager();
ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
for (Iterator z = selection.iterator(); z.hasNext() && ok;) {
Object object = z.next();
if (object instanceof ISystemProfile) {
ISystemProfile profile = (ISystemProfile) object;
if (profile == defaultProfile) {
ok = false;
}
} else {
ok = false;
}
}
else if (!mgr.isSystemProfileActive(((ISystemProfile)currObj).getName()))
activeCount++;
}
if (ok && (activeCount == nbrActiveProfiles)) // attempting to delete all active profiles?
ok = false; // don't allow that!
//System.out.println("Inside canDelete: "+ok);
return ok;
}

View file

@ -20,9 +20,12 @@
* David Dykstal (IBM) - [191130] use new getRemoteSystemsProject(boolean) call
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
* David Dykstal (IBM) - [cleanup] formatted
********************************************************************************/
package org.eclipse.rse.internal.ui.view.team;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
@ -34,6 +37,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
@ -51,31 +55,26 @@ import org.eclipse.rse.ui.view.ISystemPropertyConstants;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.views.properties.PropertyDescriptor;
/**
* Adapter for displaying and processing SystemProfile objects in tree views, such as
* the Team view.
*/
public class SystemTeamViewProfileAdapter
extends AbstractSystemViewAdapter
{
public class SystemTeamViewProfileAdapter extends AbstractSystemViewAdapter {
private boolean actionsCreated = false;
private Hashtable categoriesByProfile = new Hashtable();
private Hashtable categoriesByProfile = new Hashtable();
// context menu actions for profiles...
protected SystemTeamViewActiveProfileAction activeProfileAction;
protected SystemTeamViewMakeActiveProfileAction makeProfileActiveAction;
protected SystemTeamViewMakeInActiveProfileAction makeProfileInactiveAction;
protected SystemCommonRenameAction renameAction;
protected SystemTeamViewMakeInActiveProfileAction makeProfileInactiveAction;
protected SystemCommonRenameAction renameAction;
protected SystemCommonDeleteAction deleteAction;
protected SystemProfileNameCopyAction copyProfileAction;
// -------------------
// property descriptors
// -------------------
private static PropertyDescriptor[] propertyDescriptorArray = null;
/**
* Returns any actions that should be contributed to the popup menu
* for the given element.
@ -84,86 +83,63 @@ public class SystemTeamViewProfileAdapter
* @param shell Shell of viewer
* @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
*/
public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
{
if (!actionsCreated)
createActions();
boolean privateProfileStillExists = (RSECorePlugin.getTheSystemProfileManager().getDefaultPrivateSystemProfile() != null);
copyProfileAction.setProfile((ISystemProfile)selection.getFirstElement());
if (activeProfileAction != null)
{
activeProfileAction.setEnabled(!privateProfileStillExists);
menu.add(ISystemContextMenuConstants.GROUP_CHANGE,activeProfileAction);
public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup) {
if (!actionsCreated) {
createActions();
}
else
{
menu.add(ISystemContextMenuConstants.GROUP_CHANGE,makeProfileActiveAction);
menu.add(ISystemContextMenuConstants.GROUP_CHANGE,makeProfileInactiveAction);
}
menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE,copyProfileAction);
menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE,deleteAction);
menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE,renameAction);
copyProfileAction.setProfile((ISystemProfile) selection.getFirstElement());
menu.add(ISystemContextMenuConstants.GROUP_CHANGE, makeProfileActiveAction);
menu.add(ISystemContextMenuConstants.GROUP_CHANGE, makeProfileInactiveAction);
menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE, copyProfileAction);
menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE, deleteAction);
menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE, renameAction);
}
private void createActions()
{
// activate profile action...
// TODO: Delete the activeProfileAction logic when we have another mri rev, and can use the new actions.
if (SystemResources.ACTION_PROFILE_MAKEACTIVE_LABEL.equals("test")) //$NON-NLS-1$
activeProfileAction = new SystemTeamViewActiveProfileAction(getShell());
else
{
makeProfileActiveAction = new SystemTeamViewMakeActiveProfileAction(getShell());
makeProfileInactiveAction = new SystemTeamViewMakeInActiveProfileAction(getShell());
}
copyProfileAction = new SystemProfileNameCopyAction(getShell());
private void createActions() {
makeProfileActiveAction = new SystemTeamViewMakeActiveProfileAction(getShell());
makeProfileInactiveAction = new SystemTeamViewMakeInActiveProfileAction(getShell());
copyProfileAction = new SystemProfileNameCopyAction(getShell());
deleteAction = new SystemCommonDeleteAction(getShell(),getTeamViewPart());
deleteAction.setHelp(RSEUIPlugin.HELPPREFIX+"actndlpr"); //$NON-NLS-1$
deleteAction.setDialogHelp(RSEUIPlugin.HELPPREFIX+"ddltprfl"); //$NON-NLS-1$
deleteAction = new SystemCommonDeleteAction(getShell(), getTeamViewPart());
deleteAction.setHelp(RSEUIPlugin.HELPPREFIX + "actndlpr"); //$NON-NLS-1$
deleteAction.setDialogHelp(RSEUIPlugin.HELPPREFIX + "ddltprfl"); //$NON-NLS-1$
deleteAction.setPromptLabel(SystemResources.RESID_DELETE_PROFILES_PROMPT);
renameAction = new SystemCommonRenameAction(getShell(),getTeamViewPart());
renameAction.setHelp(RSEUIPlugin.HELPPREFIX+"actnrnpr"); //$NON-NLS-1$
renameAction.setDialogSingleSelectionHelp(RSEUIPlugin.HELPPREFIX+"drnsprfl"); //$NON-NLS-1$
renameAction.setDialogMultiSelectionHelp(RSEUIPlugin.HELPPREFIX+"drnmprfl"); //$NON-NLS-1$
renameAction.setSingleSelectPromptLabel(SystemResources.RESID_SIMPLE_RENAME_PROFILE_PROMPT_LABEL,
SystemResources.RESID_SIMPLE_RENAME_PROFILE_PROMPT_TIP);
renameAction = new SystemCommonRenameAction(getShell(), getTeamViewPart());
renameAction.setHelp(RSEUIPlugin.HELPPREFIX + "actnrnpr"); //$NON-NLS-1$
renameAction.setDialogSingleSelectionHelp(RSEUIPlugin.HELPPREFIX + "drnsprfl"); //$NON-NLS-1$
renameAction.setDialogMultiSelectionHelp(RSEUIPlugin.HELPPREFIX + "drnmprfl"); //$NON-NLS-1$
renameAction.setSingleSelectPromptLabel(SystemResources.RESID_SIMPLE_RENAME_PROFILE_PROMPT_LABEL, SystemResources.RESID_SIMPLE_RENAME_PROFILE_PROMPT_TIP);
renameAction.setMultiSelectVerbiage(SystemResources.RESID_MULTI_RENAME_PROFILE_VERBIAGE);
actionsCreated = true;
actionsCreated = true;
}
/**
* Returns an image descriptor for the image. More efficient than getting the image.
* @param element The element for which an image is desired
*/
public ImageDescriptor getImageDescriptor(Object element)
{
ISystemProfile profile = (ISystemProfile)element;
public ImageDescriptor getImageDescriptor(Object element) {
ISystemProfile profile = (ISystemProfile) element;
if (RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName()))
return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROFILE_ACTIVE_ID);
return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROFILE_ACTIVE_ID);
else
return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROFILE_ID);
return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROFILE_ID);
}
/**
* Return the team view part
*/
private SystemTeamViewPart getTeamViewPart()
{
SystemTeamView viewer = (SystemTeamView)getViewer();
//System.out.println("Team view part set? " + (viewer != null));
private SystemTeamViewPart getTeamViewPart() {
SystemTeamView viewer = (SystemTeamView) getViewer();
return viewer.getTeamViewPart();
}
/**
* Return the label for this object
*/
public String getText(Object element)
{
return ((ISystemProfile)element).getName();
public String getText(Object element) {
return ((ISystemProfile) element).getName();
}
/**
@ -171,70 +147,62 @@ public class SystemTeamViewProfileAdapter
* <p>
* Called by common rename and delete actions.
*/
public String getName(Object element)
{
return ((ISystemProfile)element).getName();
public String getName(Object element) {
return ((ISystemProfile) element).getName();
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
*/
public String getAbsoluteName(Object element)
{
return ((ISystemProfile)element).getName();
public String getAbsoluteName(Object element) {
return ((ISystemProfile) element).getName();
}
/**
* Return the type label for this object
*/
public String getType(Object element)
{
public String getType(Object element) {
return SystemViewResources.RESID_PROPERTY_PROFILE_TYPE_VALUE;
}
}
/**
* Return the string to display in the status line when the given object is selected.
* We return:
* Connection: name - Host name: hostName - Description: description
*/
public String getStatusLineText(Object element)
{
ISystemProfile profile = (ISystemProfile)element;
public String getStatusLineText(Object element) {
ISystemProfile profile = (ISystemProfile) element;
boolean active = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName());
return getType(element) + ": " + profile.getName() + ", " + //$NON-NLS-1$ //$NON-NLS-2$
SystemViewResources.RESID_PROPERTY_PROFILESTATUS_LABEL + ": " + //$NON-NLS-1$
(active ? SystemViewResources.RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL : SystemViewResources.RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL);
SystemViewResources.RESID_PROPERTY_PROFILESTATUS_LABEL + ": " + //$NON-NLS-1$
(active ? SystemViewResources.RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL : SystemViewResources.RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL);
}
/**
* Return the parent of this object. We return the RemoteSystemsConnections project
*/
public Object getParent(Object element)
{
public Object getParent(Object element) {
return SystemResourceManager.getRemoteSystemsProject(false);
}
/**
* Return the children of this profile.
*/
public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
{
ISystemProfile profile = (ISystemProfile)element;
public Object[] getChildren(IAdaptable element, IProgressMonitor monitor) {
ISystemProfile profile = (ISystemProfile) element;
return getCategoryChildren(profile);
}
/**
* Given a profile, return all the category children for it. If this child objects have yet to be created,
* create them now.
*/
public SystemTeamViewCategoryNode[] getCategoryChildren(ISystemProfile profile)
{
SystemTeamViewCategoryNode[] children = (SystemTeamViewCategoryNode[])categoriesByProfile.get(profile);
if (children == null)
{
public SystemTeamViewCategoryNode[] getCategoryChildren(ISystemProfile profile) {
SystemTeamViewCategoryNode[] children = (SystemTeamViewCategoryNode[]) categoriesByProfile.get(profile);
if (children == null) {
children = new SystemTeamViewCategoryNode[2]; //5];
for (int idx=0; idx<children.length; idx++)
for (int idx = 0; idx < children.length; idx++)
children[idx] = new SystemTeamViewCategoryNode(profile);
children[0].setLabel(SystemResources.RESID_TEAMVIEW_CATEGORY_CONNECTIONS_LABEL);
children[0].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_CONNECTIONS_TOOLTIP);
@ -255,152 +223,146 @@ public class SystemTeamViewProfileAdapter
children[3].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_COMPILECMDS_TOOLTIP);
children[3].setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_COMPILE_ID));
children[3].setMementoHandle(SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS);
*/
*/
/*
children[4].setLabel(SystemResources.RESID_TEAMVIEW_CATEGORY_TARGETS_LABEL);
children[4].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_TARGETS_TOOLTIP);
children[4].setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemConstants.ICON_SYSTEM_TARGET_ID));
children[4].setMementoHandle(SystemTeamViewCategoryNode.MEMENTO_TARGETS);
*/
categoriesByProfile.put(profile, children);
}
return children;
return children;
}
/**
* Given a profile and memento handle, return the appropriate category node. This is used when
* restoring the expansion and selection state of the team view.
*/
public SystemTeamViewCategoryNode restoreCategory(ISystemProfile profile, String mementoHandle)
{
public SystemTeamViewCategoryNode restoreCategory(ISystemProfile profile, String mementoHandle) {
SystemTeamViewCategoryNode[] children = getCategoryChildren(profile);
SystemTeamViewCategoryNode category = null;
for (int idx=0; (category==null) && (idx<2); idx++)
{
if (children[idx].getMementoHandle().equals(mementoHandle))
category = children[idx];
for (int idx = 0; (category == null) && (idx < 2); idx++) {
if (children[idx].getMementoHandle().equals(mementoHandle)) category = children[idx];
}
return category;
}
/**
* Return true if this profile has children. We return true.
*/
public boolean hasChildren(IAdaptable element)
{
return true;
public boolean hasChildren(IAdaptable element) {
return true;
}
// Property sheet descriptors defining all the properties we expose in the Property Sheet
// Property sheet descriptors defining all the properties we expose in the Property Sheet
/**
* Return our unique property descriptors, which getPropertyDescriptors adds to the common properties.
*/
protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors()
{
if (propertyDescriptorArray == null)
{
propertyDescriptorArray = new PropertyDescriptor[1];
int idx = 0;
// status
propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_ACTIVE,SystemViewResources.RESID_PROPERTY_PROFILESTATUS_LABEL, SystemViewResources.RESID_PROPERTY_PROFILESTATUS_TOOLTIP);
}
protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors() {
if (propertyDescriptorArray == null) {
propertyDescriptorArray = new PropertyDescriptor[1];
int idx = 0;
// status
propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_ACTIVE, SystemViewResources.RESID_PROPERTY_PROFILESTATUS_LABEL,
SystemViewResources.RESID_PROPERTY_PROFILESTATUS_TOOLTIP);
}
return propertyDescriptorArray;
}
/**
* Returns the current value for the named property.
* The parent handles P_TEXT and P_TYPE only, and we augment that here.
* @param key - the name of the property as named by its property descriptor
* @return the current value of the property
*/
public Object internalGetPropertyValue(Object key)
{
String name = (String)key;
ISystemProfile profile = (ISystemProfile)propertySourceInput;
if (name.equals(ISystemPropertyConstants.P_IS_ACTIVE))
{
public Object internalGetPropertyValue(Object key) {
String name = (String) key;
ISystemProfile profile = (ISystemProfile) propertySourceInput;
if (name.equals(ISystemPropertyConstants.P_IS_ACTIVE)) {
boolean active = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName());
if (active)
return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL;
else
return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL;
}
else
return null;
}
return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL;
} else
return null;
}
// FOR COMMON DELETE ACTIONS
/**
* Return true if this object is deletable by the user. If so, when selected,
* the Edit->Delete menu item will be enabled.
*/
public boolean canDelete(Object element)
{
public boolean canDelete(Object element) {
boolean ok = true;
if (!(element instanceof ISystemProfile))
{
if (!(element instanceof ISystemProfile)) {
ok = false;
//System.out.println("selection: "+currObj.getClass().getName());
} else {
ISystemProfile profile = (ISystemProfile) element;
ISystemProfileManager manager = RSECorePlugin.getTheSystemProfileManager();
ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
if (profile == defaultProfile) {
ok = false;
}
}
return ok;
}
}
/**
* Perform the delete action.
*/
public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception
{
public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception {
boolean ok = true;
RSECorePlugin.getTheSystemRegistry().deleteSystemProfile((ISystemProfile)element);
RSECorePlugin.getTheSystemRegistry().deleteSystemProfile((ISystemProfile) element);
return ok;
}
// FOR COMMON RENAME ACTIONS
/**
* Return true if this object is renamable by the user. If so, when selected,
* the Rename popup menu item will be enabled.
*/
public boolean canRename(Object element)
{
public boolean canRename(Object element) {
boolean ok = true;
if (!(element instanceof ISystemProfile))
ok = false;
if (!(element instanceof ISystemProfile)) ok = false;
return ok;
}
}
/**
* Perform the rename action.
*/
public boolean doRename(Shell shell, Object element, String newName, IProgressMonitor monitor) throws Exception
{
boolean ok = true;
RSECorePlugin.getTheSystemRegistry().renameSystemProfile((ISystemProfile)element, newName);
public boolean doRename(Shell shell, Object element, String newName, IProgressMonitor monitor) throws Exception {
boolean ok = true;
RSECorePlugin.getTheSystemRegistry().renameSystemProfile((ISystemProfile) element, newName);
return ok;
}
}
/**
* Return a validator for verifying the new name is correct.
*/
public ISystemValidator getNameValidator(Object element)
{
String[] nameArray = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().getSystemProfileNames();
Vector names = new Vector(nameArray.length);
names.addAll(Arrays.asList(nameArray));
ISystemValidator validator = new ValidatorProfileName(names);
public ISystemValidator getNameValidator(Object element) {
String[] nameArray = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().getSystemProfileNames();
Vector names = new Vector(nameArray.length);
names.addAll(Arrays.asList(nameArray));
ISystemValidator validator = new ValidatorProfileName(names);
return validator;
}
/**
* Parent override.
* <p>
* Form and return a new canonical (unique) name for this object, given a candidate for the new
* name. This is called by the generic multi-rename dialog to test that all new names are unique.
* To do this right, sometimes more than the raw name itself is required to do uniqueness checking.
* <p>
* Returns profile.connectionName, upperCased
*/
public String getCanonicalNewName(Object element, String newName)
{
return newName.toUpperCase();
}
}
/**
* Parent override.
* <p>
* Form and return a new canonical (unique) name for this object, given a candidate for the new
* name. This is called by the generic multi-rename dialog to test that all new names are unique.
* To do this right, sometimes more than the raw name itself is required to do uniqueness checking.
* <p>
* Returns profile.connectionName, upperCased
*/
public String getCanonicalNewName(Object element, String newName) {
return newName.toUpperCase();
}
// ------------------------------------------------------------
// METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
@ -408,19 +370,18 @@ public class SystemTeamViewProfileAdapter
/**
* Return what to save to disk to identify this element in the persisted list of expanded elements.
*/
public String getMementoHandle(Object element)
{
ISystemProfile profile = (ISystemProfile)element;
return profile.getName();
public String getMementoHandle(Object element) {
ISystemProfile profile = (ISystemProfile) element;
return profile.getName();
}
/**
* Return a short string to uniquely identify the type of resource.
*/
public String getMementoHandleKey(Object element)
{
public String getMementoHandleKey(Object element) {
return ISystemMementoConstants.MEMENTO_KEY_PROFILE;
}
/**
* This is a local RSE artifact so returning false
*