use of com.twinsoft.convertigo.eclipse.editors.connector.htmlconnector.TwsDomTree.MenuMaker in project convertigo by convertigo.
the class XpathEvaluatorComposite method makeShowInBrowserMenuMaker.
protected MenuMaker makeShowInBrowserMenuMaker() {
return new MenuMaker() {
public void makeMenu(final TwsDomTree tree, TreeItem treeItem, MouseEvent e, Menu menu) {
if (e.button == 3 && treeItem != null) {
final Object object = treeItem.getData();
if (object instanceof Node) {
MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText("Show in browser");
item.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String newXpath = makeAbsoluteXPath((Node) object);
setSelectedXpath(newXpath);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
}
}
};
}
use of com.twinsoft.convertigo.eclipse.editors.connector.htmlconnector.TwsDomTree.MenuMaker in project convertigo by convertigo.
the class HtmlXpathEvaluatorComposite method makeStatementGeneratorsMenuMaker.
public MenuMaker makeStatementGeneratorsMenuMaker(final boolean overwrite) {
return new MenuMaker() {
public void makeMenu(final TwsDomTree tree, TreeItem treeItem, MouseEvent e, Menu menu) {
if (e.button == 3 && treeItem != null) {
Object object = treeItem.getData();
final TreeItem ti = treeItem;
if (object instanceof Node) {
final Node node = (Node) object;
if (overwrite || lastEval != null) {
Element element = null;
if (node instanceof Attr) {
Attr attribut = (Attr) node;
element = attribut.getOwnerElement();
} else if (overwrite) {
MenuItem item1 = new MenuItem(menu, SWT.NONE);
item1.setText("Select attributes in order to generate statement(s) in the selected statement container.");
return;
}
if (node instanceof Element || element != null) {
if (element == null)
element = (Element) node;
if (element.getTagName().equalsIgnoreCase("A") || element.getTagName().equalsIgnoreCase("INPUT") || element.getTagName().equalsIgnoreCase("TEXTAREA") || element.getTagName().equalsIgnoreCase("SELECT") || element.getTagName().equalsIgnoreCase("FORM")) {
Object selected = htmlDesign.getProjectExplorerView().getFirstSelectedDatabaseObject();
if (selected instanceof StatementWithExpressions) {
final StatementWithExpressions block = (StatementWithExpressions) selected;
boolean clickable = false, valuable = false, checkable = false, selectable = false, radioable = false, formable = false;
if (element.getTagName().equalsIgnoreCase("A")) {
clickable = true;
} else if (element.getTagName().equalsIgnoreCase("INPUT")) {
String type = element.getAttribute("type");
// warning, must be sort
clickable = Arrays.binarySearch(new String[] { "button", "checkbox", "radio", "submit" }, type) > -1;
// warning, must be sort
valuable = Arrays.binarySearch(new String[] { "", "password", "text" }, type) > -1;
// warning, must be sort
checkable = Arrays.binarySearch(new String[] { "checkbox", "radio" }, type) > -1;
radioable = type.equals("radio");
} else if (element.getTagName().equalsIgnoreCase("TEXTAREA")) {
valuable = true;
} else if (element.getTagName().equalsIgnoreCase("SELECT")) {
selectable = true;
} else if (element.getTagName().equalsIgnoreCase("FORM")) {
formable = true;
}
final String[] etats = new String[] { clickable ? "Generate mouse statement on this " + element.getTagName() : null, valuable ? "Generate set value statement on this " + element.getTagName() : null, checkable ? "Generate set checked statement on this " + element.getTagName() : null, selectable ? "Generate set selected statement on this " + element.getTagName() : null, radioable ? "Generate set checked statement for this radio group" : null, formable ? "Generate statements from FORM" : null };
for (int i = 0; i < etats.length; i++) {
if (etats[i] != null) {
final Integer index = Integer.valueOf(i);
MenuItem item2 = new MenuItem(menu, SWT.NONE);
item2.setText(etats[i]);
item2.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
TreeItem[] sel = ti.getParent().getSelection();
String xpath = overwrite ? generateSelectionXpath(sel) : lastEval;
int id = index.intValue();
try {
switch(id) {
/*clickable*/
case 0:
((XulWebViewerImpl) htmlDesign.getWebViewer()).generateMouseStatement(block, xpath);
break;
/*valuable */
case 1:
((XulWebViewerImpl) htmlDesign.getWebViewer()).generateSetInputStatement(block, xpath);
break;
/*checkable*/
case 2:
((XulWebViewerImpl) htmlDesign.getWebViewer()).generateSetCheckableStatement(block, xpath, false);
break;
/*selectable*/
case 3:
((XulWebViewerImpl) htmlDesign.getWebViewer()).generateSetSelectStatement(block, xpath);
break;
/*radioable*/
case 4:
((XulWebViewerImpl) htmlDesign.getWebViewer()).generateSetCheckableStatement(block, xpath, true);
break;
/*formable*/
case 5:
((XulWebViewerImpl) htmlDesign.getWebViewer()).generateFormElements(block, xpath);
break;
}
} catch (EngineException e1) {
ConvertigoPlugin.logException(e1, "Error when generate statement for this xPath : " + xpath);
ConvertigoPlugin.warningMessageBox("Error when generate statement for this xPath : " + xpath);
} catch (Exception e1) {
ConvertigoPlugin.logException(e1, "Error when generate statement for this xPath : " + xpath);
}
try {
htmlDesign.getProjectExplorerView().reloadDatabaseObject(block.getParentTransaction());
} catch (EngineException e1) {
ConvertigoPlugin.logException(e1, "Error when reload explorer view tree");
} catch (IOException e1) {
ConvertigoPlugin.logException(e1, "Error when reload explorer view tree");
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
}
}
} else {
MenuItem item1 = new MenuItem(menu, SWT.NONE);
item1.setText("Select a handler in project explorer to be able to generate statements automatically.");
}
} else {
MenuItem item1 = new MenuItem(menu, SWT.NONE);
item1.setText("Select a 'A', 'INPUT', 'TEXTAREA', 'SELECT' or 'FORM' element to be able to generate statements automatically.");
}
}
}
}
}
}
};
}
use of com.twinsoft.convertigo.eclipse.editors.connector.htmlconnector.TwsDomTree.MenuMaker in project convertigo by convertigo.
the class XpathEvaluatorComposite method makeXPathMenuMaker.
public MenuMaker makeXPathMenuMaker(final boolean overwrite) {
return new MenuMaker() {
public void makeMenu(final TwsDomTree tree, TreeItem treeItem, MouseEvent e, Menu menu) {
if ((e.button == 3) && (treeItem != null)) {
Object object = treeItem.getData();
if (object instanceof Node) {
final Node node = (Node) object;
MenuItem item;
if (overwrite || lastEval != null) {
if (canGenerateSelectionXpath(overwrite, node)) {
// check if show SelectionMenu is necessary
item = new MenuItem(menu, SWT.NONE);
item.setText("Generate selection Xpath (Enter)");
item.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
generateSelectionXpath(overwrite, tree);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
item = new MenuItem(menu, SWT.NONE);
item.setText("Generate absolute Xpath (Shift+Enter)");
item.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
generateAbsoluteXpath(overwrite, node);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
}
}
}
};
}
Aggregations