Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 79567
Collapse All | Expand All

(-)plugin.properties (-14 / +12 lines)
Lines 71-88 Link Here
71
#OpenWizardAction
71
#OpenWizardAction
72
72
73
#RefreshFromLocalAction
73
#RefreshFromLocalAction
74
UNLOAD_MEMORY								= Free up memory...
74
UNLOAD_MEMORY								= Unload profiling data...
75
RELOAD_LOCAL_FILE                           = Reload the project from local files
75
RELOAD_INFORMATION                          = You chose to unload from memory the profiling data.Any view displaying this data will also be reset.\nDo you want to continue?
76
RELOAD_LOCAL_FILE_TOOLTIP                   = Reload the project from local files
76
FREE_MEMORY_QUESTION						= The following data is not yet saved to the file system.\nPlease select the profiling data you want to save.
77
RELOAD_QUESTION                             = You have chosen not to save modified files. This action will remove any unsaved resources from the view. Are you sure you want to do this?
77
FREE_MEMORY_QUESTION1						= You chose to save only some of the modified profiling data.Unsaved data will be discarded after being unload from memory.\nDo you want to continue?
78
FREE_MEMORY_QUESTION						= This action will remove any unsaved resources.\nPlease select the resources to save:
79
RELOAD_INFORMATION_TITLE                    = Confirm 'Free up memory...' selection
80
RELOAD_INFORMATION                          = Selecting 'Free up memory...' will remove all the resources from memory, and from the views.
81
78
82
#RefreshTreeACtion
79
#RefreshTreeACtion
83
REFRESH                                     = &Refresh
80
REFRESH                                     = &Refresh
84
REFRESH_THE_TREE                            = Refresh the tree
81
REFRESH_THE_TREE                            = Refresh the tree
85
REFRESH_TREE_TOOLTIP                        = Refresh tree
82
REFRESH_TREE_TOOLTIP                        = Refresh tree
83
CONFIRM_REFRESH_MSG                         = Refresh selected resource?
84
STR_REFRESH_RES_SYS                         = &Refresh contents from the file system
85
STR_NOT_REFRESH_RES                         = &Do not refresh from the file system
86
86
87
#SaveTOLocalAction
87
#SaveTOLocalAction
88
SAVE                                        = Save
88
SAVE                                        = Save
Lines 152-162 Link Here
152
152
153
#LogProcessWizardPage
153
#LogProcessWizardPage
154
ENABLE_LOGGING                              = Ena&ble logging
154
ENABLE_LOGGING                              = Ena&ble logging
155
ADD_AGENT                                   = &New agent:
155
ADD_LOG_AGENT                               = Add Agent
156
ADD_AGENT_BUTTON                            = Add A&gent
156
LOG_AGENT_LABEL                             = Agent name:
157
REMOVE_AGENT                                = &Remove Agent
158
#DEFAULT_AGENT                              = Default Logging Agent
159
#LOGGING_AGENT                              = Logging Agents:
160
157
161
#NewFolderWizard
158
#NewFolderWizard
162
#CONTAINER                                  = Folder
159
#CONTAINER                                  = Folder
Lines 236-242 Link Here
236
#preferences
233
#preferences
237
STR_PREF_HOST_NODE                          = Defa&ult Hosts:
234
STR_PREF_HOST_NODE                          = Defa&ult Hosts:
238
STR_PREF_HOST_IP                            = &Host name or IP address:
235
STR_PREF_HOST_IP                            = &Host name or IP address:
239
STR_PREF_ADD                                = &Add
236
STR_PREF_ADD                                = &Add...
240
STR_PREF_NODE_PAGE                          = Hosts
237
STR_PREF_NODE_PAGE                          = Hosts
241
STR_PREF_TRACE                              = Profiling and Logging
238
STR_PREF_TRACE                              = Profiling and Logging
242
STR_PREF_TRACE_VIEW                         = Appearance
239
STR_PREF_TRACE_VIEW                         = Appearance
Lines 374-380 Link Here
374
ATTACH_INFO_MESSAGE                         = IWAT0021I To collect data, the agent must be monitoring the application. \nFrom the pop-up menu of the agent in the Profiling Monitor view, select 'Start Monitoring'.
371
ATTACH_INFO_MESSAGE                         = IWAT0021I To collect data, the agent must be monitoring the application. \nFrom the pop-up menu of the agent in the Profiling Monitor view, select 'Start Monitoring'.
375
ATTACH_MESSAGE_CHECKBOX_MSG                 = Do not show this message again.
372
ATTACH_MESSAGE_CHECKBOX_MSG                 = Do not show this message again.
376
SHOW_PROFILE_TIPS                           = &Show profiling tips
373
SHOW_PROFILE_TIPS                           = &Show profiling tips
377
SHOW_RELOAD_MESSAGE                         = S&how 'Free up memory...' warning
374
SHOW_RELOAD_MESSAGE                         = S&how Unload profiling data message
378
PROFILING_TIP_TITLE                         = Profiling Tips
375
PROFILING_TIP_TITLE                         = Profiling Tips
379
STR_ERROR_FOLDER_CREATION                   = IWAT0023E Unable to create the target folder. Make sure the path is correct.
376
STR_ERROR_FOLDER_CREATION                   = IWAT0023E Unable to create the target folder. Make sure the path is correct.
380
STR_FOLDER_CREATION_MSG                     = Directory %1 does not exist. Do you want to create it?
377
STR_FOLDER_CREATION_MSG                     = Directory %1 does not exist. Do you want to create it?
Lines 491-496 Link Here
491
488
492
489
493
RAC_PORT_TEXT                               = A&gent Controller port:
490
RAC_PORT_TEXT                               = A&gent Controller port:
491
STR_ADD_HOST                                = Add host
494
492
495
STR_INVALID_BOUND_VALUE                     = Invalid Boundary Class Depth value, it must be positive integer.
493
STR_INVALID_BOUND_VALUE                     = Invalid Boundary Class Depth value, it must be positive integer.
496
STR_INVALID_COLLECTION_VALUE                = Value must be positive interger.
494
STR_INVALID_COLLECTION_VALUE                = Value must be positive interger.
(-)src/org/eclipse/hyades/trace/ui/internal/actions/RefreshFromLocalAction.java (-36 / +37 lines)
Lines 13-19 Link Here
13
package org.eclipse.hyades.trace.ui.internal.actions;
13
package org.eclipse.hyades.trace.ui.internal.actions;
14
14
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.Arrays;
17
import java.util.Iterator;
16
import java.util.Iterator;
18
import java.util.List;
17
import java.util.List;
19
18
Lines 21-27 Link Here
21
import org.eclipse.emf.ecore.resource.Resource;
20
import org.eclipse.emf.ecore.resource.Resource;
22
import org.eclipse.hyades.models.hierarchy.TRCAgent;
21
import org.eclipse.hyades.models.hierarchy.TRCAgent;
23
import org.eclipse.hyades.models.hierarchy.util.HierarchyResourceSetImpl;
22
import org.eclipse.hyades.models.hierarchy.util.HierarchyResourceSetImpl;
24
import org.eclipse.hyades.trace.internal.ui.PDContentProvider;
25
import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer;
23
import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer;
26
import org.eclipse.hyades.trace.internal.ui.TraceConstants;
24
import org.eclipse.hyades.trace.internal.ui.TraceConstants;
27
import org.eclipse.hyades.trace.ui.IDeleteListener;
25
import org.eclipse.hyades.trace.ui.IDeleteListener;
Lines 37-42 Link Here
37
import org.eclipse.jface.viewers.IStructuredContentProvider;
35
import org.eclipse.jface.viewers.IStructuredContentProvider;
38
import org.eclipse.jface.viewers.IStructuredSelection;
36
import org.eclipse.jface.viewers.IStructuredSelection;
39
import org.eclipse.jface.viewers.Viewer;
37
import org.eclipse.jface.viewers.Viewer;
38
import org.eclipse.swt.widgets.Display;
40
import org.eclipse.swt.widgets.Shell;
39
import org.eclipse.swt.widgets.Shell;
41
import org.eclipse.ui.IWorkbenchWindow;
40
import org.eclipse.ui.IWorkbenchWindow;
42
import org.eclipse.ui.PlatformUI;
41
import org.eclipse.ui.PlatformUI;
Lines 55-68 Link Here
55
  public RefreshFromLocalAction(INavigator viewer)
