Java Code Examples for org.eclipse.swt.events.MouseEvent

The following are top voted examples for showing how to use org.eclipse.swt.events.MouseEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Hydrograph   File: OutputRecordCountWidget.java   View source code 6 votes vote down vote up
private void addSelectionListenerToOperationRadioButton(Button operationRadioButton) 
{
	operationRadioButton.addMouseListener(new MouseAdapter() 
	{
		@Override
		public void mouseUp(MouseEvent e) {
			outputRecordCoundText.setEnabled(false);
			editButton.setEnabled(false);
			transformMapping.setExpression(false);
			propertyDialogButtonBar.enableApplyButton(true);
			expressionValidateDecorator.hide();
			OutputRecordCountUtility.INSTANCE.removeExpressionFieldFromOutputList(transformMapping);
			OutputRecordCountUtility.INSTANCE.addOperationOutputFieldToOuterListOfMappingWindow(transformMapping);
			setSchemaUpdated(false);
			outputList.clear();
			SchemaSyncUtility.INSTANCE.unionFilter(transformMapping.getOutputFieldList(), 
					outputList);
			OutputRecordCountUtility.INSTANCE.propagateOuputFieldsToSchemaTabFromTransformWidget(
					transformMapping,getSchemaForInternalPropagation(),getComponent(),outputList
					);
		}
       });
}
 
Example 2
Project: n4js   File: GraphCanvas.java   View source code 6 votes vote down vote up
protected void onClick(MouseEvent event) {
	// update selection
	final Node mNode = getNodeAt(event.x, event.y);
	final boolean shiftPressed = (event.stateMask & SWT.SHIFT) != 0;
	if (!shiftPressed) {
		if (mNode == null) {
			clearSelection();
		} else {
			setSelectedNodes(mNode);
		}
	} else {
		if (mNode == null) {
			// do nothing
		} else {
			toggleSelection(mNode);
		}
	}
}
 
Example 3
Project: neoscada   File: ChartAreaRenderer.java   View source code 6 votes vote down vote up
@Override
public void addMouseMoveListener ( final ChartMouseMoveListener listener )
{
    removeMouseMoveListener ( listener );
    final MouseMoveListener proxyListener = new MouseMoveListener () {

        @Override
        public void mouseMove ( final MouseEvent e )
        {
            listener.onMouseMove ( convertState ( e ) );
        }

    };
    final MouseMoveListener oldListener = this.mouseMoveListenerMap.put ( listener, proxyListener );
    if ( oldListener != null )
    {
        this.control.removeMouseMoveListener ( oldListener );
    }
    this.control.addMouseMoveListener ( proxyListener );
}
 
Example 4
Project: convertigo-eclipse   File: KTable.java   View source code 6 votes vote down vote up
protected void onMouseDoubleClick(MouseEvent e) {
  if (m_Model == null)
    return;
  if (e.button == 1) {

    if (e.y < m_Model.getFirstRowHeight()
        + ((m_Model.getFixedRowCount() - 1) * m_Model
            .getRowHeight())) {
      // double click in header area
      int columnIndex = getColumnForResize(e.x, e.y);
      resizeColumnOptimal(columnIndex);
      return;
    } else
      openEditorInFocus();
  }
}
 
Example 5
Project: convertigo-eclipse   File: TwsDomTree.java   View source code 6 votes vote down vote up
private void buildContextMenu(MouseEvent e) {
	Point point = new Point(e.x, e.y);
	TreeItem  treeItem = getTree().getItem(point);
	Menu menu = new Menu((Control)e.getSource());
	Iterator<MenuMaker> i = menuMakers.iterator();
	int cpt = 0;
	while(i.hasNext()) {
		i.next().makeMenu(this, treeItem, e, menu);
		if (i.hasNext() && menu.getItemCount() != cpt) {
			new MenuItem(menu, SWT.SEPARATOR);
			cpt = menu.getItemCount();
		}
	}
	if (menu.getItemCount() > 0) {
		menu.setVisible(true);
	} else {
		menu.dispose();
	}
}
 
