Java Code Examples for org.eclipse.swt.SWT#MouseDoubleClick

The following examples show how to use org.eclipse.swt.SWT#MouseDoubleClick . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CTree.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void handleEvent(Event event) {
	switch (event.type) {
	case SWT.FocusIn:
	case SWT.FocusOut:
		handleFocus(event.type);
		break;
	case SWT.MouseDoubleClick:
	case SWT.MouseDown:
	case SWT.MouseMove:
	case SWT.MouseUp:
		handleMouseEvents(event);
		break;
	case SWT.Traverse:
		handleTraverse(event);
		break;
	}
}
 
Example 2
Source File: DocumentManager.java    From ContentAssist with MIT License 6 votes vote down vote up
/**
 * Receives an event when the registered event occurs.
 * @param event the event which occurred
 */
@Override
public void handleEvent(Event event) {
    boolean cursorMoved = false;
    if (event.type == SWT.KeyDown) {
        cursorMoved = cursorMoved(event);
        
    } else if (event.type == SWT.MouseDown || event.type == SWT.MouseDoubleClick) {
        cursorMoved = true;
    }
    
    if (cursorMoved) {
        long time = Time.getCurrentTime();
        String path = recorder.getPath();
        
        String commandId = "Cursor.position.change";
        TriggerMacro trigger = new TriggerMacro(time, commandId, path, TriggerMacro.Kind.CURSOR_CHANGE);
        recorder.recordTriggerMacro(trigger);
        
        recorder.setParentMacro(null);
    }
}
 
Example 3
Source File: JavaSelectMarkerRulerAction2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void triggerAction(String actionID, Event event) {
	IAction action= getTextEditor().getAction(actionID);
	if (action != null) {
		if (action instanceof IUpdate)
			((IUpdate) action).update();
		// hack to propagate line change
		if (action instanceof ISelectionListener) {
			((ISelectionListener)action).selectionChanged(null, null);
		}
		if (action.isEnabled()) {
			if (event == null) {
				action.run();
			} else {
				event.type= SWT.MouseDoubleClick;
				event.count= 2;
				action.runWithEvent(event);
			}
		}
	}
}
 
Example 4
Source File: ResourceDependencySection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEvent(Event event) {
  if (event.widget == addButton) {
    handleAdd();
  } else if (event.widget == removeButton
          || (event.type == SWT.KeyUp && event.character == SWT.DEL)) {
    handleRemove();
  } else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) {
    handleEdit();
  }
  // else if (event.type == SWT.MouseDown && event.button == 3) {
  // handleTableContextMenuRequest(event);
  // }
  else if (event.type == SWT.MouseHover) {
    handleTableHoverHelp(event);
  } else if (event.type == SWT.Selection) {
    editor.getResourcesPage().getResourceBindingsSection().enable();
  }
  enable();
}
 
Example 5
Source File: ExtnlResBindSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEvent(Event event) {
  if (event.widget == addButton)
    handleAdd();
  else if (event.widget == editButton || event.type == SWT.MouseDoubleClick)
    handleEdit();
  else if (event.widget == removeButton
          || (event.widget == tree && event.type == SWT.KeyUp && event.character == SWT.DEL))
    handleRemove();
  else if (event.widget == bindButton)
    handleBind();
  else if (event.widget == exportButton) {
    try {
      resBindImportSection.exportImportablePart("<resourceManagerConfiguration>",
              ResourceManagerConfigurationNewWizard.RESOURCEMANGERCONFIGURATION_TEMPLATE);
    } finally {
      refresh(); // update in case of throw, even
    }
  }

  enable();
}
 
Example 6
Source File: DateChooser.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Manages events on the footer label.
 *
 * @param event event
 */
protected void footerEvent(Event event) {
	switch (event.type) {
		case SWT.MouseDoubleClick:
			setFocusOnToday(autoSelectOnFooter);
			break;
	}
}
 
Example 7
Source File: XViewerEditAdapter.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseDoubleClick(MouseEvent e) {
   // not supported yet!
   if (swtStyle == SWT.MouseDoubleClick) {
      klickedColumn = xv.getColumnUnderMouseClick(new Point(e.x, e.y));
      klickedCell = xv.getCell(new Point(e.x, e.y));
   }
}
 
Example 8
Source File: ParameterDelegatesSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void handleEvent(Event event) {
  if (event.type == SWT.MouseHover) {
    showDescriptionAsToolTip(event);
  } else if (event.type == SWT.MouseDoubleClick) {
    addOverrides(0 != (event.stateMask & SWT.SHIFT));
  } else if (event.widget == createOverrideButton) {
    addOverrides(false);
  } else if (event.widget == createNonSharedOverrideButton) {
    addOverrides(true);
  }
}
 
