Revision 767

tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/ConfirmDialog.java (revision 767)
10 10
import org.eclipse.swt.widgets.Control;
11 11
import org.eclipse.swt.widgets.Shell;
12 12

  
13
/**
14
 * A confirm Dialog with a check box to not ask again
15
 * 
16
 * @author mdecorde
17
 *
18
 */
13 19
public class ConfirmDialog extends MessageDialog {
14 20

  
15 21
	public final static String[] dialogButtonLabels = { IDialogConstants.OK_LABEL,
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/TextDialog.java (revision 767)
1
package org.txm.rcp.swt.dialog;
2
/*
3
SWT/JFace in Action
4
GUI Design with Eclipse 3.0
5
Matthew Scarpino, Stephen Holder, Stanford Ng, and Laurent Mihalkovic
6

  
7
ISBN: 1932394273
8

  
9
Publisher: Manning
10
 */
11

  
12

  
13
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.jface.dialogs.IDialogConstants;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.Label;
21
import org.eclipse.swt.widgets.Shell;
22
import org.eclipse.swt.widgets.Text;
23

  
24
public class TextDialog extends Dialog {
25
	private static final int RESET_ID = IDialogConstants.NO_TO_ALL_ID + 1;
26

  
27
	private Text textField;
28
	String title;
29
	String question;
30
	String text;
31

  
32
	public TextDialog(Shell parentShell, String title, String question, String text) {
33
		super(parentShell);
34
		this.title = title;
35
		this.question = question;
36
		this.text = text;
37
	}
38

  
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
41
	 */
42
	@Override
43
	protected void configureShell(Shell newShell) {
44
		super.configureShell(newShell);
45
		newShell.setText(title);
46
	}
47

  
48
	protected Control createDialogArea(Composite parent) {
49
		Composite comp = (Composite) super.createDialogArea(parent);
50

  
51
		GridLayout layout = (GridLayout) comp.getLayout();
52
		layout.numColumns = 1;
53
		
54
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
55

  
56
		Label questionLabel = new Label(comp, SWT.RIGHT);
57
		questionLabel.setText(question);
58
		questionLabel.setLayoutData(data);
59

  
60
		textField = new Text(comp, SWT.SINGLE);
61
		textField.setLayoutData(data);
62
		return comp;
63
	}
64

  
65
	protected void buttonPressed(int buttonId) {
66
		if (buttonId == Dialog.OK) {
67
			text = textField.getText();
68
		}
69
		super.buttonPressed(buttonId);
70
	}
71

  
72
	public String getText() {
73
		return text;
74
	}
75
}
0 76

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/NavigationWidget.java (revision 767)
32 32
import org.eclipse.swt.events.SelectionListener;
33 33
import org.eclipse.swt.graphics.Color;
34 34
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.layout.GridLayout;
36 35
import org.eclipse.swt.widgets.Button;
37 36
import org.eclipse.swt.widgets.Composite;
38 37
import org.eclipse.swt.widgets.Label;
39 38
import org.eclipse.swt.widgets.Text;
39
import org.txm.rcp.IImageKeys;
40 40
import org.txm.rcp.messages.TXMUIMessages;
41 41
import org.txm.rcp.swt.GLComposite;
42 42

  
43
// TODO: Auto-generated Javadoc
44 43
/**
45
 * [<< |< < label > >| >>] @ author mdecorde.
44
 * Navigation composite 
45
 * 
46
 * (|<) (<) current / number of lines  (>) (>|) 
47
 * 
48
 * @author mdecorde.
46 49
 */
47 50
public class NavigationWidget extends GLComposite {
48 51

  
......
60 63
	Button next;
61 64

  
62 65
	/** The prev. */
63
	Button prev;
66
	Button previous;
64 67

  
65 68
	/** The n line per page. */
66 69
	int nLinePerPage;
......
77 80
		this.getLayout().numColumns = 6;
78 81
		this.getLayout().makeColumnsEqualWidth = false;
79 82

  
80
		// | [|<] [<] [info] [>] [>|] |
83
		// | [|<] [<] [infos] [>] [>|] |
81 84

  
85
		
82 86
		// [|<]
83
		first = new Button(this, SWT.PUSH);
84
		first.setText("|<"); //$NON-NLS-1$
85
		first.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
87
		first = new Button(this, SWT.FLAT|SWT.PUSH);
86 88
		first.setEnabled(false);
87 89

  
88 90
		// [<]
89
		prev = new Button(this, SWT.PUSH);
90
		prev.setText("<"); //$NON-NLS-1$
91
		prev.setEnabled(false);
91
		previous = new Button(this, SWT.FLAT|SWT.PUSH);
92
		previous.setEnabled(false);
92 93

  
93 94
		// [current]
94 95
		currentPosition = new Text(this, SWT.NONE);
......
107 108
		currentPosition.setBackground(infoLine.getBackground());
108 109

  
109 110
		// [>]
110
		next = new Button(this, SWT.PUSH);
111
		next.setText(">"); //$NON-NLS-1$
111
		next = new Button(this, SWT.FLAT|SWT.PUSH);
112 112
		next.setEnabled(false);
113 113

  
114 114
		// [>|]
115
		last = new Button(this, SWT.PUSH);
116
		last.setText(">|"); //$NON-NLS-1$
115
		last = new Button(this, SWT.FLAT|SWT.PUSH);
117 116
		last.setEnabled(false);
117
		
118
		// set icons
119
		first.setImage(IImageKeys.getImage(IImageKeys.CTRLSTART)); 
120
		previous.setImage(IImageKeys.getImage(IImageKeys.CTRLREVERSE));
121
		next.setImage(IImageKeys.getImage(IImageKeys.CTRLPLAY));
122
		last.setImage(IImageKeys.getImage(IImageKeys.CTRLEND));
123
		
124
		// set layout data
125
		GridData buttonGridData = new GridData(GridData.FILL,GridData.CENTER, false, false);
126
		buttonGridData.widthHint = 30;
127
		buttonGridData.heightHint = 30;
128
		GridData centerButtonGridData = new GridData(GridData.END,GridData.CENTER, true, true);
129
		centerButtonGridData.widthHint = 30;
130
		centerButtonGridData.heightHint = 30;
131
		first.setLayoutData(centerButtonGridData);
132
		previous.setLayoutData(buttonGridData);
133
		next.setLayoutData(buttonGridData);
134
		centerButtonGridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, true);
135
		centerButtonGridData.widthHint = 30;
136
		centerButtonGridData.heightHint = 30;
137
		last.setLayoutData(centerButtonGridData);
118 138
	}
119 139

  
120 140

  
......
149 169
	 * @param selectionListener the selection listener
150 170
	 */
151 171
	public void addPreviousListener(SelectionListener selectionListener) {
152
		prev.addSelectionListener(selectionListener);
172
		previous.addSelectionListener(selectionListener);
153 173
	}
154 174

  
155 175
	/**
......
194 214
	 * @param b the new previous enabled
195 215
	 */
196 216
	public void setPreviousEnabled(boolean b) {
197
		prev.setEnabled(b);
217
		previous.setEnabled(b);
198 218
	}
199 219

  
200 220
	/**
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/RenameResult.java (revision 767)
1
package org.txm.rcp.commands.function;
2

  
3
import org.eclipse.core.commands.AbstractHandler;
4
import org.eclipse.core.commands.ExecutionEvent;
5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.jface.dialogs.MessageDialog;
7
import org.eclipse.jface.viewers.ISelection;
8
import org.eclipse.jface.viewers.IStructuredSelection;
9
import org.eclipse.ui.IWorkbenchWindow;
10
import org.eclipse.ui.handlers.HandlerUtil;
11
import org.txm.core.results.TXMResult;
12
import org.txm.rcp.swt.dialog.TextDialog;
13
import org.txm.rcp.views.corpora.CorporaView;
14

  
15
public class RenameResult extends AbstractHandler  {
16

  
17
	@Override
18
	public Object execute(ExecutionEvent event) throws ExecutionException {
19
		ISelection isel = HandlerUtil.getCurrentSelection(event);
20
		if (!(isel instanceof IStructuredSelection)) return null;
21
		IStructuredSelection selection = (IStructuredSelection) isel;
22
		
23
		Object first = selection.getFirstElement();
24
		if (first instanceof TXMResult) {
25
			final TXMResult r = (TXMResult)first;
26
			
27
			final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
28
			TextDialog dialog = new TextDialog(window.getShell(), "Rename "+r, "Enter the new name to show in the Corpus view", r.getUserName());
29
			if (dialog.open() == TextDialog.OK) {
30
				String newName = dialog.getText();
31
				if (newName.length() > 0) {
32
					r.setUserName(newName);
33
					
34
					window.getShell().getDisplay().syncExec(new Runnable() {
35
						@Override
36
						public void run() {
37
							CorporaView.refreshObject(r);
38
						}
39
					});
40
				}
41
			}
42
		}
43
		return null;
44
	}
45

  
46
}
0 47

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/IImageKeys.java (revision 767)
235 235
	public static final String TXM_ICON = "icons/logo/TXM logo.png";
236 236
	public static final String TXM = "icons/logo/TXM logo 64x64.png";
237 237

  
238
	public static final String OPEN_DECORATOR = "icons/decorators/bullet_arrow_down.png";
239
	public static final String CLOSE_DECORATOR = "icons/decorators/bullet_arrow_up.png";
240

  
238 241
	/**
239 242
	 * Gets the image.
240 243
	 *
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java (revision 767)
3 3
import java.util.HashMap;
4 4

  
5 5
import org.eclipse.jface.action.ToolBarManager;
6
import org.eclipse.jface.fieldassist.ControlDecoration;
6 7
import org.eclipse.swt.SWT;
7 8
import org.eclipse.swt.events.SelectionEvent;
8 9
import org.eclipse.swt.events.SelectionListener;
10
import org.eclipse.swt.graphics.Image;
9 11
import org.eclipse.swt.layout.GridData;
10 12
import org.eclipse.swt.layout.RowLayout;
11 13
import org.eclipse.swt.widgets.Button;
......
44 46
	/**
45 47
	 * Contains references to installed groups to ToolItem.
46 48
	 */
47
	private HashMap<String, ToolItem> buttons = new HashMap<String, ToolItem>();
49
	private HashMap<String, OpenCloseButton> buttons = new HashMap<String, OpenCloseButton>();
48 50

  
49 51
	/**
50 52
	 * 
......
97 99
	public void setVisible(String id, boolean visible)	{
98 100
		if (groups.containsKey(id)) {
99 101
			Composite composite = groups.get(id);
100
			ToolItem activationButton = buttons.get(id);
102
			OpenCloseButton activationButton = buttons.get(id);
101 103
			setVisible(composite, activationButton, visible);
102 104
		}
103 105
	}
......
109 111
	 * @param composite
110 112
	 * 
111 113
	 */
112
	protected void setVisible(Composite composite, ToolItem activationButton, boolean visible)	{
114
	protected void setVisible(Composite composite, OpenCloseButton showParameters, boolean visible)	{
113 115
		((GridData)composite.getLayoutData()).exclude = !visible;
114 116
		composite.setVisible(visible);
115 117
		composite.layout(true);
116 118
		editorPart.parent.layout(true);
117
		activationButton.setSelection(visible);
119
		showParameters.setSelection(visible);
118 120
	}
119 121

  
120 122

  
......
190 192

  
191 193

  
192 194
		// add finally a button to the toolbar to show/hide the Group
193
		final ToolItem showParameters = new ToolItem(this, SWT.CHECK | SWT.LEFT);
195
		
196
		final OpenCloseButton showParameters = new OpenCloseButton(this, groupTitle, iconFilePath);
197
//		if (iconFilePath != null)	{
198
//			showParameters.setImage(IImageKeys.getImage(iconFilePath));
199
//		}
200
//		// if no icon specified, show the group title in the toolitem
201
//		else	{
202
//			showParameters.setText(groupTitle);
203
//		}
204
//
205
//		if (buttonToolTip != null)	{
206
//			showParameters.setToolTipText(buttonToolTip);
207
//		}
194 208

  
195
		if (iconFilePath != null)	{
196
			showParameters.setImage(IImageKeys.getImage(iconFilePath));
197
		}
198
		// if no icon specified, show the group title in the toolitem
199
		else	{
200
			showParameters.setText(groupTitle);
201
		}
202

  
203
		if (buttonToolTip != null)	{
204
			showParameters.setToolTipText(buttonToolTip);
205
		}
206

  
207 209
		this.setVisible(group, showParameters, showGroup); // default init
208 210

  
209 211
		showParameters.addSelectionListener(new SelectionListener() {
......
221 223
		this.buttons.put(groupTitle, showParameters);
222 224
		return group;
223 225
	}
226
	
227
	//failure of open/close decorator
228
	public class OpenCloseButton {
229
//		ToolItem sep;
230
		ToolItem showParameters;
231
//		ControlDecoration openCloseDeco;
232
		
233
		public OpenCloseButton(TXMEditorToolBar toolbar, String groupTitle, String iconFilePath) {
234
			 
235
//			sep = new ToolItem(toolbar, SWT.SEPARATOR);
236
			showParameters = new ToolItem(toolbar, SWT.CHECK);
237
			if (iconFilePath != null) {
238
				showParameters.setImage(IImageKeys.getImage(iconFilePath));
239
				showParameters.setToolTipText(groupTitle);
240
			} else {
241
				showParameters.setText(groupTitle);
242
			}
243
			
244
			
245
			
246
//			showParameters.pack();
247
//			sep.setWidth (showParameters.getSize ().x);
248
//			sep.setControl (showParameters);
249
			
250
//			openCloseDeco = new ControlDecoration(showParameters, SWT.RIGHT);
251
//			openCloseDeco.setImage(IImageKeys.getImage(IImageKeys.CLOSE_DECORATOR));
252
		}
253

  
254
		public void setSelection(boolean visible) {
255
			showParameters.setSelection(visible);
256
//			if (visible) {
257
//				openCloseDeco.setImage(IImageKeys.getImage(IImageKeys.CLOSE_DECORATOR));
258
//			} else {
259
//				openCloseDeco.setImage(IImageKeys.getImage(IImageKeys.OPEN_DECORATOR));
260
//			}
261
		}
262

  
263
		public void addSelectionListener(SelectionListener selectionListener) {
264
			showParameters.addSelectionListener(selectionListener);
265
		}
266

  
267
		public boolean getSelection() {
268
			return showParameters.getSelection();
269
		}
270

  
271
		public void setToolTipText(String buttonToolTip) {
272
			showParameters.setToolTipText(buttonToolTip);
273
		}
274

  
275
		public void setText(String groupTitle) {
276
			showParameters.setText(groupTitle);
277
		}
278

  
279
		public void setImage(Image image) {
280
			showParameters.setImage(image);
281
		}
282

  
283
		public void dispose() {
284
			showParameters.dispose();
285
		}
286
	}
287

  
288
	public void unInstallGroup(String groupTitle) {
289
		if (this.groups.containsKey(groupTitle)) {
290
			this.groups.get(groupTitle).dispose();			
291
		}
292
		if (this.buttons.containsKey(groupTitle)) {
293
			this.buttons.get(groupTitle).dispose();			
294
		}
295
	}
224 296
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 767)
225 225
			if (this.bottomToolBar.getItems().length == 0) {
226 226
				this.bottomToolBar.dispose();
227 227
			}
228
			
229
			// uninstall parameers group if not used
230
			if (computingParametersGroup.getChildren().length == 0) {
231
				this.topToolBar.unInstallGroup(COMPUTING_PARAMETERS_GROUP_ID);
232
			}
228 233
		}
229 234
		catch(Exception e) {
230 235
			System.err.println("TXMEditor.createPartControl(): can not create the editor.");
......
779 784
						// multiple
780 785
						if (resultField.getType().isAssignableFrom(List.class))	{
781 786
							value = new ArrayList(((PropertiesSelector)object).getSelectedProperties()); // need to copy the list otherwise the properties selector modify the result itself through reference	
787
						} else if (resultField.getType().isAssignableFrom(ReferencePattern.class))	{
788
							value = new ReferencePattern(((PropertiesSelector)object).getSelectedProperties()); // need to copy the list otherwise the properties selector modify the result itself through reference	
782 789
						}
783 790
						// single
784 791
						else	{
tmp/org.txm.rcp/plugin.xml (revision 767)
2062 2062
               visible="true">
2063 2063
         </separator>
2064 2064
            <command
2065
                  commandId="org.txm.rcp.commands.function.RenameResult"
2066
                  label="Rename..."
2067
                  style="push">
2068
               <visibleWhen
2069
                     checkEnabled="false">
2070
                  <reference
2071
                        definitionId="OneTXMResultSelected">
2072
                  </reference>
2073
               </visibleWhen>
2074
            </command>
2075
            <command
2065 2076
                  commandId="org.eclipse.ui.window.preferences"
2066 2077
                  icon="icons/functions/prefs.png"
2067 2078
                  label="%command.label.4"
......
2447 2458
            id="org.txm.rcp.commands.ReloadCorporaView"
2448 2459
            name="Reload">
2449 2460
      </command>
2461
      <command
2462
            defaultHandler="org.txm.rcp.commands.function.RenameResult"
2463
            id="org.txm.rcp.commands.function.RenameResult"
2464
            name="Rename TXMResult">
2465
      </command>
2450 2466
   </extension>
2451 2467
   <extension
2452 2468
         id="commands"
......
3016 3032
            schemeId="org.txm.rcp.scheme"
3017 3033
            sequence="F5">
3018 3034
      </key>
3035
      <key
3036
            commandId="org.txm.rcp.commands.function.RenameResult"
3037
            contextId="org.txm.rcp.views.corpora.CorporaView"
3038
            schemeId="org.txm.rcp.scheme"
3039
            sequence="F2">
3040
      </key>
3019 3041
   </extension>
3020 3042
   <extension
3021 3043
         point="org.eclipse.e4.ui.css.swt.theme">
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 767)
218 218
			e.printStackTrace();
219 219
		}
220 220
	}
221
	
222
	public void setUserName(String newName) {
223
		userName = newName;
224
	}
221 225

  
222 226
	/**
223 227
	 * Creates and stores an UUID dedicated to persistence of this result.
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 767)
1142 1142

  
1143 1143
		// Navigation Area: infoLine and buttons
1144 1144
		GLComposite navigationAreaComposite = getBottomToolbar().installGLComposite("navigation", 1, false);
1145
		navigationAreaComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
1146
	
1145 1147
		navigationWidget = new NavigationWidget(navigationAreaComposite, SWT.NONE);
1146 1148
		navigationWidget.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false));
1147 1149

  
tmp/org.txm.libs.jfreechart/build.properties (revision 767)
1 1
bin.includes = META-INF/,\
2 2
               lib/jfreesvg-1.7.jar,\
3 3
               about.html,\
4
               .,\
5
               lib/jcommon-1.0.21.jar,\
6
               lib/jfreechart-1.0.17.jar
4
               lib/jcommon-1.0.21.jar
5
jars.compile.order = 
7 6

  

Also available in: Unified diff