Example 6
Project: avoCADo   File: ToolSketchLineCtrl.java   View source code 6 votes vote down vote up
public void glMouseDrag(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Feature2D feat2D = AvoGlobal.project.getActiveFeat2D();
	if(feat2D != null){
		//
		// get parameter set
		//
		//ParamSet paramSet = feat2D.paramSet;
	
		//
		// update param values
		//
		try{
			paramSet.changeParam("b", new Point2D(x,y));
			(new ToolSketchLineModel()).updateDerivedParams(paramSet);
			//navigationToolbar.showMessage("Release to finish line.");
		}catch(Exception ex){
			System.out.println(this.getClass().getCanonicalName() + " :: " + ex.getClass());
		}
	}
}
 
Example 7
Project: Open_Source_ECOA_Toolset_AS5   File: ServicesEditor.java   View source code 6 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	if (e.getSource() instanceof Button) {
		Button sel = (Button) e.getSource();
		if (sel.getText().equalsIgnoreCase("Save")) {
			try {
				String tempText = sUtil.processAdd(isEdit, editName, comp, type, editor.getDocumentProvider().getDocument(getEditorInput()).get());
				editor.getDocumentProvider().getDocument(getEditorInput()).set(tempText);
				createPage1();
				setActivePage(1);
			} catch (JAXBException ex) {
				ErrorDialog.openError(getSite().getShell(), "Error removing item", null, new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, "Error removing item", null));
			}
		}
	}
}
 
Example 8
Project: avoCADo   File: ToolSketchCircleCtrl.java   View source code 6 votes vote down vote up
public void glMouseDrag(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Feature2D feat2D = AvoGlobal.project.getActiveFeat2D();
	if(feat2D != null){
		//
		// get parameter set
		//
		//ParamSet paramSet = feat2D.paramSet;
	
		//
		// update param values
		//
		try{
			Point2D ptCenter = paramSet.getParam("c").getDataPoint2D();
			paramSet.changeParam("r", ptCenter.computeDist(new Point2D(x,y)));
		}catch(Exception ex){
			System.out.println("Tool2DCircle(mousedrag): " + ex.getClass());
		}
	}
}
 
Example 9
Project: Open_Source_ECOA_Toolset_AS5   File: EventServiceComposite.java   View source code 6 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	if (((Button) e.getSource()).getText().equalsIgnoreCase("Add")) {
		Parameter val = new Parameter();
		val.setName("");
		val.setType("");
		getParamArr().add(val);
		tabValues.refresh();
	} else if (((Button) e.getSource()).getText().equalsIgnoreCase("Remove")) {
		int[] items = tabValues.getTable().getSelectionIndices();
		ArrayList<Parameter> rem = new ArrayList<Parameter>();
		for (int item : items) {
			rem.add(getParamArr().get(item));
		}
		getParamArr().removeAll(rem);
		tabValues.refresh();
	} else if (((Button) e.getSource()).getText().equalsIgnoreCase("Clear")) {
		getParamArr().clear();
		tabValues.refresh();
	}
}
 
Example 10
Project: Open_Source_ECOA_Toolset_AS5   File: EnumTypesComposite.java   View source code 6 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	if (((Button) e.getSource()).getText().equalsIgnoreCase("Add")) {
		EnumValue val = new EnumValue();
		val.setName("");
		val.setComment("");
		val.setValnum("");
		getEnumArr().add(val);
		tabValues.refresh();
	} else if (((Button) e.getSource()).getText().equalsIgnoreCase("Remove")) {
		int[] items = tabValues.getTable().getSelectionIndices();
		ArrayList<EnumValue> rem = new ArrayList<EnumValue>();
		for (int item : items) {
			rem.add(getEnumArr().get(item));
		}
		getEnumArr().removeAll(rem);
		tabValues.refresh();
	} else if (((Button) e.getSource()).getText().equalsIgnoreCase("Clear")) {
		getEnumArr().clear();
		tabValues.refresh();
	}
}
 
Example 11
Project: Open_Source_ECOA_Toolset_AS5   File: EnumTypesPage.java   View source code 6 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	if (((Button) e.getSource()).getText().equalsIgnoreCase("Add")) {
		EnumValue val = new EnumValue();
		val.setName("");
		val.setComment("");
		val.setValnum("");
		getEnumArr().add(val);
		tabValues.refresh();
	} else if (((Button) e.getSource()).getText().equalsIgnoreCase("Remove")) {
		int[] items = tabValues.getTable().getSelectionIndices();
		ArrayList<EnumValue> rem = new ArrayList<EnumValue>();
		for (int item : items) {
			rem.add(getEnumArr().get(item));
		}
		getEnumArr().removeAll(rem);
		tabValues.refresh();
	} else if (((Button) e.getSource()).getText().equalsIgnoreCase("Clear")) {
		getEnumArr().clear();
		tabValues.refresh();
	}
}
 
Example 12
Project: Open_Source_ECOA_Toolset_AS5   File: TypesEditor.java   View source code 6 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	if (e.getSource() instanceof Button) {
		Button sel = (Button) e.getSource();
		if (sel.getText().equalsIgnoreCase("Save")) {
			try {
				String tempText = util.processAdd(isEdit, editName, comp, type, editor.getDocumentProvider().getDocument(getEditorInput()).get());
				editor.getDocumentProvider().getDocument(getEditorInput()).set(tempText);
				createPage1();
				setActivePage(1);
			} catch (JAXBException ex) {
				ErrorDialog.openError(getSite().getShell(), "Error removing item", null, new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, "Error removing item", null));
			}
		}
	}
}
 
Example 13
Project: Hydrograph   File: ELTSchemaGridWidget.java   View source code 6 votes vote down vote up
private void addExportSchemaButton(ELTSchemaSubgroupComposite buttonSubGroup) {

		exportSchemaButton = new ELTDefaultButton("");
		SchemaButtonsSyncUtility.INSTANCE.buttonSize(exportSchemaButton, macButtonWidth, macButtonHeight,
				windowButtonWidth, windowButtonHeight);
		buttonSubGroup.attachWidget(exportSchemaButton);
		exportSchemaButton.setImage(ImagePathConstant.EXPORT_SCHEMA_BUTTON);
		exportSchemaButton.setToolTipText(Messages.EXPORT_SCHEMA_KEY_SHORTCUT_TOOLTIP);
		Button exportButton = (Button) exportSchemaButton.getSWTWidgetControl();
		exportButton.addMouseListener(new MouseAdapter() {

			@Override
			public void mouseDown(MouseEvent e) {
				exportSchemaIntoFile(exportButton);
			}
		});
	}
 
Example 14
Project: Open_Source_ECOA_Toolset_AS5   File: EventServicePage.java   View source code 6 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	if (((Button) e.getSource()).getText().equalsIgnoreCase("Add")) {
		Parameter val = new Parameter();
		val.setName("");
		val.setType("");
		getParamArr().add(val);
		tabValues.refresh();
	} else if (((Button) e.getSource()).getText().equalsIgnoreCase("Remove")) {
		int[] items = tabValues.getTable().getSelectionIndices();
		ArrayList<Parameter> rem = new ArrayList<Parameter>();
		for (int item : items) {
			rem.add(getParamArr().get(item));
		}
		getParamArr().removeAll(rem);
		tabValues.refresh();
	} else if (((Button) e.getSource()).getText().equalsIgnoreCase("Clear")) {
		getParamArr().clear();
		tabValues.refresh();
	}
}
 
Example 15
Project: n4js   File: InterfacesComponentProvider.java   View source code 5 votes vote down vote up
@Override
public void mouseDown(MouseEvent e) {
	if (editor.getItem() != null) {
		if (editor.getItem() != interfacesTable.getItem(new Point(e.x, e.y))) {
			editor.getEditor().dispose();
			interfacesTable.setItemCount(model.getInterfaces().size());
		}
	}
}
 
Example 16
Project: Hydrograph   File: SingleClickEvent.java   View source code 5 votes vote down vote up
@Override
public void mouseUp(MouseEvent event) {
	if (armed && inRange(event)) {
		action.run();
	}
	armed = false;
}
 
Example 17
Project: n4js   File: VisualisationCanvas.java   View source code 5 votes vote down vote up
protected void onMouseDown(MouseEvent event) {
	mousePressed = true;
	mouseDragged = false;
	mouseDragStartX = event.x;
	mouseDragStartY = event.y;
	mouseDragBaseX = offsetX;
	mouseDragBaseY = offsetY;
}
 
