use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class DesignerPalette method getVisualCategory.
/**
* @return the {@link ICategory} for given {@link CategoryInfo}.
*/
private ICategory getVisualCategory(final CategoryInfo categoryInfo) {
ICategory category = m_categoryInfoToVisual.get(categoryInfo);
if (category == null) {
final String categoryId = categoryInfo.getId();
category = new ICategory() {
private boolean m_open;
@Override
public List<IEntry> getEntries() {
final List<EntryInfo> entryInfoList = Lists.newArrayList(categoryInfo.getEntries());
// add new EntryInfo's using broadcast
ExecutionUtils.runIgnore(new RunnableEx() {
@Override
public void run() throws Exception {
getBroadcastPalette().entries(categoryInfo, entryInfoList);
}
});
// convert EntryInfo's into IEntry's
List<IEntry> entries = Lists.newArrayList();
for (EntryInfo entryInfo : entryInfoList) {
if (entryInfo.isVisible()) {
IEntry entry = getVisualEntry(entryInfo);
if (entry != null) {
entries.add(entry);
}
}
}
return entries;
}
@Override
public String getText() {
return categoryInfo.getName();
}
@Override
public String getToolTipText() {
return categoryInfo.getDescription();
}
@Override
public boolean isOpen() {
return m_open;
}
@Override
public void setOpen(boolean open) {
m_open = open;
m_openCategories.put(categoryId, open);
}
};
m_categoryInfoToVisual.put(categoryInfo, category);
m_visualToCategoryInfo.put(category, categoryInfo);
// set "open" state: from map, or default
if (m_openCategories.containsKey(categoryId)) {
category.setOpen(m_openCategories.get(categoryId));
} else {
category.setOpen(categoryInfo.isOpen());
}
}
return category;
}
use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class DesignerPalette method showPalette.
/**
* Shows current {@link PaletteInfo}.
*/
private void showPalette() {
clearEntryCaches();
// set IPalette
IPalette palette = new IPalette() {
@Override
public List<ICategory> getCategories() {
// check for skipping palette during tests
if (System.getProperty(FLAG_NO_PALETTE) != null) {
return ImmutableList.of();
}
// get categories for palette model
final List<CategoryInfo> categoryInfoList;
{
List<CategoryInfo> pristineCategories = m_manager.getPalette().getCategories();
categoryInfoList = Lists.newArrayList(pristineCategories);
}
// add new CategoryInfo's using broadcast
ExecutionUtils.runLog(new RunnableEx() {
@Override
public void run() throws Exception {
getBroadcastPalette().categories(categoryInfoList);
getBroadcastPalette().categories2(categoryInfoList);
}
});
// convert CategoryInfo's into ICategory's
List<ICategory> categories = Lists.newArrayList();
for (CategoryInfo categoryInfo : categoryInfoList) {
if (shouldBeDisplayed(categoryInfo)) {
ICategory category = getVisualCategory(categoryInfo);
categories.add(category);
}
}
return categories;
}
@Override
public void addPopupActions(IMenuManager menuManager, Object target) {
new DesignerPalettePopupActions(getOperations()).addPopupActions(menuManager, target);
}
@Override
public void selectDefault() {
m_editPartViewer.getEditDomain().loadDefaultTool();
}
@Override
public void moveCategory(ICategory _category, ICategory _nextCategory) {
CategoryInfo category = m_visualToCategoryInfo.get(_category);
CategoryInfo nextCategory = m_visualToCategoryInfo.get(_nextCategory);
commands_addWrite(new CategoryMoveCommand(category, nextCategory));
}
@Override
public void moveEntry(IEntry _entry, ICategory _targetCategory, IEntry _nextEntry) {
EntryInfo entry = m_visualToEntryInfo.get(_entry);
CategoryInfo category = m_visualToCategoryInfo.get(_targetCategory);
EntryInfo nextEntry = m_visualToEntryInfo.get(_nextEntry);
commands_addWrite(new EntryMoveCommand(entry, category, nextEntry));
}
};
m_paletteComposite.setPalette(palette);
configure_EditDomain_DefaultTool();
}
use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class PaletteManager method commandsRead_fromStream0.
private void commandsRead_fromStream0(InputStream inputStream) throws Exception {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(inputStream, new DefaultHandler() {
@Override
public void startElement(String uri, String localName, final String name, final Attributes attributes) {
ExecutionUtils.runIgnore(new RunnableEx() {
@Override
public void run() throws Exception {
commandsRead_singleCommand(name, attributes);
}
});
}
});
}
use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class DefaultMultiMode method createTabFolder.
// //////////////////////////////////////////////////////////////////////////
//
// GUI
//
// //////////////////////////////////////////////////////////////////////////
/**
* Create tab folder for pages.
*/
protected final void createTabFolder(Composite parent) {
m_folder = new CTabFolder(parent, SWT.BOTTOM);
TabFolderDecorator.decorate(m_editor, m_folder);
m_folder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showPage((IEditorPage) e.item.getData());
}
});
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199499
// Switching tabs by Ctrl+PageUp/PageDown must not be caught on the inner tab set
m_folder.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
switch(e.detail) {
case SWT.TRAVERSE_PAGE_NEXT:
case SWT.TRAVERSE_PAGE_PREVIOUS:
final int detail = e.detail;
e.doit = true;
e.detail = SWT.TRAVERSE_NONE;
// 3.6+
ExecutionUtils.runIgnore(new RunnableEx() {
@Override
public void run() throws Exception {
Control control = m_folder.getParent();
ReflectionUtils.invokeMethod(control, "traverse(int,org.eclipse.swt.widgets.Event)", detail, new Event());
}
});
}
}
});
}
use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class JavaPropertiesToolBarContributor method addVariableConvertAction.
private void addVariableConvertAction(IToolBarManager manager, List<ObjectInfo> objects) {
if (objects.size() == 1 && objects.get(0) instanceof JavaInfo) {
final JavaInfo javaInfo = (JavaInfo) objects.get(0);
final VariableSupport variableSupport = javaInfo.getVariableSupport();
// prepare action
IAction variableConvertAction = new Action() {
@Override
public void run() {
ExecutionUtils.run(javaInfo, new RunnableEx() {
@Override
public void run() throws Exception {
if (variableSupport.canConvertLocalToField()) {
variableSupport.convertLocalToField();
} else if (variableSupport.canConvertFieldToLocal()) {
variableSupport.convertFieldToLocal();
}
}
});
}
};
boolean enabled = false;
// to field
if (variableSupport.canConvertLocalToField()) {
variableConvertAction.setImageDescriptor(DesignerPlugin.getImageDescriptor("structure/local_to_field.gif"));
variableConvertAction.setToolTipText(Messages.ComponentsPropertiesPage_convertLocalToFieldAction);
enabled = true;
}
// to local
if (!enabled && variableSupport.canConvertFieldToLocal()) {
variableConvertAction.setImageDescriptor(DesignerPlugin.getImageDescriptor("structure/field_to_local.gif"));
variableConvertAction.setToolTipText(Messages.ComponentsPropertiesPage_convertFieldToLocalAction);
enabled = true;
}
// append action
if (enabled) {
manager.appendToGroup(GROUP_EDIT, variableConvertAction);
}
}
}
Aggregations