Example 9
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void handleEvent(Event event) {
  if (event.type == SWT.Expand || event.type == SWT.Collapse) {
    pack04();
    return;
  }
  if (event.widget == addCapabilityButton) {
    handleAddCapability();
    enable();
    return;
  }

  TreeItem selItem = tt.getSelection()[0];
  int itemKind = getItemKind(selItem);

  if (event.widget == addLangButton) {
    handleAddLang(selItem, itemKind);
  } else if (event.widget == addTypeButton) {
    handleAddType(selItem, itemKind);
  } else if (event.widget == addSofaButton) {
    handleAddSofa(selItem, itemKind);
  } else if (event.widget == addEditFeatureButton) {
    handleAddEditFeature(selItem, itemKind);
  } else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) {
    handleEdit(selItem, itemKind);
  } else if (event.widget == removeButton
          || (event.widget == tt && event.type == SWT.KeyUp && event.character == SWT.DEL)) {
    handleRemove(selItem, itemKind);
  }

  enable();
}
 
Example 10
Source File: TypeSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void handleEvent(Event event) {
  if (event.widget == addTypeButton) {
    handleAddType();
  } else if (event.widget == addButton) {
    TreeItem parent = tt.getSelection()[0];
    if (null != parent.getParentItem())
      parent = parent.getParentItem();

    if (isSubtypeOfString(parent))
      handleAddAllowedValue(parent);
    else
      handleAddFeature(parent);

  } else if (event.widget == editButton) {
    handleEdit();
  } else if (event.type == SWT.MouseDoubleClick && (!isAggregate()) && // can't edit aggregates
          isLocalItem(tt.getSelection()[0])) {
    handleEdit();
  } else if (event.widget == removeButton) {
    handleRemove();
  } else if (event.widget == exportButton) {
    editor.getTypePage().getTypeImportSection().exportImportablePart("<typeSystemDescription>",
            TypeSystemNewWizard.TYPESYSTEM_TEMPLATE);
    refresh();
  } else if (event.widget == jcasGenButton) {
    editor.doJCasGenChkSrc(null);
  } else if (event.widget == limitJCasGenToProjectScope) {
    editor.setLimitJCasGenToProjectScope(limitJCasGenToProjectScope.getSelection());
  } else if (event.type == SWT.MouseHover) {
    handleHover(event);
  }
  enable();
}
 
Example 11
Source File: SWTBotCanvas.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
protected void mouseDown(final int x, final int y, final int buttons, final int count) {
	int type = count == 2 ? SWT.MouseDoubleClick : SWT.MouseDown;
	postMouseEvent(type, x, y, buttons, count);
}
 
Example 12
Source File: CTree.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
protected void handleMouseEvents(Event event) {
		CTreeItem item = null;
		if (event.widget == body) {
			item = getItem(event.x, event.y);
		} else if (event.item instanceof CTreeItem) {
			item = (CTreeItem) event.item;
		}
		
		switch (event.type) {
		case SWT.MouseDoubleClick:
			if(item != null && (selectOnToggle || !item.isToggle(event.x, event.y))) {
				fireSelectionEvent(true);
			}
			break;
		case SWT.MouseDown:
			if(!hasFocus) setFocus();
			if(item == null) {
				if(event.widget == body) {
					item = getItem(event.x, event.y);
				} else if(event.item instanceof CTreeItem) {
					item = (CTreeItem) event.item;
				}
			}
			switch(event.button) {
			// TODO - popup menu: not just for mouse down events!
			case 3:
				Menu menu = getMenu();
				if ((menu != null) && ((menu.getStyle() & SWT.POP_UP) != 0)) {
					menu.setVisible(true);
				}
			case 1:
				if(selectOnToggle || !item.isToggle(event.x, event.y)) {
					if(selectOnTreeToggle || !item.isTreeToggle(event.x,event.y)) {
						if((event.stateMask & SWT.SHIFT) != 0) {
							if(shiftSel == null) {
								if(selection.isEmpty()) selection.add(item);
								shiftSel = (CTreeItem) selection.get(selection.size() - 1);
							}
							setSelection(shiftSel, item);
						} else if((event.stateMask & SWT.CONTROL) != 0) {
							toggleSelection(item);
							shiftSel = null;
						} else {
							setSelection(item);
							shiftSel = null;
						}
					}
				}
				break;
			}
			break;
		case SWT.MouseMove:
			// TODO: make toggles more dynamic
			break;
		case SWT.MouseUp:
			if(item.isToggle(event.x,event.y)) {
				boolean open = item.isOpen(event.x,event.y);
				if(item.isTreeToggle(event.x,event.y)) {
//					visibleItems = null;
					item.setExpanded(!open);
					fireTreeEvent(item, !open);
				} else {
					item.getCell(event.x, event.y).setOpen(!open);
				}
			}
			break;
		}

	}
 
Example 13
Source File: CTreeCombo.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The CTreeCombo class represents a selectable user interface object
 * that combines a text field and a tree and issues notification
 * when an item is selected from the tree.
 * <p>
 * Note that although this class is a subclass of <code>Composite</code>,
 * it does not make sense to add children to it, or set a layout on it.
 * </p>
 * <dl>
 * <dt><b>Styles:</b>
 * <dd>BORDER, READ_ONLY, FLAT</dd>
 * <dt><b>Events:</b>
 * <dd>DefaultSelection, Modify, Selection, Verify</dd>
 * </dl>
 */
public CTreeCombo(Composite parent, int style) {
	super(parent, style = checkStyle(style));

	int textStyle = SWT.SINGLE;
	if ((style & SWT.READ_ONLY) != 0) {
		textStyle |= SWT.READ_ONLY;
	}
	if ((style & SWT.FLAT) != 0) {
		textStyle |= SWT.FLAT;
	}
	text = new Text(this, textStyle);
	int arrowStyle = SWT.ARROW | SWT.DOWN;
	if ((style & SWT.FLAT) != 0) {
		arrowStyle |= SWT.FLAT;
	}
	arrow = new Button(this, arrowStyle);

	listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			if (popup == event.widget) {
				popupEvent(event);
				return;
			}
			if (text == event.widget) {
				textEvent(event);
				return;
			}
			if (tree == event.widget) {
				treeEvent(event);
				return;
			}
			if (arrow == event.widget) {
				arrowEvent(event);
				return;
			}
			if (CTreeCombo.this == event.widget) {
				comboEvent(event);
				return;
			}
			if (getShell() == event.widget) {
				getDisplay().asyncExec(new Runnable() {
					@Override
					public void run() {
						if (isDisposed()) {
							return;
						}
						handleFocus(SWT.FocusOut);
					}
				});
			}
		}
	};
	filter = (event) -> {
		final Shell shell = ((Control) event.widget).getShell();
		if (shell == CTreeCombo.this.getShell()) {
			handleFocus(SWT.FocusOut);
		}
	};

	final int[] comboEvents = { SWT.Dispose, SWT.FocusIn, SWT.Move, SWT.Resize };
	for (int i = 0; i < comboEvents.length; i++) {
		addListener(comboEvents[i], listener);
	}

	final int[] textEvents = { SWT.DefaultSelection, SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.MouseDoubleClick, SWT.MouseWheel, SWT.Traverse, SWT.FocusIn, SWT.Verify };
	for (int i = 0; i < textEvents.length; i++) {
		text.addListener(textEvents[i], listener);
	}

	final int[] arrowEvents = { SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.FocusIn };
	for (int i = 0; i < arrowEvents.length; i++) {
		arrow.addListener(arrowEvents[i], listener);
	}

	createPopup(null, null);
	initAccessible();
}
 
Example 14
Source File: XBookmarksDialog.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
@Override
 protected Control createDialogArea(Composite parent) {
     Composite composite = (Composite) super.createDialogArea(parent);
     GridLayoutFactory.fillDefaults().extendedMargins(Util.isWindows() ? 0 : 3, 3, 2, 2).applyTo(composite);

     Composite tableComposite = new Composite(composite, SWT.NONE);
     tableComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
     tableComposite.setLayout(new GridLayout(1, false));
     
     tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
             | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
     
     table = tableViewer.getTable();
     table.setLayoutData(new GridData(GridData.FILL_BOTH));
     tableViewer.setContentProvider(new MenuTableContentProvider());
     tableViewer.setLabelProvider(new MenuTableLabelProvider());

     { // Columns:
         GC gc= new GC(table);
         try {
         	int maxW = gc.stringExtent("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW").x; //$NON-NLS-1$
         	int gap  = gc.stringExtent("WW").x; //$NON-NLS-1$
         	int widths[] = new int[model.columns];
         	for (int i=0; i<model.columns; ++i) {
         		widths[i] = 0;
         	}
         	for (Model.Row r : model.getRows()) {
         		for (int i=0; i<model.columns; ++i) {
         			if (!r.getField(i).isEmpty()) {
         				int w     = Math.min(gc.stringExtent(r.getField(i)).x + gap, maxW);
         				widths[i] = Math.max(widths[i], w);
         			}
         		}
         	}
         	
         	for (int i=0; i<model.columns; ++i) {
         		TableColumn tc = new TableColumn(table, SWT.LEFT);
         		tc.setWidth(widths[i]);
         	}
         	table.setHeaderVisible(false);
         	table.setLinesVisible(false);
} finally {
	gc.dispose();
}
     }
     
     Listener eventListener = new Listener() {
         @Override
         public void handleEvent(Event event) {
             if (event.type == SWT.MouseDoubleClick || 
                (event.type == SWT.KeyDown && event.character == SWT.CR)) 
             {
                 doSelect();
             }
         }
         
     };
     
     addListener (SWT.KeyDown, eventListener);
     addListener (SWT.MouseDoubleClick, eventListener);
         
     tableViewer.setInput(model);
     table.select(0);

     return composite;
 }