Example 18
Project: n4js   File: VisualisationCanvas.java   View source code 5 votes vote down vote up
protected void onMouseUp(MouseEvent event) {
	if (!mouseDragged)
		onClick(event);
	mousePressed = false;
	mouseDragged = false;
	mouseDragStartX = 0;
	mouseDragStartY = 0;
}
 
Example 19
Project: Hydrograph   File: SecondaryColumnKeysDialog.java   View source code 5 votes vote down vote up
private void attachAddButtonListern(Button addButton) {
	addButton.addMouseListener(new MouseAdapter() {
		
		@Override
		public void mouseUp(MouseEvent e) {
			addNewRow();
		}

	});
}
 
Example 20
Project: n4js   File: GraphCanvas.java   View source code 5 votes vote down vote up
protected void onMouseDown(MouseEvent event) {
	mousePressed = true;
	mouseDragged = false;
	mouseDragStartX = event.x;
	mouseDragStartY = event.y;
	mouseDragBaseX = offsetX;
	mouseDragBaseY = offsetY;
}
 
Example 21
Project: eZooKeeper   File: JmxExplorerView.java   View source code 5 votes vote down vote up
public void createPartControl(Composite parent) {

        DataModelManager<JmxConnectionModel, JmxConnectionDescriptor, JmxConnection> jmxConnectionModelManager = JmxActivator
                .getDefault().getJmxConnectionModelManager();

        ElementTypes elementTypes = new ElementTypes();

        elementTypes.add(jmxConnectionModelManager.getClass(), new DataModelManagerElementType());
        elementTypes.add(JmxConnectionModel.class, new JmxConnectionModelElementType());
        elementTypes.add(DomainModel.class, new DomainModelElementType());
        elementTypes.add(ObjectNameKeyValueModel.class, new ObjectNameKeyValueModelElementType());
        elementTypes.add(MBeanModel.class, new MBeanModelElementType());
        elementTypes.add(MBeanAttributesModelCategory.class, new MBeanAttributesModelCategoryElementType());
        elementTypes.add(MBeanAttributeModel.class, new MBeanAttributeModelElementType());
        elementTypes.add(MBeanOperationsModelCategory.class, new MBeanOperationsModelCategoryElementType());
        elementTypes.add(MBeanOperationModel.class, new MBeanOperationModelElementType());

        _TreeViewer = ViewerFactory.createDataModelTreeViewer(parent, SWT.MULTI | SWT.VIRTUAL | SWT.H_SCROLL
                | SWT.V_SCROLL, elementTypes, jmxConnectionModelManager);

        _TreeViewer.getTree().addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                getSite().getWorkbenchWindow().getActivePage().activate(JmxExplorerView.this);
            }
        });

        getSite().setSelectionProvider(_TreeViewer);

        _DrillDownAdapter = new DrillDownAdapter(_TreeViewer);

        makeActions();
        hookContextMenu();
        contributeToActionBars();

    }
 
Example 22
Project: neoscada   File: ChartAreaRenderer.java   View source code 5 votes vote down vote up
protected MouseState convertState ( final MouseEvent e )
{
    final MouseState state = new MouseState ();
    state.button = e.button;
    state.x = e.x;
    state.y = e.y;
    state.state = e.stateMask;
    return state;
}
 
Example 23
Project: Hydrograph   File: SecondaryColumnKeysDialog.java   View source code 5 votes vote down vote up
private void attachDownButtonListerner(Button downButton) {
	downButton.addMouseListener(new MouseAdapter() {
      
		@Override
		public void mouseUp(MouseEvent e) {
			moveRowDown();
		}
	});

}
 
Example 24
Project: convertigo-eclipse   File: KTable.java   View source code 5 votes vote down vote up
protected void onMouseDown(MouseEvent e) {
  if (e.button == 1) {
    // deactivateEditor(true);
    setCapture(true);
    m_Capture = true;

    // Resize column?
    int columnIndex = getColumnForResize(e.x, e.y);
    if (columnIndex >= 0) {
      m_ResizeColumnIndex = columnIndex;
      m_ResizeColumnLeft = getColumnLeft(columnIndex);
      return;
    }

    // Resize row?
    int rowIndex = getRowForResize(e.x, e.y);
    if (rowIndex >= 0) {
      m_ResizeRowIndex = rowIndex;
      m_ResizeRowTop = m_Model.getFirstRowHeight() + (rowIndex - 1)
          * m_Model.getRowHeight();
      m_NewRowSize = m_Model.getRowHeight();
      return;
    }
  }

  // focus change
  int col = calcColumnNum(e.x);
  int row = calcRowNum(e.y);

  if (col == -1 || row == -1)
    return;

  m_ClickColumnIndex = col;
  m_ClickRowIndex = row;

  focusCell(col, row, e.stateMask);

}
 
Example 25
Project: convertigo-eclipse   File: KTable.java   View source code 5 votes vote down vote up
protected void onMouseUp(MouseEvent e) {
  // if (e.button == 1)
  {
    if (m_Model == null)
      return;

    setCapture(false);
    m_Capture = false;

    if (m_ResizeColumnIndex != -1) {
      fireColumnResize(m_ResizeColumnIndex, m_Model
          .getColumnWidth(m_ResizeColumnIndex));
      m_ResizeColumnIndex = -1;
      redraw();

    }
    if (m_ResizeRowIndex != -1) {
      m_ResizeRowIndex = -1;
      m_Model.setRowHeight(m_NewRowSize);
      m_LineRestore = null;
      fireRowResize(m_NewRowSize);
      redraw();
    }
    if (m_ClickColumnIndex != -1) {
      int col = m_ClickColumnIndex;
      int row = m_ClickRowIndex;
      m_ClickColumnIndex = -1;
      m_ClickRowIndex = -1;
      if (m_CellEditor == null) {
        drawCell(new GC(this), col, row);
      }
    }

  }
}
 
Example 26
Project: Hydrograph   File: TransformDialog.java   View source code 5 votes vote down vote up
private void createInputFieldTable(Composite container) {

		Composite inputFieldComposite = new Composite(container, SWT.NONE);
		
		inputFieldComposite.setLayout(new GridLayout(2, false));

		GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_composite.widthHint = 250;
		inputFieldComposite.setLayoutData(gd_composite);
		new Label(inputFieldComposite, SWT.NONE);
		inputFieldTableViewer = new TableViewer(inputFieldComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);

		setTableViewer(inputFieldTableViewer, inputFieldComposite, new String[] { Messages.OPERATIONAL_SYSTEM_FIELD },
				new TableContentProvider());
		inputFieldTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		DragDropUtility.INSTANCE.applyDragFromTableViewer(inputFieldTableViewer.getTable());
		inputFieldTableViewer.setLabelProvider(new InputFieldColumnLabelProvider());
		inputFieldTableViewer.setInput(transformMapping.getInputFields());
        addControlListener(inputFieldTableViewer.getTable());
        inputFieldTableViewer.getControl().addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) 
			{
				TransformMappingFeatureUtility.INSTANCE.highlightInputAndOutputFields(null,
						inputFieldTableViewer,outputFieldViewer,null,null);
  			}
		});
	}
 
Example 27
Project: Hydrograph   File: Utils.java   View source code 5 votes vote down vote up
private MouseMoveListener getMouseListner(final Text extSchemaPathText){
	final MouseMoveListener listner = new MouseMoveListener() {
		
		@Override
		public void mouseMove(MouseEvent e) {
			String paramValue = Utils.INSTANCE.getParamValue(extSchemaPathText.getText());
		    finalParamPath = Utils.INSTANCE.getParamFilePath(extSchemaPathText.getText(), paramValue, extSchemaPathText);
		    while(ParameterUtil.containsParameter(finalParamPath, '/')){
		    	paramValue = Utils.INSTANCE.getParamValue(extSchemaPathText.getToolTipText());
		    	finalParamPath = Utils.INSTANCE.getParamFilePath(extSchemaPathText.getToolTipText(), paramValue, extSchemaPathText);
	    		}
			}
		};
	return listner;
}
 
