mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
Bug 436390 - Fix new connection status.
Change-Id: Ib90b507abb7c8c1b8bcb4a2d91e06de988103172 Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
d2d6c71758
commit
0df67c311c
2 changed files with 38 additions and 27 deletions
|
@ -19,8 +19,8 @@ ConnectionsPreferencePage_Open=Open
|
||||||
ConnectionsPreferencePage_Remote_Services=Remote Services:
|
ConnectionsPreferencePage_Remote_Services=Remote Services:
|
||||||
ConnectionsPreferencePage_Remove=Remove
|
ConnectionsPreferencePage_Remove=Remove
|
||||||
ConnectionsPreferencePage_Status=Status
|
ConnectionsPreferencePage_Status=Status
|
||||||
ConnectionsPreferencePage_There_are_unsaved_changes=There are unsaved changes. Do you wish to save the changes before proceeding?
|
ConnectionsPreferencePage_There_are_unsaved_changes=There are unsaved changes that must be saved before proceeding. Do you wish to save the changes?
|
||||||
ConnectionsPreferencePage_This_connection_contains_unsaved_changes=This connection contains unsaved changes. Do you wish to save before opening the connection?
|
ConnectionsPreferencePage_This_connection_contains_unsaved_changes=This connection contains unsaved changes which must be saved before the connection can be opened. Do you wish to save the changes?
|
||||||
ConnectionsPreferencePage_User=User
|
ConnectionsPreferencePage_User=User
|
||||||
LocalUIConnectionManager_0=Connection Error
|
LocalUIConnectionManager_0=Connection Error
|
||||||
LocalUIConnectionManager_1=Could not open connection
|
LocalUIConnectionManager_1=Could not open connection
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnText(Object element, int columnIndex) {
|
public String getColumnText(Object element, int columnIndex) {
|
||||||
IRemoteConnection connection = (IRemoteConnection) element;
|
IRemoteConnection connection = getOriginalIfClean((IRemoteConnection) element);
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return connection.isOpen() ? Messages.ConnectionsPreferencePage_open : Messages.ConnectionsPreferencePage_closed;
|
return connection.isOpen() ? Messages.ConnectionsPreferencePage_open : Messages.ConnectionsPreferencePage_closed;
|
||||||
|
@ -214,17 +214,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
||||||
if (fIsDirty) {
|
if (fIsDirty) {
|
||||||
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions, null,
|
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions, null,
|
||||||
Messages.ConnectionsPreferencePage_There_are_unsaved_changes, MessageDialog.QUESTION, new String[] {
|
Messages.ConnectionsPreferencePage_There_are_unsaved_changes, MessageDialog.QUESTION, new String[] {
|
||||||
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
|
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
|
||||||
switch (dialog.open()) {
|
if (dialog.open() == 1) {
|
||||||
case 0:
|
|
||||||
performOk();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
performDefaults();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
performOk();
|
||||||
}
|
}
|
||||||
IRemoteUIConnectionWizard wizard = fUIConnectionManager.getConnectionWizard(getShell());
|
IRemoteUIConnectionWizard wizard = fUIConnectionManager.getConnectionWizard(getShell());
|
||||||
if (wizard != null) {
|
if (wizard != null) {
|
||||||
|
@ -293,7 +287,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
||||||
fConnectionTable.addMouseListener(new MouseListener() {
|
fConnectionTable.addMouseListener(new MouseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseDoubleClick(MouseEvent e) {
|
public void mouseDoubleClick(MouseEvent e) {
|
||||||
if (fSelectedConnection != null && !fSelectedConnection.isOpen()) {
|
if (fSelectedConnection != null && !getOriginalIfClean(fSelectedConnection).isOpen()) {
|
||||||
editConnection();
|
editConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,7 +368,12 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
||||||
*/
|
*/
|
||||||
private void editConnection() {
|
private void editConnection() {
|
||||||
if (fSelectedConnection != null) {
|
if (fSelectedConnection != null) {
|
||||||
IRemoteConnectionWorkingCopy copy = fSelectedConnection.getWorkingCopy();
|
IRemoteConnectionWorkingCopy copy;
|
||||||
|
if (fSelectedConnection instanceof IRemoteConnectionWorkingCopy) {
|
||||||
|
copy = (IRemoteConnectionWorkingCopy) fSelectedConnection;
|
||||||
|
} else {
|
||||||
|
copy = fSelectedConnection.getWorkingCopy();
|
||||||
|
}
|
||||||
IRemoteUIConnectionWizard wizard = fUIConnectionManager.getConnectionWizard(getShell());
|
IRemoteUIConnectionWizard wizard = fUIConnectionManager.getConnectionWizard(getShell());
|
||||||
if (wizard != null) {
|
if (wizard != null) {
|
||||||
wizard.setConnection(copy);
|
wizard.setConnection(copy);
|
||||||
|
@ -451,6 +450,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
||||||
fConnectionTable.deselectAll();
|
fConnectionTable.deselectAll();
|
||||||
fSelectedConnection = null;
|
fSelectedConnection = null;
|
||||||
}
|
}
|
||||||
|
updateEnablement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -484,7 +484,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
||||||
private void toggleConnection() {
|
private void toggleConnection() {
|
||||||
TableItem[] items = fConnectionTable.getSelection();
|
TableItem[] items = fConnectionTable.getSelection();
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
IRemoteConnection conn = (IRemoteConnection) items[0].getData();
|
IRemoteConnection conn = getOriginalIfClean((IRemoteConnection) items[0].getData());
|
||||||
if (conn.isOpen()) {
|
if (conn.isOpen()) {
|
||||||
conn.close();
|
conn.close();
|
||||||
} else {
|
} else {
|
||||||
|
@ -494,17 +494,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
||||||
if (wc.isDirty()) {
|
if (wc.isDirty()) {
|
||||||
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions,
|
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions,
|
||||||
null, Messages.ConnectionsPreferencePage_This_connection_contains_unsaved_changes,
|
null, Messages.ConnectionsPreferencePage_This_connection_contains_unsaved_changes,
|
||||||
MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
|
MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
|
||||||
IDialogConstants.CANCEL_LABEL }, 0);
|
if (dialog.open() == 1) {
|
||||||
switch (dialog.open()) {
|
|
||||||
case 0:
|
|
||||||
wc.save();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wc.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IRemoteUIConnectionManager mgr = RemoteUIServices.getRemoteUIServices(conn.getRemoteServices())
|
IRemoteUIConnectionManager mgr = RemoteUIServices.getRemoteUIServices(conn.getRemoteServices())
|
||||||
|
@ -551,15 +545,32 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
||||||
fOpenButton.setEnabled(false);
|
fOpenButton.setEnabled(false);
|
||||||
fCloseButton.setEnabled(false);
|
fCloseButton.setEnabled(false);
|
||||||
if (fSelectedConnection != null) {
|
if (fSelectedConnection != null) {
|
||||||
if (!fSelectedConnection.isOpen()) {
|
IRemoteConnection conn = getOriginalIfClean(fSelectedConnection);
|
||||||
|
if (!conn.isOpen()) {
|
||||||
fEditButton
|
fEditButton
|
||||||
.setEnabled((fSelectedConnection.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_EDIT_CONNECTIONS) != 0);
|
.setEnabled((conn.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_EDIT_CONNECTIONS) != 0);
|
||||||
fRemoveButton
|
fRemoveButton
|
||||||
.setEnabled((fSelectedConnection.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_REMOVE_CONNECTIONS) != 0);
|
.setEnabled((conn.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_REMOVE_CONNECTIONS) != 0);
|
||||||
fOpenButton.setEnabled(true);
|
fOpenButton.setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
fCloseButton.setEnabled(true);
|
fCloseButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the original connection if the working copy is not dirty
|
||||||
|
*
|
||||||
|
* @param conn
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private IRemoteConnection getOriginalIfClean(IRemoteConnection conn) {
|
||||||
|
if (conn instanceof IRemoteConnectionWorkingCopy) {
|
||||||
|
IRemoteConnectionWorkingCopy wc = (IRemoteConnectionWorkingCopy) conn;
|
||||||
|
if (!wc.isDirty()) {
|
||||||
|
return wc.getOriginal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue