Lines 15-37
Link Here
|
15 |
import org.eclipse.ecf.presence.ui.MultiRosterAccount; |
15 |
import org.eclipse.ecf.presence.ui.MultiRosterAccount; |
16 |
import org.eclipse.jface.dialogs.Dialog; |
16 |
import org.eclipse.jface.dialogs.Dialog; |
17 |
import org.eclipse.jface.dialogs.IDialogConstants; |
17 |
import org.eclipse.jface.dialogs.IDialogConstants; |
18 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
18 |
import org.eclipse.jface.viewers.*; |
19 |
import org.eclipse.jface.viewers.ComboViewer; |
|
|
20 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
21 |
import org.eclipse.jface.viewers.IStructuredSelection; |
22 |
import org.eclipse.jface.viewers.LabelProvider; |
23 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
24 |
import org.eclipse.swt.SWT; |
19 |
import org.eclipse.swt.SWT; |
25 |
import org.eclipse.swt.events.ModifyEvent; |
20 |
import org.eclipse.swt.events.ModifyEvent; |
26 |
import org.eclipse.swt.events.ModifyListener; |
21 |
import org.eclipse.swt.events.ModifyListener; |
27 |
import org.eclipse.swt.layout.GridData; |
22 |
import org.eclipse.swt.layout.GridData; |
28 |
import org.eclipse.swt.layout.GridLayout; |
23 |
import org.eclipse.swt.layout.GridLayout; |
29 |
import org.eclipse.swt.widgets.Button; |
24 |
import org.eclipse.swt.widgets.*; |
30 |
import org.eclipse.swt.widgets.Composite; |
|
|
31 |
import org.eclipse.swt.widgets.Control; |
32 |
import org.eclipse.swt.widgets.Label; |
33 |
import org.eclipse.swt.widgets.Shell; |
34 |
import org.eclipse.swt.widgets.Text; |
35 |
|
25 |
|
36 |
public class AddContactDialog extends Dialog { |
26 |
public class AddContactDialog extends Dialog { |
37 |
|
27 |
|
Lines 51-56
Link Here
|
51 |
|
41 |
|
52 |
private Object input; |
42 |
private Object input; |
53 |
|
43 |
|
|
|
44 |
private MultiRosterAccount defaultRosterAccount; |
45 |
|
54 |
public AddContactDialog(Shell parentShell) { |
46 |
public AddContactDialog(Shell parentShell) { |
55 |
super(parentShell); |
47 |
super(parentShell); |
56 |
} |
48 |
} |
Lines 58-78
Link Here
|
58 |
private void addListeners() { |
50 |
private void addListeners() { |
59 |
accountText.addModifyListener(new ModifyListener() { |
51 |
accountText.addModifyListener(new ModifyListener() { |
60 |
public void modifyText(ModifyEvent e) { |
52 |
public void modifyText(ModifyEvent e) { |
61 |
okBtn.setEnabled(selection != null |
53 |
okBtn.setEnabled(selection != null && !accountText.getText().equals("")); //$NON-NLS-1$ |
62 |
&& !accountText.getText().equals("")); //$NON-NLS-1$ |
|
|
63 |
} |
54 |
} |
64 |
}); |
55 |
}); |
65 |
|
56 |
|
66 |
accountsViewer |
57 |
accountsViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
67 |
.addSelectionChangedListener(new ISelectionChangedListener() { |
58 |
public void selectionChanged(SelectionChangedEvent e) { |
68 |
public void selectionChanged(SelectionChangedEvent e) { |
59 |
IStructuredSelection iss = (IStructuredSelection) e.getSelection(); |
69 |
IStructuredSelection iss = (IStructuredSelection) e |
60 |
selection = ((MultiRosterAccount) iss.getFirstElement()).getPresenceContainerAdapter(); |
70 |
.getSelection(); |
61 |
okBtn.setEnabled(!accountText.getText().equals("")); //$NON-NLS-1$ |
71 |
selection = ((MultiRosterAccount) iss.getFirstElement()) |
62 |
} |
72 |
.getPresenceContainerAdapter(); |
63 |
}); |
73 |
okBtn.setEnabled(!accountText.getText().equals("")); //$NON-NLS-1$ |
|
|
74 |
} |
75 |
}); |
76 |
} |
64 |
} |
77 |
|
65 |
|
78 |
protected void configureShell(Shell newShell) { |
66 |
protected void configureShell(Shell newShell) { |
Lines 91-108
Link Here
|
91 |
parent.setLayout(new GridLayout(2, false)); |
79 |
parent.setLayout(new GridLayout(2, false)); |
92 |
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); |
80 |
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); |
93 |
|
81 |
|
94 |
new Label(parent, SWT.BEGINNING) |
82 |
new Label(parent, SWT.BEGINNING).setText(Messages.AddContactDialog_UserID); |
95 |
.setText(Messages.AddContactDialog_UserID); |
|
|
96 |
accountText = new Text(parent, SWT.SINGLE | SWT.BORDER); |
83 |
accountText = new Text(parent, SWT.SINGLE | SWT.BORDER); |
97 |
accountText.setLayoutData(data); |
84 |
accountText.setLayoutData(data); |
98 |
|
85 |
|
99 |
new Label(parent, SWT.BEGINNING) |
86 |
new Label(parent, SWT.BEGINNING).setText(Messages.AddContactDialog_Alias); |
100 |
.setText(Messages.AddContactDialog_Alias); |
|
|
101 |
aliasText = new Text(parent, SWT.SINGLE | SWT.BORDER); |
87 |
aliasText = new Text(parent, SWT.SINGLE | SWT.BORDER); |
102 |
aliasText.setLayoutData(data); |
88 |
aliasText.setLayoutData(data); |
103 |
|
89 |
|
104 |
new Label(parent, SWT.BEGINNING) |
90 |
new Label(parent, SWT.BEGINNING).setText(Messages.AddContactDialog_Account); |
105 |
.setText(Messages.AddContactDialog_Account); |
|
|
106 |
accountsViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.BORDER); |
91 |
accountsViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.BORDER); |
107 |
accountsViewer.getControl().setLayoutData(data); |
92 |
accountsViewer.getControl().setLayoutData(data); |
108 |
accountsViewer.setContentProvider(new ArrayContentProvider()); |
93 |
accountsViewer.setContentProvider(new ArrayContentProvider()); |
Lines 113-118
Link Here
|
113 |
} |
98 |
} |
114 |
}); |
99 |
}); |
115 |
accountsViewer.setInput(input); |
100 |
accountsViewer.setInput(input); |
|
|
101 |
accountsViewer.setSelection(new StructuredSelection(defaultRosterAccount)); |
102 |
selection = defaultRosterAccount.getPresenceContainerAdapter(); |
116 |
|
103 |
|
117 |
addListeners(); |
104 |
addListeners(); |
118 |
|
105 |
|
Lines 142-145
Link Here
|
142 |
this.input = input; |
129 |
this.input = input; |
143 |
} |
130 |
} |
144 |
|
131 |
|
|
|
132 |
public void setDefaultRosterAccount(MultiRosterAccount account) { |
133 |
this.defaultRosterAccount = account; |
134 |
} |
145 |
} |
135 |
} |