Example 28
Project: avoCADo   File: ToolSketchLineCtrl.java   View source code 5 votes vote down vote up
public void glMouseDown(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Sketch sketch = AvoGlobal.project.getActiveSketch();
	if(sketch != null && !sketch.isConsumed){
		//
		// starting to draw a new feature... deselect all other features.
		//
		sketch.deselectAllFeat2D();
		
		//
		// Build parameter set for this feature
		//
		ParamSet pSet = (new ToolSketchLineModel()).constructNewParamSet();
		try{
			pSet.changeParam("a", new Point2D(x,y));
			pSet.changeParam("b", new Point2D(x,y));
		}catch(Exception ex){
			System.out.println(this.getClass().getCanonicalName() + " :: " + ex.getClass());
		}			
		
		//
		// add the new feature to the end of the feature set
		// and set it as the active feature2D.		
		Feature2D f2D = new Feature2D(sketch, pSet,"Line" + sketch.getFeat2DListSize());
		f2D.setDescriptor("Line");
		int indx = sketch.add(f2D);
		sketch.setActiveFeat2D(indx);
		
		//
		// give paramDialog the paramSet so that it can
		// be displayed to the user for manual parameter
		// input.
		//
		AvoGlobal.paramDialog.setParamSet(pSet);
		
		
	}
}
 
Example 29
Project: avoCADo   File: ToolSketchLineCtrl.java   View source code 5 votes vote down vote up
public void glMouseUp(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Feature2D feat2D = AvoGlobal.project.getActiveFeat2D();
	if(feat2D != null){
		//
		// get parameter set
		//
		//ParamSet paramSet = feat2D.paramSet;
		
		//
		// finalize the feature's formation
		//
		try{
			paramSet.changeParam("b", new Point2D(x,y));
			(new ToolSketchLineModel()).updateDerivedParams(paramSet);
			
			Point2D ptA = paramSet.getParam("a").getDataPoint2D();
			Point2D ptB = paramSet.getParam("b").getDataPoint2D();
			// * discard if start point is the same as the end point
			if(ptA.equalsPt(ptB)){
				// end point are the same... discard
				System.out.println("end points of line are the same... discarding feature");
				// remove feature2D from the set
				AvoGlobal.project.getActiveSketch().removeActiveFeat2D();
				AvoGlobal.paramDialog.setParamSet(null);
				//navigationToolbar.showMessage("Left click on sketch (hold) to set first point. Drag to set direction and length.");
			}else{					
				//navigationToolbar.showMessage("Line done. Left click on sketch to deselect it.");
			}
			
		}catch(Exception ex){
			System.out.println(this.getClass().getCanonicalName() + " :: " + ex.getClass());
		}			
	}
}
 
Example 30
Project: RxSWT   File: MouseDoubleClickObservable.java   View source code 5 votes vote down vote up
@Override
protected AbstractMouseListener getMouseListener(Control control, Observer<? super MouseEvent> observer) {
	return new AbstractMouseListener(control) {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			if (!isDisposed()) {
				observer.onNext(e);
			}
		}
	};
}
 
Example 31
Project: avoCADo   File: ToolSketchExampleCtrl.java   View source code 5 votes vote down vote up
public void glMouseDown(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Sketch sketch = AvoGlobal.project.getActiveSketch();
	if(sketch != null && !sketch.isConsumed){
		//
		// starting to draw a new feature... deselect all other features.
		//
		sketch.deselectAllFeat2D();
		
		//
		// Build parameter set for this feature
		//
		ParamSet pSet = (new ToolSketchExampleModel()).constructNewParamSet();
		try{
			pSet.changeParam("c", new Point2D(x,y));
		}catch(Exception ex){
			System.out.println("Tool2DExample(mousedown): " + ex.getClass());
		}			
		//
		// add the new feature to the end of the feature set
		// and set it as the active feature2D.		
		int indx = sketch.add(new Feature2D(sketch, pSet,"Example" + sketch.getFeat2DListSize()));
		sketch.setActiveFeat2D(indx);
		
		//
		// give paramDialog the paramSet so that it can
		// be displayed to the user for manual parameter
		// input.
		//
		AvoGlobal.paramDialog.setParamSet(pSet);
	}
}
 