54
  public RefreshFromLocalAction(INavigator viewer)
56
  {
55
  {
57
	super(viewer.getViewer(), UIPlugin.getResourceString("UNLOAD_MEMORY"));
56
	super(viewer.getViewer(), UIPlugin.getResourceString("UNLOAD_MEMORY"));
58
	setDescription(UIPlugin.getResourceString("RELOAD_LOCAL_FILE"));
57
	setDescription(UIPlugin.getResourceString("UNLOAD_MEMORY"));
59
	fViewer = viewer;
58
	fViewer = viewer;
60
59
61
	PlatformUI.getWorkbench().getHelpSystem().setHelp(
60
	PlatformUI.getWorkbench().getHelpSystem().setHelp(
62
		this,
61
		this,
63
		UIPlugin.getPluginId()+".refl0000");
62
		UIPlugin.getPluginId()+".refl0000");
64
	
63
	
65
	setToolTipText(UIPlugin.getResourceString("RELOAD_LOCAL_FILE_TOOLTIP"));	
64
	setToolTipText(UIPlugin.getResourceString("UNLOAD_MEMORY"));	
66
  }
65
  }
67
  
66
  
68
  public void run()
67
  public void run()
Lines 76-82 Link Here
76
	
75
	
77
	if (UIPlugin.getDefault().getPreferenceStore().getBoolean(TraceConstants.RELOAD_INFO)) {
76
	if (UIPlugin.getDefault().getPreferenceStore().getBoolean(TraceConstants.RELOAD_INFO)) {
78
		MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, 
77
		MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, 
79
				UIPlugin.getResourceString("RELOAD_INFORMATION_TITLE"), //$NON-NLS-1$
78
				UIPlugin.getResourceString("TRACE_MSG"), //$NON-NLS-1$
80
				UIPlugin.getResourceString("RELOAD_INFORMATION"), //$NON-NLS-1$
79
				UIPlugin.getResourceString("RELOAD_INFORMATION"), //$NON-NLS-1$
81
				UIPlugin.getResourceString("ATTACH_MESSAGE_CHECKBOX_MSG"), //$NON-NLS-1$
80
				UIPlugin.getResourceString("ATTACH_MESSAGE_CHECKBOX_MSG"), //$NON-NLS-1$
82
				false, UIPlugin.getDefault().getPreferenceStore(),
81
				false, UIPlugin.getDefault().getPreferenceStore(),
Lines 113-164 Link Here
113
		
112
		
114
		ListSelectionDialog dlg =
113
		ListSelectionDialog dlg =
115
			new ListSelectionDialog(
114
			new ListSelectionDialog(
116
					fViewer.getViewSite().getShell(),
115
					Display.getCurrent().getActiveShell(),
117
					listArray,
116
					listArray,
118
					contentProvider,
117
					contentProvider,
119
					new SimpleLayout(null).getLabelProvider(),
118
					new SimpleLayout(null).getLabelProvider(),
120
					UIPlugin.getResourceString("FREE_MEMORY_QUESTION"));
119
					UIPlugin.getResourceString("FREE_MEMORY_QUESTION"));
121
		dlg.setInitialSelections(listArray);
120
		dlg.setInitialSelections(listArray);
122
		dlg.setTitle(UIPlugin.getResourceString("UNLOAD_MEMORY"));
121
		dlg.setTitle(UIPlugin.getResourceString("TRACE_MSG"));
123
		
122
		
124
		int result = dlg.open();	
123
		int result = dlg.open();	
125
		if(result == ListSelectionDialog.CANCEL)
124
		if(result == ListSelectionDialog.CANCEL)
126
			return;	
125
			return;	
127
		
126
		
128
		if(!Arrays.asList(dlg.getResult()).isEmpty())
127
		Object[] selections = dlg.getResult();
128
		if(listArray.length != selections.length)
129
		{
129
		{
130
			try{
131
				SaveAction saveLogs = new SaveAction(fViewer);
132
				saveLogs.run(result);
133
			}catch (Exception e) {
134
				HyadesUIPlugin.logError(e);
135
			}
136
		}else{
137
			String title = UIPlugin.getResourceString("TRACE_MSG");	
130
			String title = UIPlugin.getResourceString("TRACE_MSG");	
138
			String msg = UIPlugin.getResourceString("RELOAD_QUESTION");	
131
			String msg = UIPlugin.getResourceString("FREE_MEMORY_QUESTION1");	
139
			
132
			
140
			if(! MessageDialog.openQuestion(fViewer.getViewSite().getShell(), title, msg))
133
			if(! MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), title, msg))
141
				return;			
134
				return;			
142
		}
135
		}
136
		
137
		try{
138
			SaveAction saveAction = new SaveAction(fViewer);
139
			saveAction.finishSaving(selections);
140
		}catch (Exception e) {
141
			HyadesUIPlugin.logError(e);
142
		}
143
	}		
143
	}		
144
	
144
		
145
	ProfileEvent event = new ProfileEvent();
146
	event.setSource(ResourcesPlugin.getWorkspace().getRoot());
147
	
148
	handleResources();
145
	handleResources();
149
	
146
	
150
	if(!(fViewer instanceof PDProjectExplorer))	
147
	if(!(fViewer instanceof PDProjectExplorer))	
151
	{	
148
	{	
149
		ProfileEvent event = new ProfileEvent();
150
		event.setSource(ResourcesPlugin.getWorkspace().getRoot());		
152
		event.setType(ProfileEvent.REFRESH_LOG_NAVIGATOR);
151
		event.setType(ProfileEvent.REFRESH_LOG_NAVIGATOR);
153
		UIPlugin.getDefault().notifyProfileEventListener(event);		
152
		UIPlugin.getDefault().notifyProfileEventListener(event);		
154
	}
153
	}
155
	
154
	else
156
	event.setType(ProfileEvent.REFRESH_PD_EXPLORER);		
155
		fViewer.getViewer().refresh();	
157
	UIPlugin.getDefault().notifyProfileEventListener(event);
156
  } 
158
	
157
  
159
  }  
160
  /**
158
  /**
161
   * @param list
159
   * 
160
   * @param onlyModified
161
   * @return
162
   */
162
   */
163
  protected List getProcessProxies(boolean onlyModified) 
163
  protected List getProcessProxies(boolean onlyModified) 
164
  {
164
  {
Lines 175-191 Link Here
175
					if(!list.contains(agent.getAgentProxy().getProcessProxy()))
175
					if(!list.contains(agent.getAgentProxy().getProcessProxy()))
176
						list.add(agent.getAgentProxy().getProcessProxy());
176
						list.add(agent.getAgentProxy().getProcessProxy());
177
				} catch (Exception e) {
177
				} catch (Exception e) {
178
					// TODO: handle exception
179
				}
178
				}
180
			}
179
			}
181
		}
180
		}
182
	}
181
	}
183
	return list;
182
	return list;
184
  }
183
  }
184
 
185
  /**
185
  /**
186
  * 
186
   * 
187
  */
187
   */
188
189
  public void selectionChanged(IStructuredSelection selection)
188
  public void selectionChanged(IStructuredSelection selection)
