use of org.eclipse.swt.graphics.Point 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.graphics.Point 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.graphics.Point 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.graphics.Point in project cogtool by cogtool.
the class ManagedCombo method replaceSelection.
protected void replaceSelection(String withString) {
if (withString != null) {
Point selection = getSelection();
String allText = getText();
setText(allText.substring(0, selection.x) + withString + allText.substring(selection.y));
selection.y = selection.x + withString.length();
setSelection(selection);
}
}
use of org.eclipse.swt.graphics.Point in project cogtool by cogtool.
the class ActionPropertySet method layoutHelper.
@Override
public void layoutHelper() {
actionSettings = new Composite(parent, SWT.BORDER);
actionSettings.setLayout(actionSettingsLayout);
propLabel = new Label(parent, SWT.CENTER);
propLabel.setText(designPropertiesLabel);
Font labelFont = FontUtils.getAdjustedFont(propLabel.getFont(), SWT.BOLD);
propLabel.setFont(labelFont);
actionType = new DisplayLabel(parent, SWT.NONE);
actionType.setText(actionTypeLabel);
actionChoices = new ComboWithEnableFix(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
actionChoices.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
int currentSelection = actionChoices.getSelectionIndex();
if (currentSelection != chosenActionType) {
editTransitionParms.useWhichParts = choiceUseIndexes[currentSelection];
chosenActionType = currentSelection;
view.performAction(DesignEditorLID.EditTransition, editTransitionParms, true);
}
}
});
delayLabelLabel = new DisplayLabel(parent, SWT.NONE);
delayLabelLabel.setText(DELAY_LABEL_LABEL);
delayLabel = new View.PerformActionText(parent, SWT.SINGLE | SWT.BORDER) {
@Override
protected void onFocus() {
super.onFocus();
view.getTransmuter().setLIDEnabledState();
}
@Override
protected boolean doChangeAction() {
Point labelSelection = getSelection();
if ("".equals(getText())) {
setText(TransitionDelay.DEFAULT_DELAY_LABEL);
labelSelection = null;
}
if (view.performAction(DesignEditorLID.ChangeDelay)) {
if (labelSelection != null) {
setSelection(labelSelection);
}
return true;
}
return false;
}
};
delayInSecsLabel = new DisplayLabel(parent, SWT.NONE);
delayInSecsLabel.setText(DELAY_DURATION_LABEL + ":");
secondsUnit = new Label(parent, SWT.NONE);
secondsUnit.setText(SECONDS);
delayInSecs = new View.PerformActionDouble(parent, SWT.SINGLE | SWT.BORDER) {
@Override
protected void onFocus() {
super.onFocus();
view.getTransmuter().setLIDEnabledState();
}
@Override
protected void onModify() {
super.onModify();
delayLabel.setEnabled(getDoubleValue() > 0.0);
}
@Override
protected boolean doChangeAction() {
Point delaySelection = getSelection();
if (getDoubleValue() == 0.0) {
setText("");
delaySelection = null;
}
if (view.performAction(DesignEditorLID.ChangeDelay)) {
if (delaySelection != null) {
setSelection(delaySelection);
}
return true;
}
return false;
}
};
delayInSecs.setAllowNegative(false);
delayInSecs.setDecimalPlaces(3);
delayInSecs.moveAbove(delayLabel.getOuter());
FormData data = new FormData();
data.left = leftAttachment;
data.right = new FormAttachment(100, -5);
propLabel.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(actionChoices, 0, SWT.CENTER);
actionType.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(actionType, 5, SWT.RIGHT);
data.right = new FormAttachment(100, -5);
data.top = new FormAttachment(propLabel, 5, SWT.BOTTOM);
actionChoices.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(actionChoices, 5, SWT.BOTTOM);
data.right = new FormAttachment(100, -5);
actionSettings.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(actionSettings, 5, SWT.BOTTOM);
delayInSecsLabel.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(delayInSecsLabel, 5, SWT.BOTTOM);
data.width = 100;
delayInSecs.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(delayInSecs.getOuter(), 5, SWT.RIGHT);
data.top = new FormAttachment(delayInSecs.getOuter(), 0, SWT.CENTER);
secondsUnit.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(delayInSecs.getOuter(), 5, SWT.BOTTOM);
delayLabelLabel.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(delayLabelLabel, 5, SWT.BOTTOM);
data.right = new FormAttachment(100, -5);
delayLabel.setLayoutData(data);
emptyParms = createEmptyComposite();
layOutEmptyComposite();
multTransParms = new Composite(actionSettings, SWT.NONE);
multTransParms.setLayout(new FormLayout());
Label multTransLabel = new Label(multTransParms, SWT.WRAP);
multTransLabel.setText(noActionAvailableText);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(0, 5);
data.right = new FormAttachment(100, -5);
multTransLabel.setLayoutData(data);
frameParms = createFrameComposite();
}
Aggregations