Example 32
Project: avoCADo   File: ToolSketchRectCtrl.java   View source code 5 votes vote down vote up
public void glMouseDown(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Sketch sketch = AvoGlobal.project.getActiveSketch();
	if(sketch != null && !sketch.isConsumed){
		//
		// starting to draw a new feature... deselect all other features.
		//
		sketch.deselectAllFeat2D();
		
		//
		// Build parameter set for this feature
		//
		ParamSet pSet = (new ToolSketchRectModel()).constructNewParamSet();
		try{
			pSet.changeParam("a", new Point2D(x,y));
			pSet.changeParam("b", new Point2D(x,y));
		}catch(Exception ex){
			System.out.println(this.getClass().getCanonicalName() + " :: " + ex.getClass());
		}	
		//
		// add the new feature to the end of the feature set
		// and set it as the active feature2D.
		Feature2D f2D = new Feature2D(sketch, pSet,"Rectangle" + sketch.getFeat2DListSize());
		f2D.setDescriptor("Rectangle");
		int indx = sketch.add(f2D);
		sketch.setActiveFeat2D(indx);
		
		//
		// give paramDialog the paramSet so that it can
		// be displayed to the user for manual parameter
		// input.
		//
		AvoGlobal.paramDialog.setParamSet(pSet);
		//navigationToolbar.showMessage("Drag to set size.");
	}
}
 
Example 33
Project: gemoc-studio   File: AbstractTimelineView.java   View source code 5 votes vote down vote up
@Override
public void mouseDown(MouseEvent e) {
	if (e.button == 1) {
		originMousePosition = new Point(e.x, e.y);
		final Canvas canevas = (Canvas)timelineViewer.getControl();
		doneShift = 0;
		if (canevas.getVerticalBar() != null) {
			offset.y = canevas.getVerticalBar().getSelection();
		} else {
			offset.y = 0;
		}
	}
}
 
Example 34
Project: avoCADo   File: ToolSketchRectCtrl.java   View source code 5 votes vote down vote up
public void glMouseUp(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Feature2D feat2D = AvoGlobal.project.getActiveFeat2D();
	if(feat2D != null){
		//
		// get parameter set
		//
		//ParamSet paramSet = feat2D.paramSet;
		
		//
		// finalize the feature's formation
		//
		try{
			paramSet.changeParam("b", new Point2D(x,y));
			(new ToolSketchRectModel()).updateDerivedParams(paramSet);
			
			Point2D ptA = paramSet.getParam("a").getDataPoint2D();
			Point2D ptB = paramSet.getParam("b").getDataPoint2D();
			// * discard if startX == endX or startY == endY  (rectangle has 0 Area)
			if(ptA.getX() == ptB.getX() || ptA.getY() == ptB.getY()){
				// end point are the same... discard
				System.out.println("Reactangle has zero area... discarding feature");
				// remove feature2D from the set
				AvoGlobal.project.getActiveSketch().removeActiveFeat2D();
				AvoGlobal.paramDialog.setParamSet(null);
				//navigationToolbar.showMessage("Left click on sketch (hold) to set first corner. Drag to set size.");
			}else{
				//navigationToolbar.showMessage("Rectangle done. Left click on sketch to deselect it.");
			}
			
		}catch(Exception ex){
			System.out.println(ex.getClass());
		}				
	}		
}
 
Example 35
Project: RxSWT   File: MouseEnterObservable.java   View source code 5 votes vote down vote up
@Override
protected AbstractMouseTrackListener getMouseListener(Control control, Observer<? super MouseEvent> observer) {
	return new AbstractMouseTrackListener(control) {
		@Override
		public void mouseEnter(MouseEvent e) {
			observer.onNext(e);
		}
	};
}
 
Example 36
Project: avoCADo   File: ToolSketchCircleCtrl.java   View source code 5 votes vote down vote up
public void glMouseDown(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Sketch sketch = AvoGlobal.project.getActiveSketch();
	if(sketch != null && !sketch.isConsumed){
		//
		// starting to draw a new feature... deselect all other features.
		//
		sketch.deselectAllFeat2D();
		
		//
		// Build parameter set for this feature
		//
		ParamSet pSet = (new ToolSketchCircleModel()).constructNewParamSet();
		try{
			pSet.changeParam("c", new Point2D(x,y));
		}catch(Exception ex){
			System.out.println("Tool2DCircle(mousedown): " + ex.getClass());
		}
		//
		// add the new feature to the end of the feature set
		// and set it as the active feature2D.		
		Feature2D f2D = new Feature2D(sketch, pSet, "Circle" + sketch.getFeat2DListSize());
		f2D.setDescriptor("Circle");
		int indx = sketch.add(f2D);
		sketch.setActiveFeat2D(indx);
		
		//
		// give paramDialog the paramSet so that it can
		// be displayed to the user for manual parameter
		// input.
		//
		AvoGlobal.paramDialog.setParamSet(pSet);
		
		//navigationToolbar.showMessage("Drag to set radius. Release to finish circle.");
	}
}
 
