use of org.eclipse.wb.internal.core.model.property.JavaProperty in project windowbuilder by eclipse.
the class StringsAddPropertyEditor method setItems.
/**
* Sets new items into given {@link Property}.
*/
void setItems(Property _property, final String[] items) throws Exception {
final JavaInfo javaInfo = ((JavaProperty) _property).getJavaInfo();
ExecutionUtils.run(javaInfo, new RunnableEx() {
@Override
public void run() throws Exception {
setItems0(items, javaInfo);
}
});
}
use of org.eclipse.wb.internal.core.model.property.JavaProperty in project windowbuilder by eclipse.
the class PropertyTest method test_JavaProperty_getTitle.
/**
* Test for {@link JavaProperty#getTitle()}.
*/
public void test_JavaProperty_getTitle() throws Exception {
ContainerInfo panel = parseContainer("// filler filler filler", "public class Test extends JPanel {", " public Test() {", " }", "}");
JavaProperty property = (JavaProperty) panel.getPropertyByTitle("enabled");
// default title
assertEquals("enabled", property.getTitle());
// update title
property.setTitle("newTitle");
assertEquals("newTitle", property.getTitle());
}
use of org.eclipse.wb.internal.core.model.property.JavaProperty in project windowbuilder by eclipse.
the class PropertyTest method test_JavaProperty_getJavaInfo.
// //////////////////////////////////////////////////////////////////////////
//
// JavaProperty
//
// //////////////////////////////////////////////////////////////////////////
/**
* Test for {@link JavaProperty#getJavaInfo()}.
*/
public void test_JavaProperty_getJavaInfo() throws Exception {
ContainerInfo panel = parseContainer("// filler filler filler", "public class Test extends JPanel {", " public Test() {", " }", "}");
JavaProperty property = (JavaProperty) panel.getPropertyByTitle("enabled");
//
assertSame(panel, property.getObjectInfo());
assertSame(panel, property.getJavaInfo());
assertSame(panel, property.getAdapter(ObjectInfo.class));
}
use of org.eclipse.wb.internal.core.model.property.JavaProperty in project windowbuilder by eclipse.
the class TableViewerColumnSorterPropertyEditor method doubleClick.
// //////////////////////////////////////////////////////////////////////////
//
// Editing
//
// //////////////////////////////////////////////////////////////////////////
@Override
public void doubleClick(Property _property, Point location) throws Exception {
JavaProperty property = (JavaProperty) _property;
final JavaInfo javaInfo = property.getJavaInfo();
ASTNode node = (ASTNode) property.getValue();
// open in source, if exists
if (node != null) {
IDesignPageSite site = IDesignPageSite.Helper.getSite(javaInfo);
if (site != null) {
site.openSourcePosition(node.getStartPosition());
}
return;
}
// no sorter, generate
AstEditor editor = javaInfo.getEditor();
ProjectUtils.ensureResourceType(editor.getJavaProject(), Activator.getDefault().getBundle(), "org.eclipse.wb.swt.TableViewerColumnSorter");
ExecutionUtils.run(javaInfo, new RunnableEx() {
@Override
public void run() throws Exception {
String source = CodeUtils.getSource("new org.eclipse.wb.swt.TableViewerColumnSorter(" + TemplateUtils.getExpression(javaInfo) + ") {", "\t@Override", "\tprotected int doCompare(org.eclipse.jface.viewers.Viewer viewer, Object e1, Object e2) {", "\t\t// TODO Remove this method, if your getValue(Object) returns Comparable.", "\t\t// Typical Comparable are String, Integer, Double, etc.", "\t\treturn super.doCompare(viewer, e1, e2);", "\t}", "\t@Override", "\tprotected Object getValue(Object o) {", "\t\t// TODO remove this method, if your EditingSupport returns value", "\t\treturn super.getValue(o);", "\t}", "}");
javaInfo.addExpressionStatement(source);
}
});
// open in source
doubleClick(_property, location);
}
use of org.eclipse.wb.internal.core.model.property.JavaProperty in project windowbuilder by eclipse.
the class StringsAddPropertyEditor method getItems.
// //////////////////////////////////////////////////////////////////////////
//
// Items
//
// //////////////////////////////////////////////////////////////////////////
/**
* @return the items specified in value of given {@link Property}.
*/
String[] getItems(Property _property) throws Exception {
JavaInfo javaInfo = ((JavaProperty) _property).getJavaInfo();
// prepare "add" invocations
List<MethodInvocation> invocations;
{
invocations = javaInfo.getMethodInvocations(m_addMethodSignature);
ExecutionFlowDescription flowDescription = EditorState.get(javaInfo.getEditor()).getFlowDescription();
JavaInfoUtils.sortNodesByFlow(flowDescription, false, invocations);
}
// fill items
List<String> items = Lists.newArrayList();
for (MethodInvocation invocation : invocations) {
Expression itemExpression = DomGenerics.arguments(invocation).get(0);
String item = (String) JavaInfoEvaluationHelper.getValue(itemExpression);
items.add(item);
}
// return as array
return items.toArray(new String[items.size()]);
}
Aggregations