190
  {
189
  {
191
	setEnabled(isEnabled());
190
	setEnabled(isEnabled());
Lines 205-213 Link Here
205
  }
204
  }
206
  
205
  
207
  protected void handleResources(){
206
  protected void handleResources(){
208
  	
207
  	  
209
  	PDContentProvider.resetMonitors();
210
  	
211
	Object[] resources = HierarchyResourceSetImpl.getInstance().getResources().toArray();
208
	Object[] resources = HierarchyResourceSetImpl.getInstance().getResources().toArray();
212
	for (int idx=0;idx < resources.length;idx++) 
209
	for (int idx=0;idx < resources.length;idx++) 
213
	{
210
	{
Lines 217-230 Link Here
217
			for(int i=0;i<elements.length;i++)
214
			for(int i=0;i<elements.length;i++)
218
			{
215
			{
219
				Object obj = elements[i];
216
				Object obj = elements[i];
217
				
220
218
221
				List deletelist = UIPlugin.getDefault().getDeleteListeners();
219
				List deletelist = UIPlugin.getDefault().getDeleteListeners();
222
				for(int j=0; j<deletelist.size();j++)
220
				for(int j=0; j<deletelist.size();j++)
223
				{
221
				{
224
					((IDeleteListener)deletelist.get(j)).deregister(obj);
222
					((IDeleteListener)deletelist.get(j)).deregister(obj);
225
				}
223
				}
226
224
				
227
				element.unload();
225
				if(obj instanceof TRCAgent)
226
				{					
227
					element.unload();
228
				}
228
			}
229
			}
229
		}
230
		}
230
	}
231
	}
(-)src/org/eclipse/hyades/trace/ui/internal/actions/RefreshTreeAction.java (-3 / +127 lines)
Lines 12-22 Link Here
12
12
13
package org.eclipse.hyades.trace.ui.internal.actions;
13
package org.eclipse.hyades.trace.ui.internal.actions;
14
14
15
import java.util.List;
16
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.emf.ecore.resource.Resource;
19
import org.eclipse.hyades.models.hierarchy.util.HierarchyResourceSetImpl;
20
import org.eclipse.hyades.trace.internal.ui.PDContentProvider;
15
import org.eclipse.hyades.trace.internal.ui.PDPluginImages;
21
import org.eclipse.hyades.trace.internal.ui.PDPluginImages;
22
import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer;
23
import org.eclipse.hyades.trace.ui.IDeleteListener;
24
import org.eclipse.hyades.trace.ui.ProfileEvent;
16
import org.eclipse.hyades.trace.ui.UIPlugin;
25
import org.eclipse.hyades.trace.ui.UIPlugin;
17
import org.eclipse.hyades.ui.internal.navigator.INavigator;
26
import org.eclipse.hyades.ui.internal.navigator.INavigator;
27
import org.eclipse.jface.dialogs.IDialogConstants;
28
import org.eclipse.jface.dialogs.MessageDialog;
18
import org.eclipse.jface.viewers.ISelectionChangedListener;
29
import org.eclipse.jface.viewers.ISelectionChangedListener;
19
import org.eclipse.jface.viewers.IStructuredSelection;
30
import org.eclipse.jface.viewers.IStructuredSelection;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.events.SelectionAdapter;
33
import org.eclipse.swt.events.SelectionEvent;
34
import org.eclipse.swt.events.SelectionListener;
35
import org.eclipse.swt.layout.GridLayout;
36
import org.eclipse.swt.widgets.Button;
37
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Control;
39
import org.eclipse.swt.widgets.Shell;
20
import org.eclipse.ui.PlatformUI;
40
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.ui.actions.SelectionProviderAction;
41
import org.eclipse.ui.actions.SelectionProviderAction;
22
42
Lines 27-33 Link Here
27
public class RefreshTreeAction extends SelectionProviderAction
47
public class RefreshTreeAction extends SelectionProviderAction
28
								implements ISelectionChangedListener
48
								implements ISelectionChangedListener
