blob: fdbedfdd53777a244b36710dbb339f662c1f0611 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*******************************************************************************
* Copyright (c) 2004, 2008 John Krasnay and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Krasnay - initial API and implementation
*******************************************************************************/
package org.eclipse.vex.ui.internal.handlers;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.vex.core.internal.css.CSS;
import org.eclipse.vex.core.internal.css.StyleSheet;
import org.eclipse.vex.core.internal.dom.Node;
import org.eclipse.vex.core.internal.layout.Box;
import org.eclipse.vex.core.internal.layout.TableRowBox;
import org.eclipse.vex.core.internal.widget.IBoxFilter;
import org.eclipse.vex.ui.internal.swt.VexWidget;
/**
* Splits the nearest enclosing table row or list item (usually by hitting {@code Shift+Return}). If a table row is
* being split, empty versions of the current row's cells are created.
*
* @see SplitBlockElementHandler
*/
public class SplitItemHandler extends SplitBlockElementHandler {
@Override
public void execute(final VexWidget widget) throws ExecutionException {
final StyleSheet ss = widget.getStyleSheet();
// Item is either a TableRowBox or a BlockElementBox representing
// a list item
final Box item = widget.findInnermostBox(new IBoxFilter() {
public boolean matches(final Box box) {
if (box instanceof TableRowBox) {
return true;
} else {
final Node node = box.getNode();
return node != null && ss.getStyles(node).getDisplay().equals(CSS.LIST_ITEM);
}
}
});
if (item instanceof TableRowBox) {
new AddRowBelowHandler().execute(widget);
// VexHandlerUtil.duplicateTableRow(vexWidget, (TableRowBox) item);
} else if (item != null) {
splitElement(widget, item.getNode());
}
}
}
|