Example 37
Project: avoCADo   File: ToolSketchCircleCtrl.java   View source code 5 votes vote down vote up
public void glMouseUp(double x, double y, double z,  MouseEvent e, ParamSet paramSet) {
	Feature2D feat2D = AvoGlobal.project.getActiveFeat2D();
	if(feat2D != null){
		//
		// get parameter set
		//
		//ParamSet paramSet = feat2D.paramSet;
		
		//
		// finalize the feature's formation
		//
		try{
			Point2D ptCenter = paramSet.getParam("c").getDataPoint2D();
			paramSet.changeParam("r", ptCenter.computeDist(new Point2D(x,y)));
			
			// * discard if radius == 0.0
			Double radius = paramSet.getParam("r").getDataDouble();
			if(radius == 0.0){
				System.out.println("radius was zero... feature discarded");
				// remove feature2D from the set!
				AvoGlobal.project.getActiveSketch().removeActiveFeat2D();
				AvoGlobal.paramDialog.setParamSet(null);
				//navigationToolbar.showMessage("Left click (hold) to set center, then drag to set radius.");
			}else{
				//navigationToolbar.showMessage("Circle done. Left click on sketch to deselect it.");
			
			}
		}catch(Exception ex){
			System.out.println("Tool2DCircle(mouseup): " + ex.getClass());
		}						
	}
}
 
Example 38
Project: RxSWT   File: MouseDownObservable.java   View source code 5 votes vote down vote up
@Override
protected AbstractMouseListener getMouseListener(Control control, Observer<? super MouseEvent> observer) {
	return new AbstractMouseListener(control) {
		@Override
		public void mouseDown(MouseEvent e) {
			if (!isDisposed()) {
				observer.onNext(e);
			}
		}
	};
}
 
Example 39
Project: codelens-eclipse   File: ViewZoneChangeAccessor.java   View source code 5 votes vote down vote up
@Override
public void mouseMove(MouseEvent event) {
	int lineIndex = fTextWidget.getLineIndex(event.y);
	int lineNumber = lineIndex + 1;
	IViewZone zone = getViewZone(lineNumber);
	if (zone != null) {
		// The line which have a zone at end of this line is
		// hovered.
		// Check if it's the zone which is hovered or the view zone.
		int offset = fTextWidget.getOffsetAtLine(lineIndex + 1);
		Point p = fTextWidget.getLocationAtOffset(offset);
		if (p.y - zone.getHeightInPx() < event.y) {
			// Zone is hovered
			if (zone.equals(hoveredZone)) {
				hoveredZone.mouseHover(event);
				layoutZone(hoveredZone);
			} else {
				if (hoveredZone != null) {
					hoveredZone.mouseExit(event);
					layoutZone(hoveredZone);
				}
				hoveredZone = zone;
				hoveredZone.mouseEnter(event);
				layoutZone(hoveredZone);
			}
		} else {
			if (hoveredZone != null) {
				hoveredZone.mouseExit(event);
				layoutZone(hoveredZone);
				hoveredZone = null;
			}
		}
	} else if (hoveredZone != null) {
		if (!hoveredZone.isDisposed()) {
			hoveredZone.mouseExit(event);
			layoutZone(hoveredZone);
		}
		hoveredZone = null;
	}
}
 
Example 40
Project: Hydrograph   File: FunctionsComposite.java   View source code 5 votes vote down vote up
private void addDoubleClickListner(final List methodList) {
	methodList.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			if(methodList.getSelectionIndex()!=-1 && !StringUtils.startsWith(methodList.getItem(methodList.getSelectionIndex()),Messages.CANNOT_SEARCH_INPUT_STRING)){
			MethodDetails methodDetails = (MethodDetails) methodList.getData(String.valueOf(methodList
					.getSelectionIndex()));
				if(methodDetails !=null && StringUtils.isNotBlank(methodDetails.getPlaceHolder())){
					expressionEditorTextBox.insert(methodDetails.getPlaceHolder());
				}
	}
		}
	});
}