Révision 2491
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/ViewPropertySelectionDialog.java (revision 2491) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.rcp.swt.dialog; |
|
| 29 |
|
|
| 30 |
import java.util.ArrayList; |
|
| 31 |
import java.util.List; |
|
| 32 |
|
|
| 33 |
import org.eclipse.jface.dialogs.Dialog; |
|
| 34 |
import org.eclipse.jface.window.IShellProvider; |
|
| 35 |
import org.eclipse.swt.SWT; |
|
| 36 |
import org.eclipse.swt.events.MouseAdapter; |
|
| 37 |
import org.eclipse.swt.events.MouseEvent; |
|
| 38 |
import org.eclipse.swt.events.SelectionAdapter; |
|
| 39 |
import org.eclipse.swt.events.SelectionEvent; |
|
| 40 |
import org.eclipse.swt.layout.GridData; |
|
| 41 |
import org.eclipse.swt.layout.GridLayout; |
|
| 42 |
import org.eclipse.swt.widgets.Button; |
|
| 43 |
import org.eclipse.swt.widgets.Composite; |
|
| 44 |
import org.eclipse.swt.widgets.Control; |
|
| 45 |
import org.eclipse.swt.widgets.Shell; |
|
| 46 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 47 |
import org.txm.searchengine.cqp.corpus.Property; |
|
| 48 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
| 49 |
|
|
| 50 |
// TODO: Auto-generated Javadoc |
|
| 51 |
/** |
|
| 52 |
* The dialog box called to select the view properties. |
|
| 53 |
* |
|
| 54 |
* @ author mdecorde |
|
| 55 |
*/ |
|
| 56 |
public class ViewPropertySelectionDialog<P extends Property> extends Dialog {
|
|
| 57 |
|
|
| 58 |
/** The available properties. */ |
|
| 59 |
final private List<P> availableProperties; |
|
| 60 |
|
|
| 61 |
/** The selected properties. */ |
|
| 62 |
final private List<P> selectedProperties; |
|
| 63 |
|
|
| 64 |
/** The maxprops. */ |
|
| 65 |
int maxprops = -1; |
|
| 66 |
|
|
| 67 |
/** The available properties view. */ |
|
| 68 |
org.eclipse.swt.widgets.List availablePropertiesView; |
|
| 69 |
|
|
| 70 |
/** The selected properties view. */ |
|
| 71 |
org.eclipse.swt.widgets.List selectedPropertiesView; |
|
| 72 |
|
|
| 73 |
private ArrayList<P> cancelSelectedProperties; |
|
| 74 |
|
|
| 75 |
private ArrayList<P> cancelAvailableProperties; |
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* Instantiates a new view property selection dialog. |
|
| 79 |
* |
|
| 80 |
* @param parentShell the parent shell |
|
| 81 |
* @param availableProperties the available properties |
|
| 82 |
* @param selectedProperties the selected properties |
|
| 83 |
*/ |
|
| 84 |
public ViewPropertySelectionDialog(IShellProvider parentShell, |
|
| 85 |
List<P> availableProperties, |
|
| 86 |
List<P> selectedProperties) {
|
|
| 87 |
this(parentShell.getShell(), availableProperties, selectedProperties); |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
/** |
|
| 91 |
* Instantiates a new view property selection dialog. |
|
| 92 |
* |
|
| 93 |
* @param shell the shell |
|
| 94 |
* @param availableProperties the available properties |
|
| 95 |
* @param selectedProperties the selected properties |
|
| 96 |
*/ |
|
| 97 |
public ViewPropertySelectionDialog(Shell shell, |
|
| 98 |
List<P> availableProperties, |
|
| 99 |
List<P> selectedProperties) {
|
|
| 100 |
this(shell, availableProperties, selectedProperties, -1); |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
/** |
|
| 104 |
* Instantiates a new view property selection dialog. |
|
| 105 |
* |
|
| 106 |
* @param shell the shell |
|
| 107 |
* @param availableProperties the available properties |
|
| 108 |
* @param selectedProperties the selected properties |
|
| 109 |
* @param maxprops the maxprops |
|
| 110 |
*/ |
|
| 111 |
public ViewPropertySelectionDialog(Shell shell, |
|
| 112 |
List<P> availableProperties, |
|
| 113 |
List<P> selectedProperties, int maxprops) {
|
|
| 114 |
super(shell); |
|
| 115 |
|
|
| 116 |
this.availableProperties = availableProperties; |
|
| 117 |
this.selectedProperties = selectedProperties; |
|
| 118 |
this.cancelAvailableProperties = new ArrayList<P>(availableProperties); |
|
| 119 |
this.cancelSelectedProperties = new ArrayList<P>(selectedProperties); |
|
| 120 |
|
|
| 121 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
| 122 |
this.maxprops = maxprops; |
|
| 123 |
} |
|
| 124 |
|
|
| 125 |
/** |
|
| 126 |
* Gets the selected properties. |
|
| 127 |
* |
|
| 128 |
* @return the selected properties |
|
| 129 |
*/ |
|
| 130 |
public List<P> getSelectedProperties() {
|
|
| 131 |
return selectedProperties; |
|
| 132 |
} |
|
| 133 |
|
|
| 134 |
/* (non-Javadoc) |
|
| 135 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
| 136 |
*/ |
|
| 137 |
@Override |
|
| 138 |
protected void configureShell(Shell newShell) {
|
|
| 139 |
super.configureShell(newShell); |
|
| 140 |
newShell.setText(TXMUIMessages.common_displayOptions); |
|
| 141 |
newShell.setMinimumSize(300, 200); |
|
| 142 |
} |
|
| 143 |
|
|
| 144 |
/* (non-Javadoc) |
|
| 145 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
| 146 |
*/ |
|
| 147 |
@Override |
|
| 148 |
protected Control createDialogArea(Composite parent) {
|
|
| 149 |
// parent.setLayout(new FormLayout()); |
|
| 150 |
Composite mainArea = new Composite(parent, SWT.NONE); |
|
| 151 |
mainArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
| 152 |
|
|
| 153 |
// 4 columns |
|
| 154 |
GridLayout layout = new GridLayout(4, false); |
|
| 155 |
mainArea.setLayout(layout); |
|
| 156 |
|
|
| 157 |
availablePropertiesView = new org.eclipse.swt.widgets.List(mainArea, |
|
| 158 |
SWT.BORDER | SWT.V_SCROLL); |
|
| 159 |
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
| 160 |
availablePropertiesView.setLayoutData(gridData); |
|
| 161 |
|
|
| 162 |
Composite selectionButtons = new Composite(mainArea, SWT.NONE); |
|
| 163 |
selectionButtons.setLayout(new GridLayout(1, false)); |
|
| 164 |
Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT); |
|
| 165 |
Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT); |
|
| 166 |
|
|
| 167 |
selectedPropertiesView = new org.eclipse.swt.widgets.List(mainArea, |
|
| 168 |
SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); |
|
| 169 |
gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
| 170 |
selectedPropertiesView.setLayoutData(gridData); |
|
| 171 |
|
|
| 172 |
Composite orderButtons = new Composite(mainArea, SWT.NONE); |
|
| 173 |
orderButtons.setLayout(new GridLayout(1, false)); |
|
| 174 |
Button up = new Button(orderButtons, SWT.ARROW | SWT.UP); |
|
| 175 |
Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN); |
|
| 176 |
|
|
| 177 |
select.addSelectionListener(new SelectionAdapter() {
|
|
| 178 |
@Override |
|
| 179 |
public void widgetSelected(SelectionEvent e) {
|
|
| 180 |
int index = availablePropertiesView.getSelectionIndex(); |
|
| 181 |
if (maxprops == 1) {
|
|
| 182 |
selectedProperties.add(availableProperties.get(index)); |
|
| 183 |
availableProperties.remove(index); |
|
| 184 |
|
|
| 185 |
availableProperties.add(selectedProperties.get(0)); |
|
| 186 |
selectedProperties.remove(0); |
|
| 187 |
} else {
|
|
| 188 |
if (maxprops > 0) {
|
|
| 189 |
if (selectedProperties.size() >= maxprops) |
|
| 190 |
return; |
|
| 191 |
} |
|
| 192 |
if (index >= 0) {
|
|
| 193 |
selectedProperties.add(availableProperties.get(index)); |
|
| 194 |
availableProperties.remove(index); |
|
| 195 |
} |
|
| 196 |
} |
|
| 197 |
reload(); |
|
| 198 |
availablePropertiesView.setSelection(index); |
|
| 199 |
} |
|
| 200 |
}); |
|
| 201 |
|
|
| 202 |
unselect.addSelectionListener(new SelectionAdapter() {
|
|
| 203 |
@Override |
|
| 204 |
public void widgetSelected(SelectionEvent e) {
|
|
| 205 |
deselectProperties(); |
|
| 206 |
} |
|
| 207 |
}); |
|
| 208 |
|
|
| 209 |
up.addSelectionListener(new SelectionAdapter() {
|
|
| 210 |
@Override |
|
| 211 |
public void widgetSelected(SelectionEvent e) {
|
|
| 212 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
| 213 |
if (index > 0) {
|
|
| 214 |
P selectedP = selectedProperties.get(index); |
|
| 215 |
P upperP = selectedProperties.get(index - 1); |
|
| 216 |
|
|
| 217 |
selectedProperties.set(index, upperP); |
|
| 218 |
selectedProperties.set(index - 1, selectedP); |
|
| 219 |
|
|
| 220 |
reload(); |
|
| 221 |
selectedPropertiesView.setSelection(index - 1); |
|
| 222 |
} |
|
| 223 |
} |
|
| 224 |
}); |
|
| 225 |
|
|
| 226 |
down.addSelectionListener(new SelectionAdapter() {
|
|
| 227 |
@Override |
|
| 228 |
public void widgetSelected(SelectionEvent e) {
|
|
| 229 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
| 230 |
if (index < selectedProperties.size() - 1 && index >= 0) {
|
|
| 231 |
P selectedP = selectedProperties.get(index); |
|
| 232 |
P bellowP = selectedProperties.get(index + 1); |
|
| 233 |
|
|
| 234 |
selectedProperties.set(index, bellowP); |
|
| 235 |
selectedProperties.set(index + 1, selectedP); |
|
| 236 |
|
|
| 237 |
reload(); |
|
| 238 |
selectedPropertiesView.setSelection(index + 1); |
|
| 239 |
} |
|
| 240 |
} |
|
| 241 |
}); |
|
| 242 |
|
|
| 243 |
availablePropertiesView.addMouseListener(new MouseAdapter() {
|
|
| 244 |
@Override |
|
| 245 |
public void mouseDoubleClick(MouseEvent e) {
|
|
| 246 |
|
|
| 247 |
if ( maxprops == 1) {
|
|
| 248 |
int index = availablePropertiesView.getSelectionIndex(); |
|
| 249 |
//System.out.println("dl click, maxprops="+maxprops+" idx="+index);
|
|
| 250 |
selectedProperties.add(availableProperties.get(index)); |
|
| 251 |
availableProperties.remove(index); |
|
| 252 |
|
|
| 253 |
availableProperties.add(selectedProperties.get(0)); |
|
| 254 |
selectedProperties.remove(0); |
|
| 255 |
|
|
| 256 |
reload(); |
|
| 257 |
|
|
| 258 |
} else {
|
|
| 259 |
int index = availablePropertiesView.getSelectionIndex(); |
|
| 260 |
if (index >= 0) {
|
|
| 261 |
selectedProperties.add(availableProperties.get(index)); |
|
| 262 |
availableProperties.remove(index); |
|
| 263 |
|
|
| 264 |
reload(); |
|
| 265 |
availablePropertiesView.setSelection(index); |
|
| 266 |
} |
|
| 267 |
} |
|
| 268 |
} |
|
| 269 |
}); |
|
| 270 |
|
|
| 271 |
selectedPropertiesView.addMouseListener(new MouseAdapter() {
|
|
| 272 |
@Override |
|
| 273 |
public void mouseDoubleClick(MouseEvent e) {
|
|
| 274 |
deselectProperties(); |
|
| 275 |
} |
|
| 276 |
}); |
|
| 277 |
|
|
| 278 |
reload(); |
|
| 279 |
return mainArea; |
|
| 280 |
} |
|
| 281 |
|
|
| 282 |
private void deselectProperties() {
|
|
| 283 |
if (selectedProperties.size() > 1) {
|
|
| 284 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
| 285 |
|
|
| 286 |
availableProperties.add(selectedProperties.get(index)); |
|
| 287 |
selectedProperties.remove(index); |
|
| 288 |
|
|
| 289 |
reload(); |
|
| 290 |
selectedPropertiesView.setSelection(index); |
|
| 291 |
} |
|
| 292 |
} |
|
| 293 |
|
|
| 294 |
/** |
|
| 295 |
* Reload. |
|
| 296 |
*/ |
|
| 297 |
public void reload() {
|
|
| 298 |
if (availableProperties == null) {
|
|
| 299 |
System.out.println("Error: the available properties list is NULL.");
|
|
| 300 |
return; |
|
| 301 |
} |
|
| 302 |
availablePropertiesView.removeAll(); |
|
| 303 |
for (Property property : availableProperties) {
|
|
| 304 |
//if (!property.getName().equals("id")) //$NON-NLS-1$
|
|
| 305 |
if (property instanceof StructuralUnitProperty) {
|
|
| 306 |
availablePropertiesView.add(((StructuralUnitProperty)property).getFullName()); |
|
| 307 |
} |
|
| 308 |
else {
|
|
| 309 |
availablePropertiesView.add(property.getName()); |
|
| 310 |
} |
|
| 311 |
} |
|
| 312 |
selectedPropertiesView.removeAll(); |
|
| 313 |
for (Property property : selectedProperties) {
|
|
| 314 |
//if (!property.getName().equals("id")) //$NON-NLS-1$
|
|
| 315 |
if (property instanceof StructuralUnitProperty) {
|
|
| 316 |
selectedPropertiesView.add(((StructuralUnitProperty)property).getFullName()); |
|
| 317 |
} |
|
| 318 |
else {
|
|
| 319 |
selectedPropertiesView.add(property.getName()); |
|
| 320 |
} |
|
| 321 |
} |
|
| 322 |
|
|
| 323 |
availablePropertiesView.getParent().layout(); |
|
| 324 |
} |
|
| 325 |
|
|
| 326 |
/* (non-Javadoc) |
|
| 327 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
| 328 |
*/ |
|
| 329 |
@Override |
|
| 330 |
protected void okPressed() {
|
|
| 331 |
if (selectedProperties.size() != 0) {
|
|
| 332 |
super.okPressed(); |
|
| 333 |
} |
|
| 334 |
} |
|
| 335 |
|
|
| 336 |
/* (non-Javadoc) |
|
| 337 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
| 338 |
*/ |
|
| 339 |
@Override |
|
| 340 |
protected void cancelPressed() {
|
|
| 341 |
this.selectedProperties.clear(); |
|
| 342 |
this.selectedProperties.addAll(cancelSelectedProperties); |
|
| 343 |
|
|
| 344 |
this.availableProperties.clear(); |
|
| 345 |
availableProperties.addAll(cancelAvailableProperties); |
|
| 346 |
|
|
| 347 |
super.cancelPressed(); |
|
| 348 |
} |
|
| 349 |
} |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/MultiplePropertySelectionDialog.java (revision 2491) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.rcp.swt.dialog; |
|
| 29 |
|
|
| 30 |
import java.util.ArrayList; |
|
| 31 |
import java.util.List; |
|
| 32 |
|
|
| 33 |
import org.eclipse.jface.dialogs.Dialog; |
|
| 34 |
import org.eclipse.jface.window.IShellProvider; |
|
| 35 |
import org.eclipse.swt.SWT; |
|
| 36 |
import org.eclipse.swt.events.MouseAdapter; |
|
| 37 |
import org.eclipse.swt.events.MouseEvent; |
|
| 38 |
import org.eclipse.swt.events.SelectionAdapter; |
|
| 39 |
import org.eclipse.swt.events.SelectionEvent; |
|
| 40 |
import org.eclipse.swt.layout.GridData; |
|
| 41 |
import org.eclipse.swt.layout.GridLayout; |
|
| 42 |
import org.eclipse.swt.widgets.Button; |
|
| 43 |
import org.eclipse.swt.widgets.Composite; |
|
| 44 |
import org.eclipse.swt.widgets.Control; |
|
| 45 |
import org.eclipse.swt.widgets.Shell; |
|
| 46 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 47 |
import org.txm.searchengine.cqp.corpus.Property; |
|
| 48 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
| 49 |
|
|
| 50 |
// TODO: Auto-generated Javadoc |
|
| 51 |
/** |
|
| 52 |
* The dialog box called to select the view properties. |
|
| 53 |
* |
|
| 54 |
* @ author mdecorde |
|
| 55 |
*/ |
|
| 56 |
public class MultiplePropertySelectionDialog<P extends Property> extends Dialog {
|
|
| 57 |
|
|
| 58 |
/** The available properties. */ |
|
| 59 |
final private List<P> availableProperties; |
|
| 60 |
|
|
| 61 |
/** The selected properties. */ |
|
| 62 |
final private List<P> selectedProperties; |
|
| 63 |
|
|
| 64 |
/** The maxprops. */ |
|
| 65 |
int maxprops = -1; |
|
| 66 |
|
|
| 67 |
/** The available properties view. */ |
|
| 68 |
org.eclipse.swt.widgets.List availablePropertiesView; |
|
| 69 |
|
|
| 70 |
/** The selected properties view. */ |
|
| 71 |
org.eclipse.swt.widgets.List selectedPropertiesView; |
|
| 72 |
|
|
| 73 |
private ArrayList<P> cancelSelectedProperties; |
|
| 74 |
|
|
| 75 |
private ArrayList<P> cancelAvailableProperties; |
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* Instantiates a new view property selection dialog. |
|
| 79 |
* |
|
| 80 |
* @param parentShell the parent shell |
|
| 81 |
* @param availableProperties the available properties |
|
| 82 |
* @param selectedProperties the selected properties |
|
| 83 |
*/ |
|
| 84 |
public MultiplePropertySelectionDialog(IShellProvider parentShell, |
|
| 85 |
List<P> availableProperties, |
|
| 86 |
List<P> selectedProperties) {
|
|
| 87 |
this(parentShell.getShell(), availableProperties, selectedProperties); |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
/** |
|
| 91 |
* Instantiates a new view property selection dialog. |
|
| 92 |
* |
|
| 93 |
* @param shell the shell |
|
| 94 |
* @param availableProperties the available properties |
|
| 95 |
* @param selectedProperties the selected properties |
|
| 96 |
*/ |
|
| 97 |
public MultiplePropertySelectionDialog(Shell shell, |
|
| 98 |
List<P> availableProperties, |
|
| 99 |
List<P> selectedProperties) {
|
|
| 100 |
this(shell, availableProperties, selectedProperties, -1); |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
/** |
|
| 104 |
* Instantiates a new view property selection dialog. |
|
| 105 |
* |
|
| 106 |
* @param shell the shell |
|
| 107 |
* @param availableProperties the available properties |
|
| 108 |
* @param selectedProperties the selected properties |
|
| 109 |
* @param maxprops the maxprops |
|
| 110 |
*/ |
|
| 111 |
public MultiplePropertySelectionDialog(Shell shell, |
|
| 112 |
List<P> availableProperties, |
|
| 113 |
List<P> selectedProperties, int maxprops) {
|
|
| 114 |
super(shell); |
|
| 115 |
|
|
| 116 |
this.availableProperties = availableProperties; |
|
| 117 |
this.selectedProperties = selectedProperties; |
|
| 118 |
this.cancelAvailableProperties = new ArrayList<P>(availableProperties); |
|
| 119 |
this.cancelSelectedProperties = new ArrayList<P>(selectedProperties); |
|
| 120 |
|
|
| 121 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
| 122 |
this.maxprops = maxprops; |
|
| 123 |
} |
|
| 124 |
|
|
| 125 |
/** |
|
| 126 |
* Gets the selected properties. |
|
| 127 |
* |
|
| 128 |
* @return the selected properties |
|
| 129 |
*/ |
|
| 130 |
public List<P> getSelectedProperties() {
|
|
| 131 |
return selectedProperties; |
|
| 132 |
} |
|
| 133 |
|
|
| 134 |
/* (non-Javadoc) |
|
| 135 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
| 136 |
*/ |
|
| 137 |
@Override |
|
| 138 |
protected void configureShell(Shell newShell) {
|
|
| 139 |
super.configureShell(newShell); |
|
| 140 |
newShell.setText(TXMUIMessages.common_displayOptions); |
|
| 141 |
newShell.setMinimumSize(300, 200); |
|
| 142 |
} |
|
| 143 |
|
|
| 144 |
/* (non-Javadoc) |
|
| 145 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
| 146 |
*/ |
|
| 147 |
@Override |
|
| 148 |
protected Control createDialogArea(Composite parent) {
|
|
| 149 |
// parent.setLayout(new FormLayout()); |
|
| 150 |
Composite mainArea = new Composite(parent, SWT.NONE); |
|
| 151 |
mainArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
| 152 |
|
|
| 153 |
// 4 columns |
|
| 154 |
GridLayout layout = new GridLayout(4, false); |
|
| 155 |
mainArea.setLayout(layout); |
|
| 156 |
|
|
| 157 |
availablePropertiesView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER | SWT.V_SCROLL); |
|
| 158 |
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
| 159 |
availablePropertiesView.setLayoutData(gridData); |
|
| 160 |
|
|
| 161 |
Composite selectionButtons = new Composite(mainArea, SWT.NONE); |
|
| 162 |
selectionButtons.setLayout(new GridLayout(1, false)); |
|
| 163 |
Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT); |
|
| 164 |
Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT); |
|
| 165 |
|
|
| 166 |
selectedPropertiesView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); |
|
| 167 |
gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
| 168 |
selectedPropertiesView.setLayoutData(gridData); |
|
| 169 |
|
|
| 170 |
Composite orderButtons = new Composite(mainArea, SWT.NONE); |
|
| 171 |
orderButtons.setLayout(new GridLayout(1, false)); |
|
| 172 |
Button up = new Button(orderButtons, SWT.ARROW | SWT.UP); |
|
| 173 |
Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN); |
|
| 174 |
|
|
| 175 |
select.addSelectionListener(new SelectionAdapter() {
|
|
| 176 |
@Override |
|
| 177 |
public void widgetSelected(SelectionEvent e) {
|
|
| 178 |
int index = availablePropertiesView.getSelectionIndex(); |
|
| 179 |
if (maxprops == 1) {
|
|
| 180 |
selectedProperties.add(availableProperties.get(index)); |
|
| 181 |
availableProperties.remove(index); |
|
| 182 |
|
|
| 183 |
availableProperties.add(selectedProperties.get(0)); |
|
| 184 |
selectedProperties.remove(0); |
|
| 185 |
} else {
|
|
| 186 |
if (maxprops > 0) {
|
|
| 187 |
if (selectedProperties.size() >= maxprops) |
|
| 188 |
return; |
|
| 189 |
} |
|
| 190 |
if (index >= 0) {
|
|
| 191 |
selectedProperties.add(availableProperties.get(index)); |
|
| 192 |
availableProperties.remove(index); |
|
| 193 |
} |
|
| 194 |
} |
|
| 195 |
reload(); |
|
| 196 |
availablePropertiesView.setSelection(index); |
|
| 197 |
} |
|
| 198 |
}); |
|
| 199 |
|
|
| 200 |
unselect.addSelectionListener(new SelectionAdapter() {
|
|
| 201 |
@Override |
|
| 202 |
public void widgetSelected(SelectionEvent e) {
|
|
| 203 |
deselectProperties(); |
|
| 204 |
} |
|
| 205 |
}); |
|
| 206 |
|
|
| 207 |
up.addSelectionListener(new SelectionAdapter() {
|
|
| 208 |
@Override |
|
| 209 |
public void widgetSelected(SelectionEvent e) {
|
|
| 210 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
| 211 |
if (index > 0) {
|
|
| 212 |
P selectedP = selectedProperties.get(index); |
|
| 213 |
P upperP = selectedProperties.get(index - 1); |
|
| 214 |
|
|
| 215 |
selectedProperties.set(index, upperP); |
|
| 216 |
selectedProperties.set(index - 1, selectedP); |
|
| 217 |
|
|
| 218 |
reload(); |
|
| 219 |
selectedPropertiesView.setSelection(index - 1); |
|
| 220 |
} |
|
| 221 |
} |
|
| 222 |
}); |
|
| 223 |
|
|
| 224 |
down.addSelectionListener(new SelectionAdapter() {
|
|
| 225 |
@Override |
|
| 226 |
public void widgetSelected(SelectionEvent e) {
|
|
| 227 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
| 228 |
if (index < selectedProperties.size() - 1 && index >= 0) {
|
|
| 229 |
P selectedP = selectedProperties.get(index); |
|
| 230 |
P bellowP = selectedProperties.get(index + 1); |
|
| 231 |
|
|
| 232 |
selectedProperties.set(index, bellowP); |
|
| 233 |
selectedProperties.set(index + 1, selectedP); |
|
| 234 |
|
|
| 235 |
reload(); |
|
| 236 |
selectedPropertiesView.setSelection(index + 1); |
|
| 237 |
} |
|
| 238 |
} |
|
| 239 |
}); |
|
| 240 |
|
|
| 241 |
availablePropertiesView.addMouseListener(new MouseAdapter() {
|
|
| 242 |
@Override |
|
| 243 |
public void mouseDoubleClick(MouseEvent e) {
|
|
| 244 |
|
|
| 245 |
if ( maxprops == 1) {
|
|
| 246 |
int index = availablePropertiesView.getSelectionIndex(); |
|
| 247 |
//System.out.println("dl click, maxprops="+maxprops+" idx="+index);
|
|
| 248 |
selectedProperties.add(availableProperties.get(index)); |
|
| 249 |
availableProperties.remove(index); |
|
| 250 |
|
|
| 251 |
availableProperties.add(selectedProperties.get(0)); |
|
| 252 |
selectedProperties.remove(0); |
|
| 253 |
|
|
| 254 |
reload(); |
|
| 255 |
|
|
| 256 |
} else {
|
|
| 257 |
int index = availablePropertiesView.getSelectionIndex(); |
|
| 258 |
if (index >= 0) {
|
|
| 259 |
selectedProperties.add(availableProperties.get(index)); |
|
| 260 |
availableProperties.remove(index); |
|
| 261 |
|
|
| 262 |
reload(); |
|
| 263 |
availablePropertiesView.setSelection(index); |
|
| 264 |
} |
|
| 265 |
} |
|
| 266 |
} |
|
| 267 |
}); |
|
| 268 |
|
|
| 269 |
selectedPropertiesView.addMouseListener(new MouseAdapter() {
|
|
| 270 |
@Override |
|
| 271 |
public void mouseDoubleClick(MouseEvent e) {
|
|
| 272 |
deselectProperties(); |
|
| 273 |
} |
|
| 274 |
}); |
|
| 275 |
|
|
| 276 |
reload(); |
|
| 277 |
return mainArea; |
|
| 278 |
} |
|
| 279 |
|
|
| 280 |
private void deselectProperties() {
|
|
| 281 |
if (selectedProperties.size() > 1) {
|
|
| 282 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
| 283 |
|
|
| 284 |
availableProperties.add(selectedProperties.get(index)); |
|
| 285 |
selectedProperties.remove(index); |
|
| 286 |
|
|
| 287 |
reload(); |
|
| 288 |
selectedPropertiesView.setSelection(index); |
|
| 289 |
} |
|
| 290 |
} |
|
| 291 |
|
|
| 292 |
/** |
|
| 293 |
* Reload. |
|
| 294 |
*/ |
|
| 295 |
public void reload() {
|
|
| 296 |
if (availableProperties == null) {
|
|
| 297 |
System.out.println("Error: the available properties list is NULL.");
|
|
| 298 |
return; |
|
| 299 |
} |
|
| 300 |
availablePropertiesView.removeAll(); |
|
| 301 |
for (Property property : availableProperties) {
|
|
| 302 |
//if (!property.getName().equals("id")) //$NON-NLS-1$
|
|
| 303 |
if (property instanceof StructuralUnitProperty) {
|
|
| 304 |
availablePropertiesView.add(((StructuralUnitProperty)property).getFullName()); |
|
| 305 |
} |
|
| 306 |
else {
|
|
| 307 |
availablePropertiesView.add(property.getName()); |
|
| 308 |
} |
|
| 309 |
} |
|
| 310 |
selectedPropertiesView.removeAll(); |
|
| 311 |
for (Property property : selectedProperties) {
|
|
| 312 |
//if (!property.getName().equals("id")) //$NON-NLS-1$
|
|
| 313 |
if (property instanceof StructuralUnitProperty) {
|
|
| 314 |
selectedPropertiesView.add(((StructuralUnitProperty)property).getFullName()); |
|
| 315 |
} |
|
| 316 |
else {
|
|
| 317 |
selectedPropertiesView.add(property.getName()); |
|
| 318 |
} |
|
| 319 |
} |
|
| 320 |
|
|
| 321 |
availablePropertiesView.getParent().layout(); |
|
| 322 |
} |
|
| 323 |
|
|
| 324 |
/* (non-Javadoc) |
|
| 325 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
| 326 |
*/ |
|
| 327 |
@Override |
|
| 328 |
protected void okPressed() {
|
|
| 329 |
if (selectedProperties.size() != 0) {
|
|
| 330 |
super.okPressed(); |
|
| 331 |
} |
|
| 332 |
} |
|
| 333 |
|
|
| 334 |
/* (non-Javadoc) |
|
| 335 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
| 336 |
*/ |
|
| 337 |
@Override |
|
| 338 |
protected void cancelPressed() {
|
|
| 339 |
this.selectedProperties.clear(); |
|
| 340 |
this.selectedProperties.addAll(cancelSelectedProperties); |
|
| 341 |
|
|
| 342 |
this.availableProperties.clear(); |
|
| 343 |
availableProperties.addAll(cancelAvailableProperties); |
|
| 344 |
|
|
| 345 |
super.cancelPressed(); |
|
| 346 |
} |
|
| 347 |
} |
|
| 0 | 348 | |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/SinglePropertySelectionDialog.java (revision 2491) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.rcp.swt.dialog; |
|
| 29 |
|
|
| 30 |
import java.util.ArrayList; |
|
| 31 |
import java.util.List; |
|
| 32 |
|
|
| 33 |
import org.eclipse.jface.dialogs.Dialog; |
|
| 34 |
import org.eclipse.jface.window.IShellProvider; |
|
| 35 |
import org.eclipse.swt.SWT; |
|
| 36 |
import org.eclipse.swt.events.MouseAdapter; |
|
| 37 |
import org.eclipse.swt.events.MouseEvent; |
|
| 38 |
import org.eclipse.swt.events.SelectionAdapter; |
|
| 39 |
import org.eclipse.swt.events.SelectionEvent; |
|
| 40 |
import org.eclipse.swt.layout.GridData; |
|
| 41 |
import org.eclipse.swt.layout.GridLayout; |
|
| 42 |
import org.eclipse.swt.widgets.Button; |
|
| 43 |
import org.eclipse.swt.widgets.Composite; |
|
| 44 |
import org.eclipse.swt.widgets.Control; |
|
| 45 |
import org.eclipse.swt.widgets.Shell; |
|
| 46 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 47 |
import org.txm.searchengine.cqp.corpus.Property; |
|
| 48 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
| 49 |
|
|
| 50 |
// TODO: Auto-generated Javadoc |
|
| 51 |
/** |
|
| 52 |
* The dialog box called to select the view properties. |
|
| 53 |
* |
|
| 54 |
* @ author mdecorde |
|
| 55 |
*/ |
|
| 56 |
public class SinglePropertySelectionDialog<P extends Property> extends Dialog {
|
|
| 57 |
|
|
| 58 |
/** The available properties. */ |
|
| 59 |
private List<P> allProperties; |
|
| 60 |
|
|
| 61 |
/** The available properties. */ |
|
| 62 |
private List<P> availableProperties; |
|
| 63 |
|
|
| 64 |
/** The selected properties. */ |
|
| 65 |
private List<P> selectedProperties; |
|
| 66 |
|
|
| 67 |
/** The maxprops. */ |
|
| 68 |
int maxprops = -1; |
|
| 69 |
|
|
| 70 |
/** The available properties view. */ |
|
| 71 |
org.eclipse.swt.widgets.List availablePropertiesView; |
|
| 72 |
|
|
| 73 |
private ArrayList<P> cancelSelectedProperties; |
|
| 74 |
|
|
| 75 |
private ArrayList<P> cancelAvailableProperties; |
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* Instantiates a new view property selection dialog. |
|
| 79 |
* |
|
| 80 |
* @param parentShell the parent shell |
|
| 81 |
* @param availableProperties the available properties |
|
| 82 |
* @param selectedProperties the selected properties |
|
| 83 |
*/ |
|
| 84 |
public SinglePropertySelectionDialog(IShellProvider parentShell, |
|
| 85 |
List<P> availableProperties, |
|
| 86 |
List<P> selectedProperties) {
|
|
| 87 |
this(parentShell.getShell(), availableProperties, selectedProperties); |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
/** |
|
| 91 |
* Instantiates a new view property selection dialog. |
|
| 92 |
* |
|
| 93 |
* @param shell the shell |
|
| 94 |
* @param availableProperties the available properties |
|
| 95 |
* @param selectedProperties the selected properties |
|
| 96 |
*/ |
|
| 97 |
public SinglePropertySelectionDialog(Shell shell, |
|
| 98 |
List<P> availableProperties, |
|
| 99 |
List<P> selectedProperties) {
|
|
| 100 |
this(shell, availableProperties, selectedProperties, -1); |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
/** |
|
| 104 |
* Instantiates a new view property selection dialog. |
|
| 105 |
* |
|
| 106 |
* @param shell the shell |
|
| 107 |
* @param availableProperties the available properties |
|
| 108 |
* @param selectedProperties the selected properties |
|
| 109 |
* @param maxprops the maxprops |
|
| 110 |
*/ |
|
| 111 |
public SinglePropertySelectionDialog(Shell shell, |
|
| 112 |
List<P> availableProperties, |
|
| 113 |
List<P> selectedProperties, int maxprops) {
|
|
| 114 |
super(shell); |
|
| 115 |
|
|
| 116 |
this.availableProperties = availableProperties; |
|
| 117 |
this.selectedProperties = selectedProperties; |
|
| 118 |
this.allProperties = new ArrayList<>(); |
|
| 119 |
allProperties.addAll(selectedProperties); |
|
| 120 |
allProperties.addAll(availableProperties); |
|
| 121 |
|
|
| 122 |
this.cancelAvailableProperties = new ArrayList<>(availableProperties); |
|
| 123 |
this.cancelSelectedProperties = new ArrayList<>(selectedProperties); |
|
| 124 |
|
|
| 125 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
| 126 |
this.maxprops = maxprops; |
|
| 127 |
} |
|
| 128 |
|
|
| 129 |
/** |
|
| 130 |
* Gets the selected properties. |
|
| 131 |
* |
|
| 132 |
* @return the selected properties |
|
| 133 |
*/ |
|
| 134 |
public List<P> getSelectedProperties() {
|
|
| 135 |
return selectedProperties; |
|
| 136 |
} |
|
| 137 |
|
|
| 138 |
/* |
|
| 139 |
* (non-Javadoc) |
|
| 140 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
| 141 |
*/ |
|
| 142 |
@Override |
|
| 143 |
protected void configureShell(Shell newShell) {
|
|
| 144 |
super.configureShell(newShell); |
|
| 145 |
newShell.setText(TXMUIMessages.common_displayOptions); |
|
| 146 |
newShell.setMinimumSize(300, 200); |
|
| 147 |
} |
|
| 148 |
|
|
| 149 |
/* |
|
| 150 |
* (non-Javadoc) |
|
| 151 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
| 152 |
*/ |
|
| 153 |
@Override |
|
| 154 |
protected Control createDialogArea(Composite parent) {
|
|
| 155 |
// parent.setLayout(new FormLayout()); |
|
| 156 |
Composite mainArea = new Composite(parent, SWT.NONE); |
|
| 157 |
mainArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
| 158 |
|
|
| 159 |
// 4 columns |
|
| 160 |
GridLayout layout = new GridLayout(4, false); |
|
| 161 |
mainArea.setLayout(layout); |
|
| 162 |
|
|
| 163 |
availablePropertiesView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER | SWT.V_SCROLL); |
|
| 164 |
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
| 165 |
availablePropertiesView.setLayoutData(gridData); |
|
| 166 |
|
|
| 167 |
availablePropertiesView.addMouseListener(new MouseAdapter() {
|
|
| 168 |
|
|
| 169 |
@Override |
|
| 170 |
public void mouseUp(MouseEvent e) {
|
|
| 171 |
|
|
| 172 |
int index = availablePropertiesView.getSelectionIndex(); |
|
| 173 |
|
|
| 174 |
if (selectedProperties.size() > 0) {
|
|
| 175 |
availableProperties.add(0, selectedProperties.get(0)); |
|
| 176 |
selectedProperties.remove(0); |
|
| 177 |
} |
|
| 178 |
|
|
| 179 |
selectedProperties.add(allProperties.get(index)); |
|
| 180 |
availableProperties.remove(availableProperties.indexOf(allProperties.get(index))); |
|
| 181 |
} |
|
| 182 |
}); |
|
| 183 |
|
|
| 184 |
reload(); |
|
| 185 |
return mainArea; |
|
| 186 |
} |
|
| 187 |
|
|
| 188 |
/** |
|
| 189 |
* Reload. |
|
| 190 |
*/ |
|
| 191 |
public void reload() {
|
|
| 192 |
if (allProperties == null) {
|
|
| 193 |
System.out.println("Error: the available properties list is NULL.");
|
|
| 194 |
return; |
|
| 195 |
} |
|
| 196 |
availablePropertiesView.removeAll(); |
|
| 197 |
for (Property property : allProperties) {
|
|
| 198 |
// if (!property.getName().equals("id")) //$NON-NLS-1$
|
|
| 199 |
if (property instanceof StructuralUnitProperty) {
|
|
| 200 |
availablePropertiesView.add(((StructuralUnitProperty) property).getFullName()); |
|
| 201 |
} |
|
| 202 |
else {
|
|
| 203 |
availablePropertiesView.add(property.getName()); |
|
| 204 |
} |
|
| 205 |
} |
|
| 206 |
|
|
| 207 |
availablePropertiesView.getParent().layout(); |
|
| 208 |
if (selectedProperties.size() > 0) {
|
|
| 209 |
availablePropertiesView.setSelection(allProperties.indexOf(selectedProperties.get(0))); |
|
| 210 |
} |
|
| 211 |
} |
|
| 212 |
|
|
| 213 |
/* |
|
| 214 |
* (non-Javadoc) |
|
| 215 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
| 216 |
*/ |
|
| 217 |
@Override |
|
| 218 |
protected void okPressed() {
|
|
| 219 |
if (selectedProperties.size() != 0) {
|
|
| 220 |
super.okPressed(); |
|
| 221 |
} |
|
| 222 |
} |
|
| 223 |
|
|
| 224 |
/* |
|
| 225 |
* (non-Javadoc) |
|
| 226 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
| 227 |
*/ |
|
| 228 |
@Override |
|
| 229 |
protected void cancelPressed() {
|
|
| 230 |
this.selectedProperties.clear(); |
|
| 231 |
this.selectedProperties.addAll(cancelSelectedProperties); |
|
| 232 |
|
|
| 233 |
this.availableProperties.clear(); |
|
| 234 |
availableProperties.addAll(cancelAvailableProperties); |
|
| 235 |
|
|
| 236 |
super.cancelPressed(); |
|
| 237 |
} |
|
| 238 |
} |
|
| 0 | 239 | |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/PropertiesSelector.java (revision 2491) | ||
|---|---|---|
| 43 | 43 |
import org.eclipse.swt.widgets.Listener; |
| 44 | 44 |
import org.txm.objects.CorpusBuild; |
| 45 | 45 |
import org.txm.rcp.messages.TXMUIMessages; |
| 46 |
import org.txm.rcp.swt.dialog.ViewPropertySelectionDialog; |
|
| 46 |
import org.txm.rcp.swt.dialog.MultiplePropertySelectionDialog; |
|
| 47 |
import org.txm.rcp.swt.dialog.SinglePropertySelectionDialog; |
|
| 47 | 48 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 48 | 49 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 49 | 50 |
import org.txm.searchengine.cqp.corpus.Property; |
| 50 | 51 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
| 51 | 52 |
import org.txm.utils.logger.Log; |
| 52 |
|
|
| 53 |
|
|
| 53 | 54 |
/** |
| 54 | 55 |
* Allows to choose a structural unit property. |
| 55 | 56 |
* |
| ... | ... | |
| 58 | 59 |
public class PropertiesSelector<P extends Property> extends Composite {
|
| 59 | 60 |
|
| 60 | 61 |
protected static final int MAX_LABEL_LENGHT = 25; |
| 61 |
|
|
| 62 |
|
|
| 62 | 63 |
/** The corpus. */ |
| 63 | 64 |
CQPCorpus corpus; |
| 64 | 65 |
|
| 65 | 66 |
/** The properties. */ |
| 66 |
final List<P> selectedProperties = new ArrayList<P>();
|
|
| 67 |
final List<P> selectedProperties = new ArrayList<>(); |
|
| 67 | 68 |
|
| 68 | 69 |
/** The availableProperties: the list is final because we don't want to alter the source list */ |
| 69 |
final List<P> availableProperties = new ArrayList<P>();
|
|
| 70 |
final List<P> availableProperties = new ArrayList<>(); |
|
| 70 | 71 |
|
| 71 | 72 |
/** The maxprops: the maximum number of selected properties */ |
| 72 | 73 |
int maxprops = -1; |
| 73 |
|
|
| 74 |
|
|
| 74 | 75 |
/** The properties label. */ |
| 75 | 76 |
Label propertiesLabel; |
| 76 | 77 |
|
| 77 |
/** The openeditdialog. */
|
|
| 78 |
Button openeditdialog;
|
|
| 78 |
/** The openEditDialog opens the MultiPropertySelectionDialog or SinglePropertySelectionDialog. */
|
|
| 79 |
Button openEditDialog;
|
|
| 79 | 80 |
|
| 80 | 81 |
/** The prop label. */ |
| 81 | 82 |
Label propLabel; |
| ... | ... | |
| 83 | 84 |
/** The prop separator. */ |
| 84 | 85 |
String propSeparator = " ; "; //$NON-NLS-1$ |
| 85 | 86 |
|
| 86 |
ArrayList<Listener> listeners = new ArrayList<Listener>();
|
|
| 87 |
ArrayList<Listener> listeners = new ArrayList<>(); |
|
| 87 | 88 |
|
| 88 |
|
|
| 89 |
|
|
| 90 | 89 |
/** |
| 91 | 90 |
* Instantiates a new properties selector. |
| 92 | 91 |
* |
| ... | ... | |
| 95 | 94 |
*/ |
| 96 | 95 |
public PropertiesSelector(Composite parent, int style) {
|
| 97 | 96 |
super(parent, style); |
| 98 |
|
|
| 97 |
|
|
| 99 | 98 |
this.setLayout(new GridLayout(3, false)); |
| 100 |
// = properties |
|
| 99 |
|
|
| 100 |
// "properties" |
|
| 101 | 101 |
propLabel = new Label(this, SWT.NONE); |
| 102 | 102 |
propLabel.setText(TXMUIMessages.propertiesColon); |
| 103 | 103 |
propLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, true)); |
| 104 |
|
|
| 105 |
// word_pos
|
|
| 104 |
|
|
| 105 |
// selected properties
|
|
| 106 | 106 |
propertiesLabel = new Label(this, SWT.NONE); |
| 107 | 107 |
propertiesLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true)); |
| 108 |
|
|
| 109 |
openeditdialog = new Button(this, SWT.PUSH); |
|
| 110 |
openeditdialog.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true)); |
|
| 111 |
openeditdialog.setText(TXMUIMessages.edit); |
|
| 112 |
|
|
| 113 |
openeditdialog.addSelectionListener(new SelectionListener() {
|
|
| 108 |
|
|
| 109 |
// "edit" |
|
| 110 |
openEditDialog = new Button(this, SWT.PUSH); |
|
| 111 |
openEditDialog.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true)); |
|
| 112 |
openEditDialog.setText(TXMUIMessages.edit); |
|
| 113 |
|
|
| 114 |
openEditDialog.addSelectionListener(new SelectionListener() {
|
|
| 115 |
|
|
| 114 | 116 |
@Override |
| 115 | 117 |
public void widgetSelected(SelectionEvent e) {
|
| 116 | 118 |
showEditorDialog(); |
| 117 | 119 |
refresh(); |
| 118 | 120 |
} |
| 119 |
|
|
| 121 |
|
|
| 120 | 122 |
@Override |
| 121 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 122 |
|
|
| 123 |
} |
|
| 123 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 124 | 124 |
}); |
| 125 | 125 |
} |
| 126 | 126 |
|
| 127 |
public void setButtonText(String text) {
|
|
| 128 |
if (openeditdialog != null && !openeditdialog.isDisposed()) {
|
|
| 129 |
openeditdialog.setText(text); |
|
| 130 |
} |
|
| 131 |
} |
|
| 132 |
|
|
| 133 | 127 |
/** |
| 134 | 128 |
* Instantiates a new properties selector. |
| 129 |
* |
|
| 135 | 130 |
* @param parent |
| 136 | 131 |
*/ |
| 137 | 132 |
public PropertiesSelector(Composite parent) {
|
| 138 | 133 |
this(parent, SWT.NONE); |
| 139 | 134 |
} |
| 140 | 135 |
|
| 136 |
public void setButtonText(String text) {
|
|
| 137 |
if (openEditDialog != null && !openEditDialog.isDisposed()) {
|
|
| 138 |
openEditDialog.setText(text); |
|
| 139 |
} |
|
| 140 |
} |
|
| 141 |
|
|
| 141 | 142 |
public void addSelectionListener(SelectionListener listener) {
|
| 142 |
openeditdialog.addSelectionListener(listener);
|
|
| 143 |
openEditDialog.addSelectionListener(listener);
|
|
| 143 | 144 |
} |
| 144 |
|
|
| 145 |
|
|
| 145 | 146 |
/** |
| 146 | 147 |
* Sets the max property number. |
| 147 | 148 |
* |
| ... | ... | |
| 150 | 151 |
public void setMaxPropertyNumber(int max) {
|
| 151 | 152 |
this.maxprops = max; |
| 152 | 153 |
} |
| 153 |
|
|
| 154 |
|
|
| 154 | 155 |
/** |
| 155 | 156 |
* Refresh. |
| 156 | 157 |
*/ |
| ... | ... | |
| 165 | 166 |
else {
|
| 166 | 167 |
buffer.append(propSeparator); |
| 167 | 168 |
} |
| 168 |
|
|
| 169 |
|
|
| 169 | 170 |
if (p instanceof StructuralUnitProperty) |
| 170 | 171 |
buffer.append(((StructuralUnitProperty) p).getFullName()); |
| 171 | 172 |
else |
| 172 | 173 |
buffer.append(p.getName()); |
| 173 |
|
|
| 174 |
|
|
| 174 | 175 |
} |
| 175 | 176 |
if (buffer.length() > 0) {
|
| 176 | 177 |
int l = buffer.length(); |
| ... | ... | |
| 185 | 186 |
// propertiesLabel.update(); //this line cause the SWT env to go |
| 186 | 187 |
// crazy with Ubuntu 14.04 !!! |
| 187 | 188 |
} |
| 188 |
|
|
| 189 |
|
|
| 189 | 190 |
if (!previous.equals(propertiesLabel.getText())) { // value changed !
|
| 190 | 191 |
for (Listener l : listeners) {
|
| 191 | 192 |
l.handleEvent(null); |
| 192 | 193 |
} |
| 193 | 194 |
} |
| 194 | 195 |
} |
| 195 |
|
|
| 196 |
|
|
| 196 | 197 |
/** |
| 197 | 198 |
* Show editor dialog. |
| 198 | 199 |
*/ |
| 199 | 200 |
public void showEditorDialog() {
|
| 200 |
if (availableProperties == null){
|
|
| 201 |
if (availableProperties == null) {
|
|
| 201 | 202 |
return; |
| 202 | 203 |
} |
| 203 |
new ViewPropertySelectionDialog(this.getShell(), availableProperties, selectedProperties, maxprops).open(); |
|
| 204 |
if (maxprops == 1) {
|
|
| 205 |
new SinglePropertySelectionDialog(this.getShell(), availableProperties, selectedProperties, maxprops).open(); |
|
| 206 |
} |
|
| 207 |
else {
|
|
| 208 |
new MultiplePropertySelectionDialog(this.getShell(), availableProperties, selectedProperties, maxprops).open(); |
|
| 209 |
} |
|
| 204 | 210 |
} |
| 205 |
|
|
| 211 |
|
|
| 206 | 212 |
/** |
| 207 | 213 |
* Sets the corpus. |
| 208 | 214 |
* |
| ... | ... | |
| 218 | 224 |
selectedProperties.clear(); |
| 219 | 225 |
try {
|
| 220 | 226 |
availableProperties.addAll((Collection<? extends P>) corpus.getOrderedProperties()); |
| 221 |
//availableprops.addAll(corpus.getStructuralUnitProperties()); |
|
| 227 |
// availableprops.addAll(corpus.getStructuralUnitProperties());
|
|
| 222 | 228 |
|
| 223 | 229 |
for (int i = 0; i < availableProperties.size(); i++) {
|
| 224 | 230 |
// remove TXM internal properties |
| ... | ... | |
| 227 | 233 |
i--; |
| 228 | 234 |
} |
| 229 | 235 |
} |
| 230 |
} catch (CqiClientException e) {
|
|
| 236 |
} |
|
| 237 |
catch (CqiClientException e) {
|
|
| 231 | 238 |
Log.severe(NLS.bind(TXMUIMessages.cantLoadPropertiesFromCorpusP0ColonP1, e.getMessage())); |
| 232 | 239 |
} |
| 233 | 240 |
} |
| 234 |
|
|
| 241 |
|
|
| 235 | 242 |
/** |
| 236 | 243 |
* Gets the properties. |
| 237 | 244 |
* |
| 238 | 245 |
* @return the properties |
| 239 | 246 |
*/ |
| 240 | 247 |
public List<P> getSelectedProperties() {
|
| 241 |
return new ArrayList<P>(this.selectedProperties);
|
|
| 248 |
return new ArrayList<>(this.selectedProperties); |
|
| 242 | 249 |
} |
| 243 | 250 |
|
| 244 | 251 |
/** |
| ... | ... | |
| 247 | 254 |
* @return the Available properties |
| 248 | 255 |
*/ |
| 249 | 256 |
public List<P> getAvailableProperties() {
|
| 250 |
return new ArrayList<P>(this.availableProperties);
|
|
| 257 |
return new ArrayList<>(this.availableProperties); |
|
| 251 | 258 |
} |
| 252 |
|
|
| 259 |
|
|
| 253 | 260 |
/** |
| 254 | 261 |
* Sets the properties. |
| 255 | 262 |
* |
| ... | ... | |
| 279 | 286 |
if (selected != null) this.selectedProperties.add(selected); |
| 280 | 287 |
refresh(); |
| 281 | 288 |
} |
| 282 |
|
|
| 289 |
|
|
| 283 | 290 |
/** |
| 284 |
* Sets the properties. |
|
| 291 |
* Sets the properties. |
|
| 292 |
* |
|
| 285 | 293 |
* @param available a list of properties set to the this.availableProperties list |
| 286 | 294 |
*/ |
| 287 | 295 |
public void setProperties(List<P> available) {
|
| ... | ... | |
| 290 | 298 |
|
| 291 | 299 |
/** |
| 292 | 300 |
* Sets the selected properties. |
| 301 |
* |
|
| 293 | 302 |
* @param properties |
| 294 | 303 |
*/ |
| 295 | 304 |
public void setSelectedProperties(List<P> properties) {
|
| ... | ... | |
| 302 | 311 |
|
| 303 | 312 |
/** |
| 304 | 313 |
* Sets a unique selected property according to its index. |
| 314 |
* |
|
| 305 | 315 |
* @param index |
| 306 | 316 |
*/ |
| 307 | 317 |
public void setSelectedProperty(int index) {
|
| ... | ... | |
| 310 | 320 |
|
| 311 | 321 |
/** |
| 312 | 322 |
* Sets a unique selected property. |
| 323 |
* |
|
| 313 | 324 |
* @param property |
| 314 | 325 |
*/ |
| 315 | 326 |
public void setSelectedProperty(P property) {
|
| 316 |
List<P> properties = new ArrayList<P>();
|
|
| 327 |
List<P> properties = new ArrayList<>(); |
|
| 317 | 328 |
properties.add(property); |
| 318 | 329 |
this.setSelectedProperties(properties); |
| 319 | 330 |
} |
| ... | ... | |
| 327 | 338 |
propLabel.setText(string); |
| 328 | 339 |
propLabel.update(); |
| 329 | 340 |
} |
| 330 |
|
|
| 341 |
|
|
| 331 | 342 |
/** |
| 332 | 343 |
* reset available and selected properties |
| 333 | 344 |
*/ |
| ... | ... | |
| 343 | 354 |
setTitle(""); //$NON-NLS-1$
|
| 344 | 355 |
setProperties(new ArrayList<P>(), new ArrayList<P>()); |
| 345 | 356 |
} |
| 346 |
|
|
| 357 |
|
|
| 347 | 358 |
public void addValueChangeListener(Listener listener) {
|
| 348 | 359 |
listeners.add(listener); |
| 349 | 360 |
} |
| 350 |
} |
|
| 361 |
} |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/BaseAbstractHandler.java (revision 2491) | ||
|---|---|---|
| 39 | 39 |
* |
| 40 | 40 |
*/ |
| 41 | 41 |
public abstract class BaseAbstractHandler extends AbstractHandler {
|
| 42 |
|
|
| 43 | 42 |
|
| 44 | 43 |
|
| 44 |
|
|
| 45 | 45 |
public final static String SEND_SELECTION_TO_COMMAND_CONTEXT_ID = "sendSelectionToContext"; //$NON-NLS-1$ |
| 46 | 46 |
|
| 47 |
|
|
| 48 | 47 |
|
| 48 |
|
|
| 49 | 49 |
/** |
| 50 | 50 |
* Default constructor. |
| 51 | 51 |
*/ |
| ... | ... | |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 | 56 |
/** |
| 57 |
* Checks the Statistics Engine running status and displays a message if it's not running. |
|
| 57 |
* Checks the Statistics Engine running status and displays a message if it's not running. |
|
| 58 |
* |
|
| 58 | 59 |
* @return true if the stat engine is available |
| 59 | 60 |
*/ |
| 60 |
public boolean checkStatsEngine() {
|
|
| 61 |
if(!Toolbox.getEngineManager(EngineType.STATS).isCurrentEngineAvailable()) {
|
|
| 61 |
public boolean checkStatsEngine() {
|
|
| 62 |
if (!Toolbox.getEngineManager(EngineType.STATS).isCurrentEngineAvailable()) {
|
|
| 62 | 63 |
Log.warning(StatsEngineCoreMessages.error_statsEngineNotReadyCancelingCommand); |
| 63 | 64 |
return false; |
| 64 | 65 |
} |
| ... | ... | |
| 68 | 69 |
|
| 69 | 70 |
/** |
| 70 | 71 |
* Checks the Corpus Engine running status and displays a message if it's not running. |
| 72 |
* |
|
| 71 | 73 |
* @return true if the corpus engine is available |
| 72 | 74 |
*/ |
| 73 |
public boolean checkCorpusEngine() {
|
|
| 74 |
if (!CQPSearchEngine.isInitialized()) {
|
|
| 75 |
public boolean checkCorpusEngine() {
|
|
| 76 |
if (!CQPSearchEngine.isInitialized()) {
|
|
| 75 | 77 |
Log.warning("Corpus Engine is not ready, canceling command.");
|
| 76 | 78 |
return false; |
| 77 | 79 |
} |
| ... | ... | |
| 80 | 82 |
|
| 81 | 83 |
/** |
| 82 | 84 |
* Gets the current selected object. |
| 85 |
* |
|
| 83 | 86 |
* @param event the ExecutionEvent that provoke the command call. |
| 84 | 87 |
* @return the corpora view current selection |
| 85 | 88 |
*/ |
| 86 |
public Object getCorporaViewSelectedObject(ExecutionEvent event) {
|
|
| 89 |
public Object getCorporaViewSelectedObject(ExecutionEvent event) {
|
|
| 87 | 90 |
|
| 88 |
//FIXME: check this, because it may be too linked to the Corpora view |
|
| 91 |
// FIXME: check this, because it may be too linked to the Corpora view
|
|
| 89 | 92 |
Object o = CorporaView.getFirstSelectedObject(); |
| 90 | 93 |
// otherwise use this code |
| 91 | 94 |
// yeah but selection might be tricky |
| 92 |
//Object o = (IStructuredSelection) HandlerUtil.getCurrentSelection(event).getFirstElement(); |
|
| 95 |
// Object o = (IStructuredSelection) HandlerUtil.getCurrentSelection(event).getFirstElement();
|
|
| 93 | 96 |
if (o == null) {
|
| 94 | 97 |
Log.severe("BaseAbstractHandler.getCorporaViewSelectedObject(): current selection is null.");
|
| 95 | 98 |
} |
| ... | ... | |
| 98 | 101 |
|
| 99 | 102 |
return o; |
| 100 | 103 |
} |
| 101 |
|
|
| 104 |
|
|
| 102 | 105 |
/** |
| 103 | 106 |
* Gets the current selected objects. |
| 107 |
* |
|
| 104 | 108 |
* @param event |
| 105 | 109 |
* @return |
| 106 | 110 |
*/ |
| 107 |
public List<?> getCorporaViewSelectedObjects(ExecutionEvent event) {
|
|
| 108 |
//FIXME: check this, because it may be too linked to the Corpora view |
|
| 111 |
public List<?> getCorporaViewSelectedObjects(ExecutionEvent event) {
|
|
| 112 |
// FIXME: check this, because it may be too linked to the Corpora view
|
|
| 109 | 113 |
return CorporaView.getSelectedObjects(); |
| 110 | 114 |
} |
| 111 | 115 |
|
| ... | ... | |
| 116 | 120 |
|
| 117 | 121 |
/** |
| 118 | 122 |
* Gets the result stored in the current active editor. |
| 123 |
* |
|
| 119 | 124 |
* @param event |
| 120 | 125 |
* @return |
| 121 | 126 |
*/ |
| 122 |
public static TXMResult getActiveEditorResult(ExecutionEvent event) {
|
|
| 127 |
public static TXMResult getActiveEditorResult(ExecutionEvent event) {
|
|
| 123 | 128 |
try {
|
| 124 | 129 |
return SWTEditorsUtils.getActiveEditor(event).getResult(); |
| 125 | 130 |
} |
| ... | ... | |
| 127 | 132 |
return null; |
| 128 | 133 |
} |
| 129 | 134 |
} |
| 130 |
|
|
| 131 | 135 |
|
| 136 |
|
|
| 132 | 137 |
/** |
| 133 | 138 |
* Gets the parent of the result stored in the active editor. |
| 134 | 139 |
* This parent will be send to the target command as parent of the new result. |
| 135 |
* This method is essentially dedicated to be overridden, if needed, to define a parent that is not the direct parent (eg. the corpus parent instead of the partition parent). |
|
| 140 |
* This method is essentially dedicated to be overridden, if needed, to define a parent that is not the direct parent (eg. the corpus parent instead of the partition parent). |
|
| 141 |
* |
|
| 136 | 142 |
* @param event |
| 137 | 143 |
* @return |
| 138 | 144 |
*/ |
| 139 |
public TXMResult getResultParent(ExecutionEvent event) {
|
|
| 145 |
public TXMResult getResultParent(ExecutionEvent event) {
|
|
| 140 | 146 |
return getActiveEditorResult(event).getParent(); |
| 141 | 147 |
} |
| 142 | 148 |
|
| ... | ... | |
| 144 | 150 |
|
| 145 | 151 |
/** |
| 146 | 152 |
* Logs a severe entry. |
| 153 |
* |
|
| 147 | 154 |
* @param selection |
| 148 | 155 |
*/ |
| 149 |
protected boolean logCanNotExecuteCommand(Object selection) {
|
|
| 156 |
protected boolean logCanNotExecuteCommand(Object selection) {
|
|
| 150 | 157 |
Log.severe("Can not execute command " + this.getClass() + " with the selection: " + selection + ".");
|
| 151 | 158 |
return false; |
| 152 | 159 |
} |
| ... | ... | |
| 155 | 162 |
|
| 156 | 163 |
/** |
| 157 | 164 |
* Executes a command handler specified by its id. |
| 165 |
* |
|
| 158 | 166 |
* @param commandId |
| 159 | 167 |
*/ |
| 160 | 168 |
public static void executeCommand(String commandId) {
|
| 161 | 169 |
executeCommand(commandId, null, null); |
| 162 | 170 |
} |
| 163 |
|
|
| 164 | 171 |
|
| 165 |
public static void executeCommand(String commandId, Map<String,String> params) {
|
|
| 172 |
|
|
| 173 |
public static void executeCommand(String commandId, Map<String, String> params) {
|
|
| 166 | 174 |
executeCommand(commandId, null, params); |
| 167 | 175 |
} |
| 168 | 176 |
|
| ... | ... | |
| 173 | 181 |
|
| 174 | 182 |
/** |
| 175 | 183 |
* Executes a command handler specified by its id. |
| 184 |
* |
|
| 176 | 185 |
* @param commandId |
| 177 | 186 |
* @param resultUUID |
| 178 | 187 |
*/ |
| 179 |
public static void executeCommand(String commandId, String resultUUID, Map<String,String> params) {
|
|
| 188 |
public static void executeCommand(String commandId, String resultUUID, Map<String, String> params) {
|
|
| 180 | 189 |
|
| 181 | 190 |
Log.fine("BaseAbstractHandler.executeCommand(): calling command " + commandId + ".");
|
| 182 | 191 |
|
| 183 | 192 |
|
| 184 | 193 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
| 185 |
ICommandService cmdService = (ICommandService)window.getService(ICommandService.class);
|
|
| 194 |
ICommandService cmdService = window.getService(ICommandService.class); |
|
| 186 | 195 |
Command cmd = cmdService.getCommand(commandId); |
| 187 |
IHandlerService handlerService = (IHandlerService)window.getService(IHandlerService.class);
|
|
| 196 |
IHandlerService handlerService = window.getService(IHandlerService.class); |
|
| 188 | 197 |
|
| 189 | 198 |
// Redefine the command supported parameters, without that each command must define the parameter "result_parameters_node_path" in each plugin.xml... |
| 190 |
if(resultUUID != null) {
|
|
| 199 |
if (resultUUID != null) {
|
|
| 191 | 200 |
Log.fine("BaseAbstractHandler.executeCommand(): preparing the send of result UUID: " + resultUUID + ".");
|
| 192 | 201 |
try {
|
| 193 |
IParameter[] parameters = new IParameter[]{ new IParameter() {
|
|
| 202 |
IParameter[] parameters = new IParameter[] { new IParameter() {
|
|
| 194 | 203 |
|
| 195 | 204 |
@Override |
| 196 | 205 |
public boolean isOptional() {
|
| ... | ... | |
| 211 | 220 |
public String getId() {
|
| 212 | 221 |
return TXMPreferences.RESULT_PARAMETERS_NODE_PATH; |
| 213 | 222 |
} |
| 214 |
}}; |
|
| 223 |
} };
|
|
| 215 | 224 |
cmd.define(cmd.getName(), cmd.getDescription(), cmd.getCategory(), parameters); |
| 216 | 225 |
} |
| 217 | 226 |
catch (NotDefinedException e) {
|
| ... | ... | |
| 222 | 231 |
} |
| 223 | 232 |
|
| 224 | 233 |
// Call the command with parameters |
| 225 |
if(params != null) {
|
|
| 234 |
if (params != null) {
|
|
| 226 | 235 |
try {
|
| 227 | 236 |
ParameterizedCommand pc = ParameterizedCommand.generateCommand(cmd, params); |
| 228 | 237 |
handlerService.executeCommand(pc, null); |
| 229 |
} catch (Exception e) {
|
|
| 238 |
} |
|
| 239 |
catch (Exception e) {
|
|
| 230 | 240 |
e.printStackTrace(); |
| 231 | 241 |
} |
| 232 |
|
|
| 242 |
|
|
| 233 | 243 |
} |
| 234 | 244 |
// Call the command without parameters |
| 235 |
else {
|
|
| 245 |
else {
|
|
| 236 | 246 |
try {
|
| 237 | 247 |
handlerService.executeCommand(cmd.getId(), null); |
| 238 | 248 |
} |
| ... | ... | |
| 240 | 250 |
e.printStackTrace(); |
| 241 | 251 |
} |
| 242 | 252 |
} |
| 243 |
|
|
| 244 |
|
|
| 245 |
} |
|
| 246 |
|
|
| 253 |
} |
|
| 247 | 254 |
|
| 255 |
|
|
| 248 | 256 |
/** |
| 249 | 257 |
* Executes a command handler specified by its id and activates/deactivates the "send selection context". |
| 258 |
* |
|
| 250 | 259 |
* @param commandId |
Formats disponibles : Unified diff