29
{
49
{
30
  private INavigator fViewer;
50
  class RefreshResourceDialog extends MessageDialog {
51
	
52
		private boolean refreshContent = false;
53
		private Button radio1;
54
		private Button radio2;
55
	
56
		RefreshResourceDialog(Shell parentShell) {
57
			super(
58
				parentShell,
59
				UIPlugin.getResourceString("TRACE_MSG"),
60
				null,
61
			// accept the default window icon
62
			UIPlugin.getResourceString("CONFIRM_REFRESH_MSG"),
63
				MessageDialog.QUESTION,
64
				new String[] {
65
					IDialogConstants.YES_LABEL,
66
					IDialogConstants.NO_LABEL },
67
				0);
68
			// yes is the default
69
		}
70
	
71
		protected Control createCustomArea(Composite parent) {
72
			Composite composite = new Composite(parent, SWT.NONE);
73
			composite.setLayout(new GridLayout());
74
			radio1 = new Button(composite, SWT.RADIO);
75
			radio1.addSelectionListener(selectionListener);
76
			String text1 =
77
				UIPlugin.getResourceString("STR_REFRESH_RES_SYS");
78
			radio1.setText(text1);
79
	
80
			radio2 = new Button(composite, SWT.RADIO);
81
			radio2.addSelectionListener(selectionListener);
82
			String text2 =
83
				UIPlugin.getResourceString("STR_NOT_REFRESH_RES");
84
			radio2.setText(text2);
85
	
86
			// set initial state
87
			radio1.setSelection(refreshContent);
88
			radio2.setSelection(!refreshContent);
89
	
90
			return composite;
91
		}
92
	
93
		private SelectionListener selectionListener = new SelectionAdapter() {
94
			public void widgetSelected(SelectionEvent e) {
95
				Button button = (Button) e.widget;
96
				if (button.getSelection()) {
97
					refreshContent = (button == radio1);
98
				}
99
			}
100
		};
101
	
102
		public boolean getRefreshContent() {
103
			return refreshContent;
104
		}
105
	}
106
107
private INavigator fViewer;
31
108
32
   public RefreshTreeAction(INavigator viewer)
109
   public RefreshTreeAction(INavigator viewer)
33
  {
110
  {
Lines 44-51 Link Here
44
  }  
121
  }  
45
  public void run()
122
  public void run()
46
  {
123
  {
47
		fViewer.getViewer().refresh();
124
		RefreshResourceDialog dlg = new RefreshResourceDialog(fViewer.getViewSite().getShell());
48
  }  
125
		if (dlg.open() != 0)
126
			return;
127
128
		boolean refreshContents = dlg.getRefreshContent();
129
		
130
		if(refreshContents)
131
		{
132
		  	PDContentProvider.resetMonitors();
133
		  	
134
			Object[] resources = HierarchyResourceSetImpl.getInstance().getResources().toArray();
135
			for (int idx=0;idx < resources.length;idx++) 
136
			{
137
				Resource element = (Resource) resources[idx];
138
				if(element!=null && element.isLoaded()){
139
					Object[] elements = element.getContents().toArray();
140
					for(int i=0;i<elements.length;i++)
141
					{
142
						Object obj = elements[i];
143
144
						List deletelist = UIPlugin.getDefault().getDeleteListeners();
145
						for(int j=0; j<deletelist.size();j++)
146
						{
147
							((IDeleteListener)deletelist.get(j)).deregister(obj);
148
						}
149
						
150
						element.unload();
151
					}
152
				}
153
			}
154
			
155
			if(!(fViewer instanceof PDProjectExplorer))	
156
			{	
157
				ProfileEvent event = new ProfileEvent();
158
				event.setSource(ResourcesPlugin.getWorkspace().getRoot());		
159
				event.setType(ProfileEvent.REFRESH_LOG_NAVIGATOR);
160
				UIPlugin.getDefault().notifyProfileEventListener(event);		
161
			}
162
			else
163
				fViewer.getViewer().refresh();	
164
			
165
		}
166
		else
167
		{
168
			fViewer.getViewer().refresh();
169
		}
170
		
171
  }
172
  
49
  public void selectionChanged(IStructuredSelection selection)
173
  public void selectionChanged(IStructuredSelection selection)
50
  {
174
  {
51
	setEnabled(true);
175
	setEnabled(true);
(-)src/org/eclipse/hyades/trace/ui/internal/actions/SaveAction.java (-69 / +45 lines)
Lines 13-20 Link Here
13
package org.eclipse.hyades.trace.ui.internal.actions;
13
package org.eclipse.hyades.trace.ui.internal.actions;
14
14
15
import java.lang.reflect.InvocationTargetException;
15
import java.lang.reflect.InvocationTargetException;
16
import java.util.ArrayList;
16
import java.util.Arrays;
17
import java.util.Arrays;
17
import java.util.Iterator;
18
18
19
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.resources.IResource;
Lines 31-41 Link Here
31
import org.eclipse.jface.viewers.ISelection;
31
import org.eclipse.jface.viewers.ISelection;
32
import org.eclipse.jface.viewers.ISelectionChangedListener;
32
import org.eclipse.jface.viewers.ISelectionChangedListener;
33
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.swt.widgets.Shell;
34
import org.eclipse.swt.widgets.Display;
35
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.actions.SelectionProviderAction;
36
import org.eclipse.ui.actions.SelectionProviderAction;
37
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
37
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
38
import org.eclipse.ui.dialogs.ListSelectionDialog;
39
38
40
/*
39
/*
41
* CONTEXT_ID save0000 for save to local action
40
* CONTEXT_ID save0000 for save to local action
Lines 45-53 Link Here
45
	
44
	
46
	private INavigator fViewer;
45
	private INavigator fViewer;
47
	private Object[] fSelections;
46
	private Object[] fSelections;
48
	private IResource fResSelection;
49
	private IResource[] fResSelections;
50
	private Shell fShell;
51
47
52
	public SaveAction(INavigator viewer) {
48
	public SaveAction(INavigator viewer) {
53
		super(viewer.getViewer(), UIPlugin.getResourceString("SAVE"));
49
		super(viewer.getViewer(), UIPlugin.getResourceString("SAVE"));
Lines 62-77 Link Here
62
	}
58
	}
63
	public void run() {
59
	public void run() {
64
		String msg = "";
60
		String msg = "";
65
61
		
66
		ISelection sel =
62
		ISelection sel =
67
			(ISelection) getSelection();
63
			(ISelection) getSelection();
68
		if(sel instanceof IStructuredSelection)
64
		if(!(sel instanceof IStructuredSelection))
69
			fSelections = ((IStructuredSelection)sel).toArray();
70
		else
71
			return;
65
			return;
72
		
66
		
73
		fShell = fViewer.getViewSite().getShell();
74
		
75
		if(sel != null && !sel.isEmpty())
67
		if(sel != null && !sel.isEmpty())
76
		{
68
		{
77
			if(((IStructuredSelection)sel).size()==1 && ((IStructuredSelection)sel).getFirstElement()!=null && ((IStructuredSelection)sel).getFirstElement() instanceof IProject){
69
			if(((IStructuredSelection)sel).size()==1 && ((IStructuredSelection)sel).getFirstElement()!=null && ((IStructuredSelection)sel).getFirstElement() instanceof IProject){
Lines 83-168 Link Here
83
75
84
		if (!MessageDialog
76
		if (!MessageDialog
85
			.openQuestion(
77
			.openQuestion(
86
				fShell,
78
				Display.getCurrent().getActiveShell(),
87
				UIPlugin.getResourceString("SAVTOLOCACT_DIA_TITLE"),
79
				UIPlugin.getResourceString("SAVTOLOCACT_DIA_TITLE"),
88
				msg))
80
				msg))
89
			return;
81
			return;
90
		
82
		
91
		finishSaving(sel);
83
		finishSaving(((IStructuredSelection)sel).toArray());
92
		
84
		
93
	}
85
	}
94
	
86
	
95
	public void run(int result) {
87
	public void finishSaving(Object[] selections){		
96
97
		ISelection sel =
98
			(ISelection) getSelection();
99
		if(sel instanceof IStructuredSelection)
100
			fSelections = ((IStructuredSelection)sel).toArray();
101
		else
102
			return;
103
		
104
		fShell = fViewer.getViewSite().getShell();
105
		
106
		if(sel != null && !sel.isEmpty() && result == ListSelectionDialog.OK)
107
		{
108
			finishSaving(sel);
109
		}
110
111
	}
112
113
	protected void finishSaving(ISelection sel){		
114
		int j = 0;
115
		int s = ((IStructuredSelection)sel).size();
116
		fResSelections = new IResource[s];
117
		for (Iterator iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
118
			fResSelections[j++] =
119
				HyadesUtil.getSelectionFolder(iter.next());
120
			
121
		}		
122
123
		fResSelection = fResSelections[0];
124
88
89
		fSelections = selections;
125
		try {
90
		try {
126
			new ProgressMonitorDialog(fShell).run(
91
			new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(
127
				true,
92
				true,
128
				true,
93
				true,
129
				new WorkspaceModifyDelegatingOperation(this));
94
				new WorkspaceModifyDelegatingOperation(this));
130
		} catch (InterruptedException e) {
95
		} catch (InterruptedException e) {
131
			try {
96
			try {
132
				if (fResSelection != null && fResSelection.exists())
97
				
133
					fResSelection.getProject().refreshLocal(
98
				ArrayList folders = new ArrayList();
134
						IResource.DEPTH_INFINITE,
99
				for(int idx=0; idx<fSelections.length; idx++)
135
						null);
100
				{
101
					IResource res = HyadesUtil.getSelectionFolder(fSelections[idx]);
102
					
103
					if (res != null && res.exists() && !folders.contains(res))
104
						folders.add(res);
105
						res.getProject().refreshLocal(
106
							IResource.DEPTH_INFINITE,
107
							null);
108
				}
109
				folders.clear();
110
				fSelections = null;
111
				
112
				return;
113
				
136
			} catch (CoreException exc) {
114
			} catch (CoreException exc) {
137
				exc.printStackTrace();
115
				exc.printStackTrace();
138
			}
116
			}
139
140
			fResSelection = null;
141
			fResSelections = null;
142
143
			return;
144
145
		} catch (InvocationTargetException e) {
117
		} catch (InvocationTargetException e) {
146
			e.printStackTrace();
118
			e.printStackTrace();
147
119
148
			fResSelection = null;
149
			fResSelections = null;
150
151
			return;
152
		}
120
		}
153
121
154
		try {
122
		try {
155
			if (fResSelection != null && fResSelection.exists())
123
			
156
				fResSelection.getProject().refreshLocal(
124
			ArrayList folders = new ArrayList();
157
					IResource.DEPTH_INFINITE,
125
			for(int idx=0; idx<fSelections.length; idx++)
158
					null);
126
			{
127
				IResource res = HyadesUtil.getSelectionFolder(fSelections[idx]);
128
				
129
				if (res != null && res.exists() && !folders.contains(res))					
130
					folders.add(res);
131
					res.getProject().refreshLocal(
132
						IResource.DEPTH_INFINITE,
133
						null);
134
			}
135
			folders.clear();
136
			fSelections = null;
137
			
159
		} catch (CoreException exc) {
138
		} catch (CoreException exc) {
160
			exc.printStackTrace();
139
			exc.printStackTrace();
161
		}
140
		}
162
163
		fResSelection = null;
164
		fResSelections = null;
165
166
	}
141
	}
167
142
168
	protected INavigator getViewer(){
143
	protected INavigator getViewer(){
Lines 173-178 Link Here
173
	}
148
	}
174
	
149
	
175
	public void run(IProgressMonitor monitor) {
150
	public void run(IProgressMonitor monitor) {
151
		
152
		if(fSelections == null)
153
			return; 
154
		
176
		SaveUtil.save(Arrays.asList(fSelections), monitor, fViewer.getID());
155
		SaveUtil.save(Arrays.asList(fSelections), monitor, fViewer.getID());
177
	}
156
	}
178
	
157
	
Lines 183-191 Link Here
183
	public void dispose() {
162
	public void dispose() {
184
		super.dispose();
163
		super.dispose();
185
		fViewer = null;
164
		fViewer = null;
186
		fResSelection = null;
187
		fResSelections = null;
188
		fShell = null;
189
		fSelections = null;
165
		fSelections = null;
190
	}
166
	}
191
}
167
}
(-)src/org/eclipse/hyades/trace/ui/internal/core/TraceHostUI.java (-60 / +158 lines)
Lines 19-38 Link Here
19
import org.eclipse.hyades.trace.ui.UIPlugin;
19
import org.eclipse.hyades.trace.ui.UIPlugin;
20
import org.eclipse.hyades.trace.ui.internal.util.AbstractChangeable;
20
import org.eclipse.hyades.trace.ui.internal.util.AbstractChangeable;
21
import org.eclipse.hyades.ui.util.GridUtil;
21
import org.eclipse.hyades.ui.util.GridUtil;
22
import org.eclipse.jface.dialogs.Dialog;
23
import org.eclipse.jface.dialogs.IDialogConstants;
22
import org.eclipse.jface.preference.IPreferenceStore;
24
import org.eclipse.jface.preference.IPreferenceStore;
25
import org.eclipse.jface.window.Window;
23
import org.eclipse.jface.wizard.WizardPage;
26
import org.eclipse.jface.wizard.WizardPage;
24
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.ModifyEvent;
28
import org.eclipse.swt.events.ModifyEvent;
26
import org.eclipse.swt.events.ModifyListener;
29
import org.eclipse.swt.events.ModifyListener;
27
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionEvent;
28
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.events.SelectionListener;
29
import org.eclipse.swt.events.TraverseEvent;
30
import org.eclipse.swt.events.TraverseListener;
31
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridLayout;
33
import org.eclipse.swt.layout.GridLayout;
33
import org.eclipse.swt.widgets.Button;
34
import org.eclipse.swt.widgets.Button;
34
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Control;
37
import org.eclipse.swt.widgets.Display;
35
import org.eclipse.swt.widgets.Label;
38
import org.eclipse.swt.widgets.Label;
39
import org.eclipse.swt.widgets.Shell;
36
import org.eclipse.swt.widgets.Table;
40
import org.eclipse.swt.widgets.Table;
37
import org.eclipse.swt.widgets.TableItem;
41
import org.eclipse.swt.widgets.TableItem;
38
import org.eclipse.swt.widgets.Text;
42
import org.eclipse.swt.widgets.Text;
Lines 60-65 Link Here
60
64
61
public class TraceHostUI extends AbstractChangeable implements
65
public class TraceHostUI extends AbstractChangeable implements
62
		SelectionListener, ModifyListener {
66
		SelectionListener, ModifyListener {
67
		
63
	private Button _delete;
68
	private Button _delete;
64
69
65
	private Button _add;
70
	private Button _add;
Lines 74-79 Link Here
74
79
75
	private WizardPage _wizardPage = null;
80
	private WizardPage _wizardPage = null;
76
81
82
	class AddHostDialog extends Dialog implements ModifyListener {
83
		private Text _host;
84
		private Text _port;
85
		private String hostStr;
86
        private String portStr;
87
		
88
		public AddHostDialog() {
89
			super(Display.getCurrent().getActiveShell());
90
		}
91
92
		protected void configureShell(Shell shell) {
93
			super.configureShell(shell);
94
			shell.setText(UIPlugin.getResourceString("STR_ADD_HOST"));
95
		}
96
97
		protected Control createDialogArea(Composite parent) {
98
			Composite result = (Composite) super.createDialogArea(parent);
99
100
			GridLayout layout;
101
			GridData data;
102
			Label label;
103
104
			layout = new GridLayout();
105
			layout.numColumns = 2;
106
			result.setLayout(layout);
107
			data = GridUtil.createFill();
108
			data.widthHint = 400;
109
			result.setLayoutData(data);
110
111
			label = new Label(result, SWT.NONE);
112
			label.setText(UIPlugin.getResourceString("STR_PREF_HOST_IP"));
113
			_host = new Text(result, SWT.BORDER);
114
			_host.setLayoutData(GridUtil.createHorizontalFill());
115
			_host.addModifyListener(this);
116
			
117
			label = new Label(result, SWT.NONE);
118
			label.setText(UIPlugin.getResourceString("RAC_PORT_TEXT"));
119
			_port = new Text(result, SWT.BORDER);
120
			_port.setLayoutData(GridUtil.createHorizontalFill());
121
			_port.addModifyListener(this);
122
			
123
			_port.setText(String.valueOf(Constants.CTL_PORT_NUM_SERVER));
124
			_host.setText("localhost");
125
			_host.setFocus();
126
			_host.selectAll();
127
			
128
			return result;
129
		}
130
131
		public void modifyText(ModifyEvent e) {
132
				if (getButton(IDialogConstants.OK_ID) != null)
133
					getButton(IDialogConstants.OK_ID).setEnabled(
134
						_port.getText().trim().length() > 0 && _host.getText().trim().length() > 0);
135
		}
136
137
		protected void okPressed() {
138
			hostStr = _host.getText().trim();
139
			portStr = _port.getText().trim();
140
			super.okPressed();
141
		}
142
		
143
		/*
144
		 * Set the initial Ok button enablement.
145
		 */
146
		protected Control createContents(Composite parent) {
147
			Control result = super.createContents(parent);
148
			getButton(IDialogConstants.OK_ID).setEnabled(_port.getText().trim().length() > 0);
149
			return result;
150
		}
151
152
		/**
153
		 * @return Returns the hostStr.
154
		 */
155
		public String getHost() {
156
			return hostStr;
157
		}
158
159
		/**
160
		 * @return Returns the portStr.
161
		 */
162
		public String getPort() {
163
			return portStr;
164
		}
165
	}
166
	
77
	/**
167
	/**
78
	 * TraceOptionsUI constructor comment.
168
	 * TraceOptionsUI constructor comment.
79
	 */
169
	 */
Lines 91-102 Link Here
91
	 * PM)
181
	 * PM)
92
	 */
182
	 */
93
	public void addHost() {
183
	public void addHost() {
94
		addHost(_host.getText().trim() + ":" + _port.getText().trim());
184
		
95
		_host.setText("");
185
		AddHostDialog dialog = new AddHostDialog();
96
		_port.setText(String.valueOf(Constants.CTL_PORT_NUM_SERVER));
186
		dialog.open();
97
		_host.setFocus();
187
188
		if (dialog.getReturnCode() == Window.OK) {
189
		
190
			StringBuffer buffer = new StringBuffer(dialog.getHost());
191
			buffer.append(":").append(dialog.getPort());
192
			addHost(buffer.toString());
193
			
194
			enableButtons();
195
			changed();	
196
			setHostText();
197
		}
98
	}
198
	}
99
199
	
100
	/**
200
	/**
101
	 * Insert the method's description here. Creation date: (4/26/2001 5:17:57
201
	 * Insert the method's description here. Creation date: (4/26/2001 5:17:57
102
	 * PM)
202
	 * PM)
Lines 107-113 Link Here
107
	public void addHost(String text) {
207
	public void addHost(String text) {
108
		for (int idx = 0; idx < _list.getItemCount(); idx++) {
208
		for (int idx = 0; idx < _list.getItemCount(); idx++) {
109
			if (text.equals(_list.getItem(idx).getText()))
209
			if (text.equals(_list.getItem(idx).getText()))
210
			{	
211
				_list.select(idx);
110
				return;
212
				return;
213
			}
111
		}
214
		}
112
215
113
		TableItem item = new TableItem(_list, SWT.NONE);
216
		TableItem item = new TableItem(_list, SWT.NONE);
Lines 128-134 Link Here
128
		// since I only get called upon initialization
231
		// since I only get called upon initialization
129
		// I will remove all the previous hosts
232
		// I will remove all the previous hosts
130
		// and then add these hosts
233
		// and then add these hosts
131
		if (hosts != null && !hosts.equals("")) {
234
		if (hosts != null && hosts.length() > 0) {
132
			int idx = 0;
235
			int idx = 0;
133
236
134
			while (idx != -1) {
237
			while (idx != -1) {
Lines 219-227 Link Here
219
		layout.numColumns = 1;
322
		layout.numColumns = 1;
220
		buttonWidget1.setLayout(layout);
323
		buttonWidget1.setLayout(layout);
221
324
325
		_add = new Button(buttonWidget1, SWT.NULL);
326
		_add.setLayoutData(GridUtil.createHorizontalFill());
327
		_add.setText(UIPlugin.getResourceString("STR_PREF_ADD"));
328
		
222
		_delete = new Button(buttonWidget1, SWT.NULL);
329
		_delete = new Button(buttonWidget1, SWT.NULL);
223
		_delete.setLayoutData(GridUtil.createHorizontalFill());
330
		_delete.setLayoutData(GridUtil.createHorizontalFill());
224
		_delete.setText(UIPlugin.getResourceString("DELETE"));
331
		_delete.setText(UIPlugin.getResourceString("REMOVE_TEXT"));
225
332
226
		_testConnection = new Button(buttonWidget1, SWT.NULL);
333
		_testConnection = new Button(buttonWidget1, SWT.NULL);
227
		_testConnection.setLayoutData(GridUtil.createHorizontalFill());
334
		_testConnection.setLayoutData(GridUtil.createHorizontalFill());
Lines 231-247 Link Here
231
		Label l = new Label(buttonWidget1, SWT.NULL);
338
		Label l = new Label(buttonWidget1, SWT.NULL);
232
		l.setLayoutData(GridUtil.createVerticalFill());
339
		l.setLayoutData(GridUtil.createVerticalFill());
233
340
234
		Composite buttonWidget2 = new Composite(buttonWidget, SWT.NULL);
235
		data = GridUtil.createHorizontalFill();
236
		buttonWidget2.setLayoutData(data);
237
		layout = new GridLayout();
238
		layout.numColumns = 1;
239
		buttonWidget2.setLayout(layout);
240
241
		_add = new Button(buttonWidget2, SWT.NULL);
242
		_add.setLayoutData(GridUtil.createHorizontalFill());
243
		_add.setText(UIPlugin.getResourceString("STR_PREF_ADD"));
244
245
		_add.addSelectionListener(this);
341
		_add.addSelectionListener(this);
246
		_delete.addSelectionListener(this);
342
		_delete.addSelectionListener(this);
247
		_testConnection.addSelectionListener(this);
343
		_testConnection.addSelectionListener(this);
Lines 250-281 Link Here
250
		_host.addModifyListener(this);
346
		_host.addModifyListener(this);
251
		_port.addModifyListener(this);
347
		_port.addModifyListener(this);
252
348
253
		_add.setEnabled(false);
254
		_delete.setEnabled(false);
349
		_delete.setEnabled(false);
255
		_testConnection.setEnabled(false);
350
		_testConnection.setEnabled(false);
256
351
257
		initializeValues();
352
		initializeValues();
258
353
259
		_host.setFocus();
260
261
		_host.addTraverseListener(new TraverseListener() {
262
			public void keyTraversed(TraverseEvent e) {
263
				if (e.detail == SWT.TRAVERSE_RETURN) {
264
					if (_host.getText().trim() == ""
265
							|| _port.getText().trim() == "")
266
						return;
267
268
					addHost();
269
					e.doit = false;
270
271
					if (_wizardPage != null)
272
						_wizardPage
273
								.setPageComplete(_list.getSelectionIndex() != -1);
274
275
				}
276
			}
277
		});
278
279
		PlatformUI.getWorkbench().getHelpSystem().setHelp(_list,
354
		PlatformUI.getWorkbench().getHelpSystem().setHelp(_list,
280
				UIPlugin.getPluginId() + ".hstp0001");
355
				UIPlugin.getPluginId() + ".hstp0001");
281
356
Lines 330-335 Link Here
330
		int i = _list.getSelectionIndex();
405
		int i = _list.getSelectionIndex();
331
		if (i != -1)
406
		if (i != -1)
332
			_list.remove(i);
407
			_list.remove(i);
408
		
409
		_host.setText("");
410
		_port.setText("");
333
411
334
	}
412
	}
335
413
Lines 413-418 Link Here
413
491
414
		String hosts = store.getString(HyadesConstants.HOST_KEY);
492
		String hosts = store.getString(HyadesConstants.HOST_KEY);
415
		addHosts(hosts);
493
		addHosts(hosts);
494
		setHostText();
495
		
416
		enableButtons();
496
		enableButtons();
417
	}
497
	}
418
498
Lines 423-444 Link Here
423
	 *            an event containing information about the modify
503
	 *            an event containing information about the modify
424
	 */
504
	 */
425
	public void modifyText(ModifyEvent e) {
505
	public void modifyText(ModifyEvent e) {
426
		if (e.widget == _host)
506
		if (e.widget == _host || e.widget == _port)
427
			_add.setEnabled((!_host.getText().trim().equals(""))
507
		{
428
					&& (!_port.getText().trim().equals("")));
508
			TableItem[] selected = _list.getSelection();			
429
		else if (e.widget == _port) {
509
			if(selected.length > 0)
430
			try {
510
			{
431
				int value = Integer.parseInt(_port.getText().trim());
511
				selected[0].setText((new StringBuffer(_host.getText().trim()).append(":").append(_port.getText().trim())).toString());
432
				if (value < 0 || value > 65535) {
433
					_add.setEnabled(false);
434
					return;
435
				}
436
				_add.setEnabled((!_host.getText().trim().equals(""))
437
						&& (!_port.getText().trim().equals("")));
438
			} catch (NumberFormatException nfe) {
439
				_add.setEnabled(false);
440
			}
512
			}
441
442
		}
513
		}
443
	}
514
	}
444
515
Lines 489-499 Link Here
489
560
490
		if (e.widget == _add) {
561
		if (e.widget == _add) {
491
			addHost();
562
			addHost();
492
			enableButtons();
493
			changed();
494
563
495
			if (_wizardPage != null)
564
			if (_wizardPage != null)
496
				_wizardPage.setPageComplete(_list.getSelectionIndex() != -1);
565
				_wizardPage.setPageComplete(_list.getSelectionIndex() != -1);
566
			
497
		} else if (e.widget == _delete) {
567
		} else if (e.widget == _delete) {
498
			deleteHost();
568
			deleteHost();
499
			enableButtons();
569
			enableButtons();
Lines 501-510 Link Here
501
571
502
			if (_wizardPage != null)
572
			if (_wizardPage != null)
503
				_wizardPage.setPageComplete(_list.getSelectionIndex() != -1);
573
				_wizardPage.setPageComplete(_list.getSelectionIndex() != -1);
574
			
504
		} else if (e.widget == _list) {
575
		} else if (e.widget == _list) {
505
			TableItem[] selected = _list.getSelection();
506
			enableButtons();
576
			enableButtons();
507
			_list.setSelection(selected);
577
			setHostText();
578
			
508
			changed();
579
			changed();
509
			if (_wizardPage != null)
580
			if (_wizardPage != null)
510
				_wizardPage.setPageComplete(_list.getSelectionIndex() != -1);
581
				_wizardPage.setPageComplete(_list.getSelectionIndex() != -1);
Lines 523-526 Link Here
523
			}
594
			}
524
		}
