--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Thu Dec 17 11:28:11 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Thu Dec 17 15:43:43 2009 -0600
@@ -250,19 +250,26 @@
return null;
}
- /* (non-Javadoc)
- * @see com.nokia.carbide.remoteconnections.registry.IConnectionStore#storeConnections()
- */
public void storeConnections() {
try {
OutputStream os = new FileOutputStream(getConnectionStorageFile());
- Writer.writeToXML(os, connectionToConnectedServices.keySet());
+ Writer.writeToXML(os, getNonDynamicConnections());
}
catch (Exception e) {
RemoteConnectionsActivator.log(Messages.getString("Registry.ConnectionStoreError"), e); //$NON-NLS-1$
}
}
+ private Collection<IConnection> getNonDynamicConnections() {
+ List<IConnection> nonDynamicConnections = new ArrayList<IConnection>();
+ for (IConnection connection : connectionToConnectedServices.keySet()) {
+ if (!(connection instanceof IConnection2) ||
+ !((IConnection2) connection).isDynamic())
+ nonDynamicConnections.add(connection);
+ }
+ return nonDynamicConnections;
+ }
+
public void addConnectionStoreChangedListener(IConnectionsManagerListener listener) {
if (listeners == null)
listeners = new ListenerList<IConnectionsManagerListener>();
@@ -522,6 +529,8 @@
}
public IConnection getDefaultConnection() {
+ if (defaultConnection == null)
+ pickNewDefaultConnection();
return defaultConnection;
}
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Thu Dec 17 11:28:11 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Thu Dec 17 15:43:43 2009 -0600
@@ -18,9 +18,73 @@
package com.nokia.carbide.remoteconnections.settings.ui;
+import java.io.File;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeNode;
+import org.eclipse.jface.viewers.TreeNodeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.IWizardContainer2;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.osgi.framework.Version;
+
import com.nokia.carbide.remoteconnections.Messages;
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
-import com.nokia.carbide.remoteconnections.interfaces.*;
+import com.nokia.carbide.remoteconnections.interfaces.AbstractConnectedService;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
+import com.nokia.carbide.remoteconnections.interfaces.IConnection;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionType;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionTypeProvider;
+import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider;
+import com.nokia.carbide.remoteconnections.interfaces.IService;
+import com.nokia.carbide.remoteconnections.interfaces.IService2;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus;
@@ -28,35 +92,12 @@
import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller;
import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller.IPackageContents;
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
-import com.nokia.cpp.internal.api.utils.core.*;
+import com.nokia.cpp.internal.api.utils.core.Check;
+import com.nokia.cpp.internal.api.utils.core.FileUtils;
+import com.nokia.cpp.internal.api.utils.core.HostOS;
+import com.nokia.cpp.internal.api.utils.core.Pair;
import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.jface.wizard.IWizardContainer2;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.osgi.framework.Version;
-
-import java.io.File;
-import java.io.InputStream;
-import java.text.MessageFormat;
-import java.util.*;
-import java.util.List;
-
public class ConnectionSettingsPage extends WizardPage {
public final class Tester extends Thread {
@@ -178,10 +219,11 @@
});
deviceOSComboViewer.setContentProvider(new ArrayContentProvider());
deviceOSComboViewer.setLabelProvider(new LabelProvider() {
+ @SuppressWarnings("unchecked")
@Override
public String getText(Object element) {
Check.checkState(element instanceof Pair);
- Pair pair = (Pair) element;
+ Pair<String, Version> pair = (Pair) element;
return MessageFormat.format("{0} {1}", pair.first, pair.second); //$NON-NLS-1$
}
});
@@ -456,6 +498,9 @@
GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true);
label.setLayoutData(gd);
}
+ else if (settingsWizard.isConnectionToEditDynamic()) {
+ disableControls(settingsUI);
+ }
// update services list
Collection<IService> compatibleServices =
@@ -487,6 +532,14 @@
((IWizardContainer2) getWizard().getContainer()).updateSize();
}
+ private void disableControls(Control[] controls) {
+ for (Control control : controls) {
+ if (control instanceof Composite)
+ disableControls(((Composite) control).getChildren());
+ control.setEnabled(false);
+ }
+ }
+
private synchronized void initializeInstallerData() {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionTypePage.java Thu Dec 17 11:28:11 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionTypePage.java Thu Dec 17 15:43:43 2009 -0600
@@ -75,6 +75,8 @@
setPageComplete(validatePage());
}
});
+ boolean canEditConnection = !settingsWizard.isConnectionToEditDynamic();
+ nameText.setEnabled(canEditConnection);
Label label = new Label(container, SWT.NONE);
label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
@@ -120,6 +122,7 @@
}
});
viewer.getList().select(getCurrentTypeIndex());
+ viewer.getList().setEnabled(canEditConnection);
connectionTypeDescLabel = new Label(container, SWT.WRAP);
connectionTypeDescLabel.setText(getConnectionTypeDescription());
@@ -158,12 +161,13 @@
return getConnectionType().getDescription();
}
+ @SuppressWarnings("unchecked")
private int getCurrentTypeIndex() {
IConnection connectionToEdit = settingsWizard.getConnectionToEdit();
if (connectionToEdit != null) {
Object input = viewer.getInput();
if (input != null) {
- Collection<IConnectionType> connectionTypes = (Collection<IConnectionType>) input;
+ Collection<IConnectionType> connectionTypes = (Collection) input;
for (int i = 0; i < connectionTypes.size(); i++) {
IConnectionType connectionType = (IConnectionType) viewer.getElementAt(i);
if (connectionToEdit.getConnectionType().equals(connectionType))
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/SettingsWizard.java Thu Dec 17 11:28:11 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/SettingsWizard.java Thu Dec 17 15:43:43 2009 -0600
@@ -18,16 +18,23 @@
package com.nokia.carbide.remoteconnections.settings.ui;
-import com.nokia.carbide.remoteconnections.Messages;
-import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
-import com.nokia.carbide.remoteconnections.interfaces.*;
-import com.nokia.carbide.remoteconnections.internal.registry.Registry;
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
-import org.eclipse.jface.wizard.*;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
-import java.text.MessageFormat;
-import java.util.*;
+import com.nokia.carbide.remoteconnections.Messages;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
+import com.nokia.carbide.remoteconnections.interfaces.IConnection;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionType;
+import com.nokia.carbide.remoteconnections.interfaces.IService;
+import com.nokia.carbide.remoteconnections.internal.IConnection2;
+import com.nokia.carbide.remoteconnections.internal.registry.Registry;
/**
* Main wizard class for hosting new and edit connection settings UI
@@ -79,6 +86,11 @@
public IConnection getConnectionToEdit() {
return connectionToEdit;
}
+
+ public boolean isConnectionToEditDynamic() {
+ return connectionToEdit instanceof IConnection2 &&
+ ((IConnection2) connectionToEdit).isDynamic();
+ }
public IService getServiceToRestrict() {
return serviceToRestrict;
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java Thu Dec 17 11:28:11 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java Thu Dec 17 15:43:43 2009 -0600
@@ -18,36 +18,76 @@
package com.nokia.carbide.remoteconnections.view;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.LegacyActionTools;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.TreeColumnViewerLabelProvider;
+import org.eclipse.jface.viewers.TreeNode;
+import org.eclipse.jface.viewers.TreeNodeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.viewers.TreeViewerEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
import com.nokia.carbide.remoteconnections.Messages;
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
-import com.nokia.carbide.remoteconnections.interfaces.*;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
+import com.nokia.carbide.remoteconnections.interfaces.IConnection;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus;
import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionsManagerListener;
+import com.nokia.carbide.remoteconnections.internal.IConnection2;
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard;
import com.nokia.cpp.internal.api.utils.core.TextUtils;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.part.ViewPart;
-
-import java.util.*;
-import java.util.List;
-
/**
* The view part for Remote connections
*/
+@SuppressWarnings("deprecation")
public class ConnectionsView extends ViewPart {
private TreeViewer viewer;
@@ -145,10 +185,11 @@
super(viewer);
editor = new TextCellEditor((Composite) viewer.getControl(), SWT.BORDER);
}
-
+
@Override
protected boolean canEdit(Object element) {
- if (((TreeNode) element).getValue() instanceof IConnection)
+ Object object = ((TreeNode) element).getValue();
+ if (object instanceof IConnection && !isDynamicConnection(object))
return true;
return false;
}
@@ -541,7 +582,8 @@
actions.add(action);
action.setEnabled(!Registry.instance().getConnectionTypes().isEmpty());
- action = new Action(Messages.getString("ConnectionsView.EditActionLabel"), CONNECTION_EDIT_IMGDESC) { //$NON-NLS-1$
+ String editLabel = Messages.getString("ConnectionsView.EditActionLabel");
+ action = new Action(editLabel, CONNECTION_EDIT_IMGDESC) { //$NON-NLS-1$
@Override
public void run() {
ISelection selection = viewer.getSelection();
@@ -571,6 +613,11 @@
viewer.editElement(node, 0);
}
}
+
+ @Override
+ public boolean isEnabled() {
+ return selectionCanBeEdited();
+ }
};
action.setId(RENAME_ACTION);
action.setAccelerator(SWT.F2);
@@ -617,6 +664,11 @@
Registry.instance().storeConnections();
}
}
+
+ @Override
+ public boolean isEnabled() {
+ return selectionCanBeEdited();
+ }
};
action.setAccelerator(SWT.DEL);
action.setId(DELETE_ACTION);
@@ -754,5 +806,16 @@
return getFirstInUseStatus(connection) != null;
}
+ private boolean isDynamicConnection(Object object) {
+ return object instanceof IConnection2 && ((IConnection2) object).isDynamic();
+ }
+
+ private boolean selectionCanBeEdited() {
+ ISelection selection = viewer.getSelection();
+ if (selection.isEmpty())
+ return false;
+ TreeNode node = (TreeNode) ((IStructuredSelection) selection).getFirstElement();
+ return !isDynamicConnection(node.getValue());
+ }
}