public void destroyColumnWithOption(Column column, Object option) { for (Widget widget : policy.getColumns()) { if (column.equals(widget.getData(Column.class.getName())) // && (option == null || option.equals(widget.getData(OPTIONS_KEY)))) { try { policy.setRedraw(false); widget.dispose(); } finally { policy.getViewer().refresh(); policy.setRedraw(true); } break; } } }
protected void controlChanged(Widget widget) { ComboData data = (ComboData) widget.getData(); if (widget instanceof Combo) { data.setIndex(((Combo) widget).getSelectionIndex()); } else { return; } }
private String serialize() { StringBuilder buf = new StringBuilder(); Widget sortedColumn = policy.getSortColumn(); for (int index : policy.getColumnOrder()) { Widget col = policy.getColumn(index); Column column = (Column) col.getData(Column.class.getName()); buf.append(column.getId()).append('='); Object option = col.getData(OPTIONS_KEY); if (option != null) buf.append(option).append('|'); if (col.equals(sortedColumn)) buf.append(policy.getSortDirection()).append('$'); buf.append(policy.getWidth(col)).append(';'); } return buf.toString(); }
private void doRemoveGroup(String group) { try { policy.setRedraw(false); for (Widget col : policy.getColumns()) { Column column = (Column) col.getData(Column.class.getName()); if (group.equals(column.getGroupLabel())) col.dispose(); } } finally { policy.getViewer().refresh(); policy.setRedraw(true); } }
@Override protected List getSelectionFromWidget() { if (virtualManager != null) { return getVirtualSelection(); } Widget[] items = doGetSelection(); ArrayList list = new ArrayList(items.length); for (int i = 0; i < items.length; i++) { Widget item = items[i]; Object e = item.getData(); if (e != null) { list.add(e); } } return list; }
/* (non-Javadoc) * @see edu.berkeley.eduride.isa.ui.viewsupport.ResourceToItemsMapper.IContentViewerAccessor#doUpdateItem(org.eclipse.swt.widgets.Widget) */ public void doUpdateItem(Widget item) { doUpdateItem(item, item.getData(), true); }
@Override public void menuAboutToShow(IMenuManager manager) { final Map<Column, List<Object>> visible = new HashMap<Column, List<Object>>(); for (Widget col : policy.getColumns()) { Column column = (Column) col.getData(Column.class.getName()); if (column.hasOptions()) { List<Object> options = visible.get(column); if (options == null) { options = new ArrayList<Object>(); visible.put(column, options); } options.add(col.getData(OPTIONS_KEY)); } else { visible.put(column, null); } } Map<String, IMenuManager> groups = new HashMap<String, IMenuManager>(); for (final Column column : columns) { IMenuManager managerToAdd = manager; // create a sub-menu for each group label if (column.getGroupLabel() != null) { managerToAdd = groups.get(column.getGroupLabel()); if (managerToAdd == null) { managerToAdd = new MenuManager(column.getGroupLabel()); groups.put(column.getGroupLabel(), managerToAdd); manager.add(managerToAdd); } } if (column.hasOptions()) { List<Object> options = visible.get(column); MenuManager subMenu = new MenuManager(column.getMenuLabel()); for (final Object option : column.getOptions()) { boolean isVisible = options != null && options.contains(option); String label = MessageFormat.format(column.getOptionsMenuLabel(), option); addShowHideAction(subMenu, column, label, isVisible, option); } managerToAdd.add(subMenu); } else { addShowHideAction( managerToAdd, column, column.getMenuLabel(), visible.containsKey(column), null); } } addMenuAddGroup(groups, visible); manager.add(new Separator()); manager.add( new Action(Messages.MenuResetColumns) { @Override public void run() { doResetColumns(); } }); }