use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.
the class ProjectUI method computeColumnArea.
protected Rectangle computeColumnArea(TreeColumn column) {
if (column != null) {
Point size = tree.getSize();
Rectangle treeArea = new Rectangle(0, 0, size.x, size.y);
int[] columnOrdering = uiModel.getCurrentDesignOrdering();
int i = 0;
TreeColumn nextCol = tree.getColumn(i++);
while (nextCol != column) {
treeArea.x += nextCol.getWidth();
// if (OSUtils.MACOSX) {
// // XXX: dirty hacks around SWT bugs
// treeArea.x += 30;
// }
nextCol = tree.getColumn(columnOrdering[i++]);
}
treeArea.width = column.getWidth();
if (OSUtils.MACOSX) {
// XXX: dirty hacks around SWT bugs
int off = ((numExpandedLevels(tree.getItems()) - 1) * 24);
treeArea.x += off;
// treeArea.width += 1;
treeArea.y += 1;
treeArea.height -= 16;
treeArea.x += 4;
}
return treeArea;
}
return null;
}
use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.
the class ProjectUI method showContextMenu.
// Override to set the correct context menu on the frame
// item item-selected column design where selection to use
//(a) ok n/a ok ok cell temporary cell
//(b) ok yes ok null task normal selection
//(c) ok no ok null task temporary task
//(d) ok n/a null n/a right of cells temporary task
//(e) null n/a ok ok design temporary design
//(f) null n/a ok null bottom-left no selection
//(g) null n/a null n/a bottom-right no selection
// TODO: dfm -- make the code match the above!!!!!
@Override
public void showContextMenu(int x, int y) {
// Clear any stale state
contextSelection.deselectAll();
// Check which region of the frame was hit
TreeItem item = tree.getItem(new Point(x, y));
TreeColumn column = findColumn(x);
// See if the context invocation was made beyond all designs
if (column == null) {
if (item == null) {
// see (g) above
showContextMenu();
} else {
// see (d) above
selectOverBox(item.getBounds());
contextSelection.addSelectedTask((AUndertaking) item.getData());
showContextMenu(contextSelection, View.CONTEXT);
}
} else // If not, the invocation occurred somewhere within the table
{
Design design = (Design) column.getData();
// Detect a context invocation in the table header/footer
if (item == null) {
// Detect a context invocation under the "tasks" heading
if (design == null) {
// see (f) above
showContextMenu();
} else // Otherwise the invocation lies under a design heading
{
// see (e) above
// TODO: Really? What if something else was selected?
selectOverBox(computeColumnArea(column));
contextSelection.setSelectedDesign(design);
showContextMenu(contextSelection, View.CONTEXT);
}
} else // Detect a context invocation inside the table body
{
AUndertaking undertaking = (AUndertaking) item.getData();
// Check for context invocation under the "tasks" column
if (design == null) {
// Set up the contextual selection state as necessary
if (selection.isTaskSelected(undertaking)) {
// see (b) above
showContextMenu();
} else {
// see (c) above
selectOverBox(item.getBounds());
contextSelection.addSelectedTask(undertaking);
showContextMenu(contextSelection, View.CONTEXT);
}
} else // Otherwise at the intersection of a task and a design
{
// see (a) above
selection.setSelectedCell(item, column);
Rectangle bounds = item.getBounds(tree.indexOf(column));
if (OSUtils.MACOSX) {
// XXX: DIRTY HACK TO fix SWT bug.
bounds.y -= 1;
bounds.height += 1;
}
selectOverBox(bounds);
// TODO: instead of the following, pass undertaking and
// design in to showContextMenuForIntersection()
Menu contextMenu = view.getContextMenuForIntersection(project, undertaking, design);
// Set up the contextual selection state as necessary
contextSelection.setSelectedDesign(design);
contextSelection.addSelectedTask(undertaking);
setViewEnabledState(contextSelection, ListenerIdentifierMap.CONTEXT);
contextMenu.setVisible(true);
}
}
}
}
use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.
the class ProjectUI method findColumn.
protected TreeColumn findColumn(int x) {
int initialOffset = 0;
if (OSUtils.MACOSX) {
// XXX: dirty hacks around SWT bugs
initialOffset = (numExpandedLevels(tree.getItems()) - 1) * 24;
// on the mac, X is not offset by the "origin" either
x += tree.getHorizontalBar().getSelection();
}
TreeColumn[] allCols = tree.getColumns();
int[] columnOrdering = uiModel.getCurrentDesignOrdering();
int numCols = tree.getColumnCount();
for (int i = 0; i < numCols; i++) {
int w = allCols[columnOrdering[i]].getWidth();
// XXX: Hack for MacOSX where the initial column is "wider" as items are expanded
if (i == 0) {
x -= initialOffset;
}
if (x < w) {
return allCols[columnOrdering[i]];
}
x -= w;
}
return null;
}
use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.
the class ProjectMouseState method dealWithMouseDoubleClick.
@Override
protected void dealWithMouseDoubleClick(MouseEvent me) {
super.dealWithMouseDoubleClick(me);
TreeItem item = ui.tree.getItem(new Point(me.x, me.y));
TreeColumn column = ui.findColumn(me.x);
// check to see if the group visibility should toggle
if ((item != null) && (column == null)) {
// Toggle tree expand when a TaskGroup is double-clicked,
// but not if double-clicking on the first column to edit the name
AUndertaking u = (AUndertaking) item.getData();
if (u.isTaskGroup()) {
item.setExpanded(!item.getExpanded());
}
}
// If on a valid cell, either edit script or open the script viewer
if ((item != null) && (column != null) && (column.getData() != null)) {
AUndertaking u = (AUndertaking) item.getData();
// At the intersection of a task and design
ProjectContextSelectionState seln = new ProjectContextSelectionState(ui.getProject());
seln.setSelectedDesign((Design) column.getData());
seln.addSelectedTask(u);
if (u.isTaskGroup()) {
TaskGroup group = (TaskGroup) u;
if (GroupNature.SUM.equals(group.getNature())) {
item.setExpanded(true);
ui.cleanupTaskEditor();
//TODO: won't work since repaint won't occur until after we're all done.
ui.performAction(ProjectLID.ViewGroupScript, seln);
}
} else {
ui.cleanupTaskEditor();
//TODO: won't work since repaint won't occur until after we're all done.
ui.performAction(ProjectLID.EditScript, seln);
}
} else if ((item != null) && (column != null) && (column.getData() == null)) {
// In a valid row, first column
if (ui.treeOperationOccurred == 0) {
ui.initiateTaskRename(item, true);
}
}
}
use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.
the class ProjectUIModel method installDesigns.
protected void installDesigns() {
TreeColumn designColumn = new TreeColumn(tree, SWT.LEFT);
designColumn.setToolTipText(selectAllHelp);
// TODO: Bonnie wants some indicator for which columns are designs
// Such as changing "Tasks" here to "Tasks \\ Designs"
designColumn.setText(L10N.get("PM.Tasks", "Tasks"));
designColumn.setResizable(true);
designColumn.setWidth(400);
if (columnHook != null) {
columnHook.onColumnCreation(designColumn);
}
Iterator<Design> designs = project.getDesigns().iterator();
while (designs.hasNext()) {
Design nextDesign = designs.next();
addTreeColumn(nextDesign);
}
}
Aggregations