595
		}
525
	}
596
	}
597
	
598
	private void setHostText()
599
	{
600
		TableItem[] selected = _list.getSelection();				
601
		if(selected.length > 0)
602
		{
603
			String text = selected[0].getText();
604
			int idx=text.lastIndexOf(":");
605
			if(idx != -1)
606
			{
607
				_host.setText(text.substring(0, idx));
608
				
609
				if(idx<text.length()-1)
610
				{
611
					_port.setText(text.substring(idx+1));
612
				}
613
				else
614
					_port.setText("");
615
			}
616
		}
617
		else
618
		{
619
			_host.setText("");
620
			_port.setText("");
621
		}
622
		
623
	}
526
}
624
}
(-)src/org/eclipse/hyades/trace/ui/internal/core/TraceLogUI.java (-79 / +154 lines)
Lines 12-42 Link Here
12
package org.eclipse.hyades.trace.ui.internal.core;
12
package org.eclipse.hyades.trace.ui.internal.core;
13
13
14
import org.eclipse.hyades.trace.ui.UIPlugin;
14
import org.eclipse.hyades.trace.ui.UIPlugin;
15
import org.eclipse.hyades.trace.ui.internal.util.CList;
16
import org.eclipse.hyades.ui.util.GridUtil;
15
import org.eclipse.hyades.ui.util.GridUtil;
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.jface.window.Window;
17
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.ModifyEvent;
20
import org.eclipse.swt.events.ModifyEvent;
19
import org.eclipse.swt.events.ModifyListener;
21
import org.eclipse.swt.events.ModifyListener;
20
import org.eclipse.swt.events.SelectionAdapter;
21
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.events.SelectionListener;
23
import org.eclipse.swt.events.SelectionListener;
23
import org.eclipse.swt.events.TraverseEvent;
24
import org.eclipse.swt.events.TraverseListener;
25
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
25
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Button;
28
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Composite;
28
import org.eclipse.swt.widgets.Control;
29
import org.eclipse.swt.widgets.Display;
29
import org.eclipse.swt.widgets.Label;
30
import org.eclipse.swt.widgets.Label;
31
import org.eclipse.swt.widgets.Shell;
32
import org.eclipse.swt.widgets.Table;
33
import org.eclipse.swt.widgets.TableItem;
30
import org.eclipse.swt.widgets.Text;
34
import org.eclipse.swt.widgets.Text;
31
35
32
public class TraceLogUI implements SelectionListener, ModifyListener {
36
public class TraceLogUI implements SelectionListener, ModifyListener {
33
37
34
	private CList _list;
38
	private Table _list;
35
	private Button _delete;
39
	private Button _delete;
36
	private Button _addAgent;
40
	private Button _addAgent;
37
	private Label _newAgentLabel;
38
	private Text _newAgent;
41
	private Text _newAgent;
39
42
43
	class AddAgentDialog extends Dialog implements ModifyListener {
44
		private Text agent;
45
		private String agentStr;
46
		
47
		public AddAgentDialog() {
48
			super(Display.getCurrent().getActiveShell());
49
		}
50
51
		protected void configureShell(Shell shell) {
52
			super.configureShell(shell);
53
			shell.setText(UIPlugin.getResourceString("ADD_LOG_AGENT"));
54
		}
55
56
		protected Control createDialogArea(Composite parent) {
57
			Composite result = (Composite) super.createDialogArea(parent);
58
59
			GridLayout layout;
60
			GridData data;
61
			Label label;
62
63
			layout = new GridLayout();
64
			layout.numColumns = 2;
65
			result.setLayout(layout);
66
			data = GridUtil.createFill();
67
			data.widthHint = 400;
68
			result.setLayoutData(data);
69
70
			label = new Label(result, SWT.NONE);
71
			label.setText(UIPlugin.getResourceString("LOG_AGENT_LABEL"));
72
			agent = new Text(result, SWT.BORDER);
73
			agent.setLayoutData(GridUtil.createHorizontalFill());
74
			
75
			agent.setText("logAgent");
76
			agent.setFocus();
77
			agent.selectAll();
78
			
79
			return result;
80
		}
81
82
		public void modifyText(ModifyEvent e) {
83
				if (getButton(IDialogConstants.OK_ID) != null)
84
					getButton(IDialogConstants.OK_ID).setEnabled(
85
							agent.getText().trim().length() > 0);
86
		}
87
88
		protected void okPressed() {
89
			agentStr = agent.getText().trim();
90
			super.okPressed();
91
		}
92
		
93
		/*
94
		 * Set the initial Ok button enablement.
95
		 */
96
		protected Control createContents(Composite parent) {
97
			Control result = super.createContents(parent);
98
			getButton(IDialogConstants.OK_ID).setEnabled(agent.getText().trim().length() > 0);
99
			return result;
100
		}
101
102
		/**
103
		 * @return Returns the agentStr.
104
		 */
105
		public String getAgentName() {
106
			return agentStr;
107
		}
108
	}
109
	
40
	public TraceLogUI() {
110
	public TraceLogUI() {
41
		super();
111
		super();
42
	}
112
	}
Lines 45-69 Link Here
45
	 * Creation date: (11/06/2000 3:38:47 PM)
115
	 * Creation date: (11/06/2000 3:38:47 PM)
46
	 */
116
	 */
47
	protected void addAgent() {
117
	protected void addAgent() {
48
		String agentName = _newAgent.getText().trim();
118
		
49
119
		AddAgentDialog dialog = new AddAgentDialog();
50
		addAgent(agentName);
120
		dialog.open();
121
122
		if (dialog.getReturnCode() == Window.OK) {
123
		
124
			addAgent(dialog.getAgentName());
125
		}
51
	}
126
	}
52
	/**
127
	/**
53
	 * Insert the method's description here.
128
	 * Insert the method's description here.
54
	 * Creation date: (4/30/2001 12:21:38 PM)
129
	 * Creation date: (4/30/2001 12:21:38 PM)
55
	 * @param name java.lang.String
130
	 * @param name java.lang.String
56
	 */
131
	 */
57
	public void addAgent(String name) {
132
	public void addAgent(String text) {
58
		_list.add(name);
133
		
59
		_list.getList().setSelection(_list.getList().indexOf(name));
134
		for (int idx = 0; idx < _list.getItemCount(); idx++) {
135
			if (text.equals(_list.getItem(idx).getText()))
136
			{	
137
				_list.select(idx);
138
				setAgentText();				
139
				return;
140
			}
141
		}
60
142
61
		_newAgent.setText("");
143
		TableItem item = new TableItem(_list, SWT.NONE);
62
		_newAgent.setFocus();
144
		item.setText(text);
63
145
64
		_addAgent.setEnabled(false);
146
		_list.setSelection(new TableItem[] { item });
65
		_delete.setEnabled(true);
147
		setAgentText();
66
	}
148
	}
149
	
67
	public Composite createControl(Composite parent) {
150
	public Composite createControl(Composite parent) {
68
		GridLayout layout;
151
		GridLayout layout;
69
		GridData gd;
152
		GridData gd;
Lines 75-81 Link Here
75
		_result.setLayout(layout);
158
		_result.setLayout(layout);
76
		_result.setLayoutData(GridUtil.createFill());
159
		_result.setLayoutData(GridUtil.createFill());
77
160
78
		_list = new CList(_result, "");
161
		_list = new Table(_result, SWT.BORDER | SWT.H_SCROLL);
162
		gd = GridUtil.createFill();
163
		_list.setLayoutData(gd);
79
164
80
		Composite buttons = new Composite(_result, SWT.NULL);
165
		Composite buttons = new Composite(_result, SWT.NULL);
81
		layout = new GridLayout();
166
		layout = new GridLayout();
Lines 88-95 Link Here
88
		gd.widthHint = 120;
173
		gd.widthHint = 120;
89
		buttons.setLayoutData(gd);
174
		buttons.setLayoutData(gd);
90
175
176
		_addAgent = new Button(buttons, SWT.PUSH);
177
		_addAgent.setText(UIPlugin.getResourceString("STR_PREF_ADD"));
178
		_addAgent.setLayoutData(GridUtil.createHorizontalFill());
179
		
91
		_delete = new Button(buttons, SWT.PUSH | SWT.NULL);
180
		_delete = new Button(buttons, SWT.PUSH | SWT.NULL);
92
		_delete.setText(UIPlugin.getResourceString("REMOVE_AGENT"));
181
		_delete.setText(UIPlugin.getResourceString("REMOVE_TEXT"));
93
		_delete.setLayoutData(GridUtil.createHorizontalFill());
182
		_delete.setLayoutData(GridUtil.createHorizontalFill());
94
		Composite space = new Composite(buttons, SWT.NULL);
183
		Composite space = new Composite(buttons, SWT.NULL);
95
		space.setLayout(layout);
184
		space.setLayout(layout);
Lines 102-160 Link Here
102
		addAgent.setLayout(layout);
191
		addAgent.setLayout(layout);
103
		addAgent.setLayoutData(GridUtil.createHorizontalFill());
192
		addAgent.setLayoutData(GridUtil.createHorizontalFill());
104
193
105
		_newAgentLabel = new Label(addAgent, SWT.NULL);
194
		Label label = new Label(addAgent, SWT.NULL);
106
		_newAgentLabel.setText(UIPlugin.getResourceString("ADD_AGENT"));
195
		label.setText(UIPlugin.getResourceString("LOG_AGENT_LABEL"));
107
		_newAgent = new Text(addAgent, SWT.BORDER);
196
		_newAgent = new Text(addAgent, SWT.BORDER);
108
		_newAgent.setLayoutData(GridUtil.createHorizontalFill());
197
		_newAgent.setLayoutData(GridUtil.createHorizontalFill());
109
198
		
110
		Composite addButton = new Composite(_result, SWT.NULL);
111
		layout = new GridLayout();
112
		layout.numColumns = 1;
113
		layout.verticalSpacing = 1;
114
		addButton.setLayout(layout);
115
		gd = new GridData();
116
		gd.widthHint = 120;
117
		addButton.setLayoutData(gd);
118
119
		_addAgent = new Button(addButton, SWT.PUSH);
120
		_addAgent.setText(UIPlugin.getResourceString("ADD_AGENT_BUTTON"));
121
		_addAgent.setLayoutData(GridUtil.createHorizontalFill());
122
123
		_addAgent.setEnabled(false);
124
		_delete.setEnabled(false);
125
126
		_delete.addSelectionListener(this);
199
		_delete.addSelectionListener(this);
127
		_addAgent.addSelectionListener(this);
200
		_addAgent.addSelectionListener(this);
128
		_newAgent.addModifyListener(this);
201
		_newAgent.addModifyListener(this);
129
202
130
		/*_newAgent.addKeyListener(new KeyAdapter() {
203
		_list.addSelectionListener(this);
131
			public void keyReleased(KeyEvent key) {
132
				if (key.character == 13)
133
					addAgent();
134
			}
135
		});*/
136
137
		_newAgent.addTraverseListener(new TraverseListener() {
138
			public void keyTraversed(TraverseEvent e) {
139
				if (e.detail == SWT.TRAVERSE_RETURN) {
140
					addAgent();
141
					e.doit = false;
142
				}
143
			}
144
		});
145
146
		_list.getList().addSelectionListener(new SelectionAdapter() {
147
			public void widgetSelected(SelectionEvent e) {
148
				_delete.setEnabled(_list.getSelectedIndices().length > 0);
149
			}
150
		});
151
204
152
		_newAgent.setFocus();
205
		_delete.setEnabled(false);
153
206
154
		return _result;
207
		return _result;
155
	}
208
	}
156
	public String[] getAgents() {
209
	public String[] getAgents() {
157
		return _list.getList().getItems();
210
		
211
		TableItem[] items = _list.getItems();
212
		String[] agents = new String[items.length];
213
		
214
		for(int idx=0; idx<items.length; idx++)
215
		{
216
			agents[idx]=items[idx].getText();
217
		}
218
		
219
		return agents;
158
	}
220
	}
159
	/**
221
	/**
160
	 * Insert the method's description here.
222
	 * Insert the method's description here.
Lines 163-199 Link Here
163
	 */
225
	 */
164
	public void modifyText(ModifyEvent event) {
226
	public void modifyText(ModifyEvent event) {
165
		if (event.widget == _newAgent)
227
		if (event.widget == _newAgent)
166
			_addAgent.setEnabled(!_newAgent.getText().trim().equals(""));
228
		{
229
			TableItem[] selected = _list.getSelection();			
230
			if(selected.length > 0)
231
			{
232
				selected[0].setText(_newAgent.getText().trim());
233
			}
234
		}
167
	}
235
	}
168
	/**
236
	/**
169
	 * Insert the method's description here.
237
	 * Insert the method's description here.
170
	 * Creation date: (11/06/2000 3:52:27 PM)
238
	 * Creation date: (11/06/2000 3:52:27 PM)
171
	 */
239
	 */
172
	protected void removeAgent() {
240
	protected void removeAgent() {
173
		int selection = _list.getSelectedIndex();
241
		int i = _list.getSelectionIndex();
174
		_list.remove(selection);
242
		if (i != -1)
175
243
			_list.remove(i);
176
		if (_list.getItemCount() > 0) {
244
		
177
			if (selection == 0)
245
		_newAgent.setText("");
178
				_list.setSelectedIndex(0);
179
			if (selection < _list.getItemCount())
180
				_list.setSelectedIndex(selection);
181
			else if ((selection - 1) < _list.getItemCount())
182
				_list.setSelectedIndex(selection - 1);
183
			else
184
				_list.setSelectedIndex(0);
185
		} else
186
			_delete.setEnabled(false);
187
188
		_newAgent.setFocus();
189
		_newAgent.selectAll();
190
	}
246
	}
191
	/**
247
	/**
192
	 * Insert the method's description here.
248
	 * Insert the method's description here.
193
	 * Creation date: (4/30/2001 12:22:33 PM)
249
	 * Creation date: (4/30/2001 12:22:33 PM)
194
	 */
250
	 */
195
	public void reset() {
251
	public void reset() {
196
		_list.getList().removeAll();
252
		_list.removeAll();
197
		_delete.setEnabled(false);
253
		_delete.setEnabled(false);
198
	}
254
	}
199
	/**
255
	/**
Lines 213-217 Link Here
213
			addAgent();
269
			addAgent();
214
		else if (event.widget == _delete)
270
		else if (event.widget == _delete)
215
			removeAgent();
271
			removeAgent();
272
	   else if (event.widget == _list) {
273
			_delete.setEnabled(_list.getSelectionIndex() != -1);
274
			setAgentText();
275
	   }		
276
	}
277
	
278
	private void setAgentText()
279
	{
280
		TableItem[] selected = _list.getSelection();				
281
		if(selected.length > 0)
282
		{
283
			_newAgent.setText(selected[0].getText());
284
		}
285
		else
286
		{
287
			_newAgent.setText("");
288
		}
289
		
216
	}
290
	}
291
	
217
}
292
}

Return to bug 79567