Java 类com.google.gwt.event.dom.client.MouseDownEvent 实例源码

项目:drools-wb    文件:ListBoxSingletonDOMElementFactoryTest.java   
@Test
public void checkDOMElementCreationMouseDownHandler() {
    factory.createDomElement(gridLayer,
                             gridWidget,
                             cellRenderContext);

    final ArgumentCaptor<MouseDownHandler> mouseDownHandlerCaptor = ArgumentCaptor.forClass(MouseDownHandler.class);

    verify(listBox).addMouseDownHandler(mouseDownHandlerCaptor.capture());

    final MouseDownEvent e = mock(MouseDownEvent.class);
    final MouseDownHandler mouseDownHandler = mouseDownHandlerCaptor.getValue();
    mouseDownHandler.onMouseDown(e);

    verify(e).stopPropagation();
}
项目:vaadin-combobox-multiselect    文件:VComboBoxMultiselect.java   
@Override
public void onMouseDown(MouseDownEvent event) {
    debug("VComboBoxMultiselect.onMouseDown(): blocking mouseDown event to avoid blur");

    event.preventDefault();
    event.stopPropagation();

    /*
     * In IE the above wont work, the blur event will still trigger. So, we
     * set a flag here to prevent the next blur event from happening. This
     * is not needed if do not already have focus, in that case there will
     * not be any blur event and we should not cancel the next blur.
     */
    if (BrowserInfo.get()
        .isIE() && this.focused) {
        this.preventNextBlurEventInIE = true;
        debug("VComboBoxMultiselect: Going to prevent next blur event on IE");
    }
}
项目:vaadin-combobox-multiselect    文件:VComboBoxMultiselect.java   
@Override
public void onMouseDown(MouseDownEvent event) {
    debug("VComboBoxMultiselect.onMouseDown(): blocking mouseDown event to avoid blur");

    event.preventDefault();
    event.stopPropagation();

    /*
     * In IE the above wont work, the blur event will still trigger. So, we
     * set a flag here to prevent the next blur event from happening. This
     * is not needed if do not already have focus, in that case there will
     * not be any blur event and we should not cancel the next blur.
     */
    if (BrowserInfo.get()
        .isIE() && this.focused) {
        this.preventNextBlurEventInIE = true;
        debug("VComboBoxMultiselect: Going to prevent next blur event on IE");
    }
}
项目:hexa.tools    文件:ResizablePanelBad.java   
@Override
public void onMouseDown( MouseDownEvent event )
{
    direction = getDirection( event.getNativeEvent().getEventTarget() );
    if( direction == 0 )
        return;

    startX = event.getScreenX();
    startY = event.getScreenY();

    startLeft = ResizablePanelBad.this.getAbsoluteLeft();
    startTop = ResizablePanelBad.this.getAbsoluteTop();
    startWidth = ResizablePanelBad.this.getOffsetWidth();
    startHeight = ResizablePanelBad.this.getOffsetHeight();

    DOM.setCapture( getElement() );

    fResizing = true;

    event.stopPropagation();
    event.preventDefault();
}
项目:putnami-web-toolkit    文件:TableOrder.java   
@Override
public void onMouseDown(MouseDownEvent event) {
    this.onMouseUp(null);

    Icon dragIcon = (Icon) event.getSource();
    this.selectedRow = (TableRow<T>) dragIcon.getParent().getParent();
    this.body = (TableEditorBody<T>) this.selectedRow.getParent();

    this.overRegistration = new HandlerRegistrationCollection();
    this.upRegistration = RootPanel.get().addDomHandler(this, MouseUpEvent.getType());
    this.rows = Lists.newArrayList(this.body.getRows());
    for (TableRow<T> row : this.rows) {
        this.overRegistration.add(row.addDomHandler(this, MouseOverEvent.getType()));
    }
    TableOrder.this.disableTextSelection(true);
    RootPanel.get().getElement().getStyle().setCursor(Style.Cursor.MOVE);
    StyleUtils.addStyle(this.selectedRow, TableOrder.STYLE_ROW_DRAGING);
}
项目:gantt    文件:GanttWidget.java   
@Override
public void onMouseDown(MouseDownEvent event) {
    GWT.log("onMouseDown(MouseDownEvent)");
    if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) {
        GanttWidget.this.onTouchOrMouseDown(event.getNativeEvent());
    } else {
        secondaryClickOnNextMouseUp = true;
        new Timer() {

            @Override
            public void run() {
                secondaryClickOnNextMouseUp = false;
            }
        }.schedule(CLICK_INTERVAL);
        event.stopPropagation();
    }
}
项目:geomajas-project-client-gwt    文件:LineStringEditController.java   
public void onMouseDown(MouseDownEvent event) {
    FeatureTransaction featureTransaction = getFeatureTransaction();
    if (featureTransaction != null && parent.getEditMode() == EditMode.DRAG_MODE
            && event.getNativeButton() != Event.BUTTON_RIGHT) {
        String targetId = getTargetId(event);
        if (TransactionGeomIndexUtil.isVertex(targetId)) {
            dragTargetId = targetId;
            if (dragTransaction == null) {
                dragTransaction = (FeatureTransaction) featureTransaction.clone();
            }
            mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
            mapWidget.render(dragTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
            createTempLine(featureTransaction, event);
        }
    }
}
项目:geomajas-project-client-gwt    文件:PolygonEditController.java   
public void onMouseDown(MouseDownEvent event) {
    FeatureTransaction featureTransaction = getFeatureTransaction();
    if (featureTransaction != null && parent.getEditMode() == EditMode.DRAG_MODE
            && event.getNativeButton() != Event.BUTTON_RIGHT) {
        String targetId = getTargetId(event);
        if (TransactionGeomIndexUtil.isVertex(targetId)) {
            dragTargetId = targetId;
            if (dragTransaction == null) {
                dragTransaction = (FeatureTransaction) featureTransaction.clone();
            }
            mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
            mapWidget.render(dragTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
            createTempLines(featureTransaction, event);
        }
    }
}
项目:EasyML    文件:DiagramController.java   
/**
 * Trigger action when mouse down event fired
 * 
 * @param event
 */
public void onMouseDown(MouseDownEvent event) {
    logger.info("diagram left mouse down");
    this.getWidgetPanel().getElement().focus();
    if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
        NodeShape shape = (NodeShape) getShapeUnderMouse();
        if (shape instanceof OutNodeShape) {
            OutNodeShape outShape = (OutNodeShape)shape;
            int x = outShape.getOffsetLeft() + 2*outShape.getRadius();
            int y = outShape.getOffsetTop() + 2*outShape.getRadius();
            outShape.getContextMenu().setPopupPosition(x,y);
            outShape.getContextMenu().show();
        }
        if(isvacancy){
            event.stopPropagation();
            event.preventDefault();
            //Popup connection menu
            if( !this.inShapeArea ){
                final Connection c = getConnectionNearMouse();
                if (c != null) {
                    showMenu(c);
                }else{
                    showContextualMenu(event);
                }
            }

        }

        return;
    }

    if (!lockDrawConnection && inEditionToDrawConnection) {
        logger.info( "draw connection lock: " +  lockDrawConnection );
        inDragBuildConnection = true;
        inEditionToDrawConnection = false;
        ((NodeShape) startShape).onConnectionStart();
        drawBuildArrow(startShape, getMousePoint());
    }
    if(!isvacancy){
        event.stopPropagation();
        event.preventDefault();
        focusTimer.scheduleRepeating(50);
    }
    else {
        this.clearSelectedWidgets();
        selectedWidget = null;
        focusTimer.scheduleRepeating(50);
    }
    this.setIsVacancy(true);
}
项目:EasyML    文件:DiagramController.java   
/**
 * Show the context menu of the mouse position.(Position from mouse down event)
 * 
 * @param event  mouse down event.
 */
public void showContextualMenu(MouseDownEvent event){
    final int X = event.getRelativeX(widgetPanel.getElement());
    final int Y = event.getRelativeY(widgetPanel.getElement());
    getMousePoint().setLeft(X);
    getMousePoint().setTop(Y);

    final int offsetX = event.getClientX();
    final int offsetY = event.getClientY();
    mouseOffsetPoint.setLeft(offsetX);
    mouseOffsetPoint.setTop(offsetY);

    cmenu.hide();
    cmenu = new ContextMenu();
    Command command = new Command() {
        @Override
        public void execute() {
            cmenu.hide();
        }
    };
}
项目:EasyML    文件:Leaf.java   
/**
 * Create a leaf node for the Tree
 *
 * @param name   name of the TreeItem
 * @param module Attached moduleId for the TreeItem
 */
public Leaf(String name,
        T module,
        String style) {
    // add context menu
    this.menu = new ContextMenu();
    label = new Label(name);
    this.setWidget(label);

    label.addMouseDownHandler(new MouseDownHandler() {
        @Override
        public void onMouseDown(MouseDownEvent event) {
            // display the context menu when right click
            if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
                menu.setPopupPosition(event.getClientX(), event.getClientY());
                menu.show();
            }
        }
    });

    // set moduleId
    this.module = module;
    this.addStyleName("bda-treeleaf");
    if (!style.equals(""))
        this.addStyleName(style);
}
项目:unitimes    文件:RoomSharingWidget.java   
Cell(int day, int slot) {
    super("cell", "item", isEditable(day, slot) ? "clickable" : null);
    iDay = day; iSlot = slot;
    RoomSharingOption option = iModel.getOption(day, slot);
    if (option == null) {
        getElement().getStyle().clearBackgroundColor();
        setHTML("");
        setTitle("");
    } else {
        getElement().getStyle().setBackgroundColor(option.getColor());
        setHTML(option.getCode() == null ? "" : option.getCode());
        setTitle(CONSTANTS.longDays()[day] + " " + slot2short(slot) + " - " + slot2short(slot + iMode.getStep()) + ": " + option.getName());
    }
    if (isEditable(day, slot))
        addMouseDownHandler(new MouseDownHandler() {
            @Override
            public void onMouseDown(MouseDownEvent event) {
                setOption(iOption);
            }
        });
}
项目:unitimes    文件:PeriodPreferencesWidget.java   
Cell(int day, int slot, Date date, PeriodInterface period) {
    super("cell", "item", isEditable() && period != null ? "clickable" : null, period == null ? "disabled" : null, period != null && iModel.isAssigned(period) ? "highlight" : null);
    iDay = day;
    iSlot = slot;
    iDate = date;
    iPeriod = period;
    if (period != null) {
        PreferenceInterface preference = iModel.getPreference(day, slot);
        if (preference == null) {
            getElement().getStyle().clearBackgroundColor();
            setHTML("");
            setTitle("");
        } else {
            getElement().getStyle().setBackgroundColor(preference.getColor());
            setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
        }
        if (isEditable())
            addMouseDownHandler(new MouseDownHandler() {
                @Override
                public void onMouseDown(MouseDownEvent event) {
                    setOption(iPreference);
                }
            });             
    }
}
项目:unitimes    文件:PeriodPreferencesWidget.java   
private D(int day, int slot, Date date, PeriodInterface period) {
    super("cell", "day", isEditable() && period != null ? "clickable" : null, period == null ? "unavailable" : null);
    iDay = day;
    iSlot = slot;
    iDate = date;
    iPeriod = period;
    setText(DateTimeFormat.getFormat("d").format(date));
    if (period != null) {
        PreferenceInterface preference = iModel.getPreference(day, slot);
        if (preference == null) {
            getElement().getStyle().clearBackgroundColor();
            setTitle("");
        } else {
            getElement().getStyle().setBackgroundColor(preference.getColor());
            setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
        }
        if (isEditable())
            addMouseDownHandler(new MouseDownHandler() {
                @Override
                public void onMouseDown(MouseDownEvent event) {
                    setOption(iPreference);
                }
            });             
    }
}
项目:unitimes    文件:TimeGrid.java   
public SelectionPanel(boolean fixed) {
    setStyleName(fixed ? "selection" : "active-selection");
    if (fixed) {
        iRemove = new P("x"); iRemove.setHTML("&times;");
        iRemove.addMouseDownHandler(new MouseDownHandler() {
            @Override
            public void onMouseDown(MouseDownEvent event) {
                iSelections.remove(SelectionPanel.this);
                if (iSelection != null)
                    iAllSelections.remove(iSelection);
            }
        });
        iRemove.getElement().getStyle().setRight(2, Unit.PX);
        iRemove.getElement().getStyle().setTop(2, Unit.PX);
        iRemove.getElement().getStyle().setPosition(Position.ABSOLUTE);
        add(iRemove);
        iText = new P("text");
        add(iText, 0, 0);
    }

    sinkEvents(Event.ONMOUSEDOWN);
    sinkEvents(Event.ONMOUSEUP);
    sinkEvents(Event.ONMOUSEMOVE);
}
项目:appinventor-extensions    文件:SimplePaletteItem.java   
private void addHandlers() {
  addMouseDownHandler(new MouseDownHandler() {
    @Override
    public void onMouseDown(MouseDownEvent arg0) {
      select(getWidget());
    }
  });
}
项目:WebConsole    文件:ListPanelComponent.java   
private void registerHandlers() {
    if(BrowserUtils.isMobile) {
        registerHandler(this.addDomHandler(this, TouchStartEvent.getType()));
        registerHandler(this.addDomHandler(this, TouchEndEvent.getType()));
    } else {
        registerHandler(this.addDomHandler(this, MouseDownEvent.getType()));
        registerHandler(this.addDomHandler(this, MouseUpEvent.getType()));
        registerHandler(this.addDomHandler(this, MouseOutEvent.getType()));
    }
    registerHandler(this.addHandler(this, DragStartEvent.getType()));
    registerHandler(this.addHandler(this, DragMoveEvent.getType()));
    registerHandler(this.addHandler(this, DragEndEvent.getType()));
    registerHandler(this.addHandler(this, DragCancelEvent.getType()));
}
项目:WebConsole    文件:ListPanelComponent.java   
@Override
public void onMouseDown(MouseDownEvent event) {
    event.stopPropagation();
    startEvent = new PressStartEvent(event);
    eventBus.fireEvent(startEvent);
    this.fireEvent(startEvent);
}
项目:WebConsole    文件:InteractiveConsoleComponent.java   
@Override
public void onMouseDown(MouseDownEvent event) {
    event.stopPropagation();
    //event.preventDefault();
    startEvent = new PressStartEvent(event);
    eventBus.fireEvent(startEvent);
    this.fireEvent(startEvent);
}
项目:WebConsole    文件:TabBarComponent.java   
private TabBarItemComponent createSystemTabItem(EnumSystemTabItemType itemType) {
    TabBarItem tabBarItem = null;
    TabBarItemComponent component = null;
    AutoBean<TabBarItem> TabBarItemBean = AutoBeanService.getInstance().getFactory().tabBarItem();
    tabBarItem = TabBarItemBean.as();
    switch (itemType) {
        case PREVIOUS:
            tabBarItem.setName("<");
            break;
        case NEXT:
            tabBarItem.setName(">");
            break;
    }
    component = new TabBarItemComponent(tabBarItem, itemType);
    // Add handlers as not created by usual mechanism
    if(BrowserUtils.isMobile) {
        systemTabHandlers.add(component.addDomHandler(this, TouchStartEvent.getType()));
        systemTabHandlers.add(component.addDomHandler(this, TouchEndEvent.getType()));
    } else {
        systemTabHandlers.add(component.addDomHandler(this, MouseDownEvent.getType()));
        systemTabHandlers.add(component.addDomHandler(this, MouseUpEvent.getType()));
        systemTabHandlers.add(component.addDomHandler(this, MouseOutEvent.getType()));
    }
    systemTabHandlers.add(component.addHandler(component, TapEvent.getType()));
    return component;
}
项目:LAS    文件:WindowBox.java   
@Override
protected void beginDragging(MouseDownEvent event) {
    int dm = -1;

    if (this.resizable && !this.minimized)
        dm = this.calcDragMode(event.getClientX(),event.getClientY());

    if (this.resizable && dm >= 0) {
        this.dragMode = dm;

        DOM.setCapture(getElement());

        this.dragX = event.getClientX();
        this.dragY = event.getClientY();

        updateCursor(dm,RootPanel.get().getElement());

    } else {
        super.beginDragging(event);
    }
}
项目:Wiab.pro    文件:BlipIndicatorController.java   
@Override
public boolean onMouseDown(MouseDownEvent event, Element context) {
  Element metaElement = context.getParentElement();
  Element blipElement = metaElement.getParentElement();
  BlipView blipView = viewProvider.asBlip(blipElement);
  ConversationBlip blip = modelProvider.getBlip(blipView);
  reader.read(blip);

  event.stopPropagation();
  return true;
}
项目:Wiab.pro    文件:ReplyIndicatorController.java   
@Override
public boolean onMouseDown(MouseDownEvent event, Element context) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }

  ReplyBoxView indicatorView = panel.asReplyBox(context);
  ThreadView threadView = indicatorView.getParent();
  ConversationThread thread = modelAsViewProvider.getThread(threadView);
  actions.addBlipToThread(thread);
  event.preventDefault();
  return true;
}
项目:Wiab.pro    文件:FocusFrameController.java   
@Override
public boolean onMouseDown(MouseDownEvent event, Element source) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  BlipView blipView = panel.asBlip(source);
  ConversationBlip blip = modelAsViewProvider.getBlip(blipView);
  focus.focus(blip);    
  return true;
}
项目:Wiab.pro    文件:CollapseController.java   
@Override
public boolean onMouseDown(MouseDownEvent event, Element source) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  handleClick(panel.fromToggle(source));
  return false;
}
项目:ephesoft    文件:FolderTableView.java   
private void addHandlersToFileIconedName(final FileWrapper file, final String fileName, HTML fileIconedName) {
    fileIconedName.addMouseDownHandler(new MouseDownHandler() {

        @Override
        public void onMouseDown(MouseDownEvent mouseDown) {
            presenter.setSelectedFile(file);
            com.google.gwt.user.client.Timer timer = new com.google.gwt.user.client.Timer() {

                @Override
                public void run() {
                    presenter.setSelectedFile(null);
                }
            };
            timer.schedule(500);
            if (mouseDown.getNativeButton() == Event.BUTTON_RIGHT) {
                performOperationsOnRightClick(file, fileName, mouseDown);
            }
        }

    });
}
项目:che    文件:View.java   
private void beginDragging(MouseDownEvent event) {
  if (DOM.getCaptureElement() == null) {
    /*
     * Need to check to make sure that we aren't already capturing an element
     * otherwise events will not fire as expected. If this check isn't here,
     * any class which extends custom button will not fire its click event for
     * example.
     */
    dragging = true;
    DOM.setCapture(header.getElement());
    if ("".equals(contentContainer.getElement().getStyle().getPosition())) {
      contentContainer
          .getElement()
          .getStyle()
          .setTop(contentContainer.getAbsoluteTop() + 1, Style.Unit.PX);
      contentContainer
          .getElement()
          .getStyle()
          .setLeft(contentContainer.getAbsoluteLeft(), Style.Unit.PX);
    } else {
      contentContainer
          .getElement()
          .getStyle()
          .setTop(contentContainer.getAbsoluteTop(), Style.Unit.PX);
      contentContainer
          .getElement()
          .getStyle()
          .setLeft(contentContainer.getAbsoluteLeft(), Style.Unit.PX);
    }

    contentContainer.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    elemental.dom.Element element = (elemental.dom.Element) contentContainer.getElement();
    transition = element.getStyle().getPropertyValue("transition");
    element.getStyle().setProperty("transition", "all 0ms");

    dragStartX = event.getX();
    dragStartY = event.getY();
  }
}
项目:che    文件:SelectionModel.java   
public void bindTree(Tree tree) {
  if (this.tree != null) {
    handlerRegistration.removeHandler();
    keyNav.bind(null);
    bindStorage(null);
    nodeStorage = null;
  }

  this.tree = tree;

  if (tree != null) {
    if (handlerRegistration == null) {
      handlerRegistration = new GroupingHandlerRegistration();
    }
    handlerRegistration.add(tree.addDomHandler(treeMouseHandler, MouseDownEvent.getType()));
    handlerRegistration.add(tree.addDomHandler(treeMouseHandler, ClickEvent.getType()));
    keyNav.bind(tree);
    bindStorage(tree.getNodeStorage());
    nodeStorage = tree.getNodeStorage();
  }
}
项目:riscoss-corporate    文件:IndicatorWidget.java   
protected void mousePressed(MouseDownEvent event) {
    int bar = findBar( event.getX(), event.getY() );
    if( bar == -1 ) return;
    double val = findValue( bar, event.getY() );
    List<Double> v = distribution.getValues();
    v.set( bar, val );
    distribution.flatten( bar );
    distribution.setValues( v ); // not needed because distribution.getValues() returns a reference
    this.bars = mkBars( distribution, mleft, mtop, canvas.getCoordinateSpaceWidth() -(mleft + mright), canvas.getCoordinateSpaceHeight() -(mtop + mbottom) );
    Context2d g = canvas.getContext2d();
    g.clearRect( 0, 0, canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight() );
    paint( distribution, g, mleft, mtop, canvas.getCoordinateSpaceWidth() -(mleft + mright), canvas.getCoordinateSpaceHeight() -(mtop + mbottom) );
    for( Listener l : listeners ) {
        l.IndicatorValueChanged();
    }
}
项目:firefly    文件:WebPlotView.java   
/**
 * Create a new PlotView.  This constructor is typically used when the
 * PlotView <em>will</em> be placed insides a scrolled window.
 */
public WebPlotView() {
    initWidgets();
    _scrollingRootPanel.addDomHandler(new MouseDownHandler() {
        public void onMouseDown(MouseDownEvent ev) {
            if (_mpw != null) _mpw.selectSelf();
        }
    }, MouseDownEvent.getType());

    _scrollingRootPanel.addDomHandler(new TouchStartHandler() {
        public void onTouchStart(TouchStartEvent event) {
            if (_mpw != null) _mpw.selectSelf();
        }
    }, TouchStartEvent.getType());

}
项目:unitime    文件:RoomSharingWidget.java   
Cell(int day, int slot) {
    super("cell", "item", isEditable(day, slot) ? "clickable" : null);
    iDay = day; iSlot = slot;
    RoomSharingOption option = iModel.getOption(day, slot);
    if (option == null) {
        getElement().getStyle().clearBackgroundColor();
        setHTML("");
        setTitle("");
    } else {
        getElement().getStyle().setBackgroundColor(option.getColor());
        setHTML(option.getCode() == null ? "" : option.getCode());
        setTitle(CONSTANTS.longDays()[day] + " " + slot2short(slot) + " - " + slot2short(slot + iMode.getStep()) + ": " + option.getName());
    }
    if (isEditable(day, slot))
        addMouseDownHandler(new MouseDownHandler() {
            @Override
            public void onMouseDown(MouseDownEvent event) {
                setOption(iOption);
            }
        });
}
项目:unitime    文件:PeriodPreferencesWidget.java   
Cell(int day, int slot, Date date, PeriodInterface period) {
    super("cell", "item", isEditable() && period != null ? "clickable" : null, period == null ? "disabled" : null, period != null && iModel.isAssigned(period) ? "highlight" : null);
    iDay = day;
    iSlot = slot;
    iDate = date;
    iPeriod = period;
    if (period != null) {
        PreferenceInterface preference = iModel.getPreference(day, slot);
        if (preference == null) {
            getElement().getStyle().clearBackgroundColor();
            setHTML("");
            setTitle("");
        } else {
            getElement().getStyle().setBackgroundColor(preference.getColor());
            setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
        }
        if (isEditable())
            addMouseDownHandler(new MouseDownHandler() {
                @Override
                public void onMouseDown(MouseDownEvent event) {
                    setOption(iPreference);
                }
            });             
    }
}
项目:unitime    文件:PeriodPreferencesWidget.java   
private D(int day, int slot, Date date, PeriodInterface period) {
    super("cell", "day", isEditable() && period != null ? "clickable" : null, period == null ? "unavailable" : null);
    iDay = day;
    iSlot = slot;
    iDate = date;
    iPeriod = period;
    setText(DateTimeFormat.getFormat("d").format(date));
    if (period != null) {
        PreferenceInterface preference = iModel.getPreference(day, slot);
        if (preference == null) {
            getElement().getStyle().clearBackgroundColor();
            setTitle("");
        } else {
            getElement().getStyle().setBackgroundColor(preference.getColor());
            setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
        }
        if (isEditable())
            addMouseDownHandler(new MouseDownHandler() {
                @Override
                public void onMouseDown(MouseDownEvent event) {
                    setOption(iPreference);
                }
            });             
    }
}
项目:unitime    文件:TimeGrid.java   
public SelectionPanel(boolean fixed) {
    setStyleName(fixed ? "selection" : "active-selection");
    if (fixed) {
        iRemove = new P("x"); iRemove.setHTML("&times;");
        iRemove.addMouseDownHandler(new MouseDownHandler() {
            @Override
            public void onMouseDown(MouseDownEvent event) {
                iSelections.remove(SelectionPanel.this);
                if (iSelection != null)
                    iAllSelections.remove(iSelection);
            }
        });
        iRemove.getElement().getStyle().setRight(2, Unit.PX);
        iRemove.getElement().getStyle().setTop(2, Unit.PX);
        iRemove.getElement().getStyle().setPosition(Position.ABSOLUTE);
        add(iRemove);
        iText = new P("text");
        add(iText, 0, 0);
    }

    sinkEvents(Event.ONMOUSEDOWN);
    sinkEvents(Event.ONMOUSEUP);
    sinkEvents(Event.ONMOUSEMOVE);
}
项目:appformer    文件:BaseDOMElement.java   
protected void setupDelegatingMouseDownHandler() {
    widgetContainer.addDomHandler(new MouseDownHandler() {
                                      @Override
                                      public void onMouseDown(final MouseDownEvent event) {
                                          gridLayer.onNodeMouseDown(new NodeMouseDownEvent(event) {

                                              @Override
                                              public int getX() {
                                                  //Adjust the x-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                                                  return super.getX() + widgetContainer.getElement().getOffsetLeft();
                                              }

                                              @Override
                                              public int getY() {
                                                  //Adjust the y-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                                                  return super.getY() + widgetContainer.getElement().getOffsetTop();
                                              }
                                          });
                                      }
                                  },
                                  MouseDownEvent.getType());
}
项目:appformer    文件:BoundaryMousePanMediatorTest.java   
@Test
public void testMouseUpEvent() {
    final MouseDownEvent md0 = mock(MouseDownEvent.class);
    when(md0.getRelativeX(any(Element.class))).thenReturn(0);
    when(md0.getRelativeY(any(Element.class))).thenReturn(0);
    final NodeMouseDownEvent nmd0 = new NodeMouseDownEvent(md0);

    final MouseUpEvent mu0 = mock(MouseUpEvent.class);
    final NodeMouseUpEvent nmu0 = new NodeMouseUpEvent(mu0);

    mediator.handleEvent(nmd0);
    mediator.handleEvent(nmu0);

    verify(vpStyle,
           times(1)).setCursor(eq(Style.Cursor.MOVE));
    verify(vpStyle,
           times(1)).setCursor(eq(Style.Cursor.DEFAULT));
}
项目:appformer    文件:BoundaryMousePanMediatorTest.java   
@Test
public void testMouseMoveEvent_RightEdge() {
    final MouseDownEvent md0 = mock(MouseDownEvent.class);
    when(md0.getRelativeX(any(Element.class))).thenReturn(0);
    when(md0.getRelativeY(any(Element.class))).thenReturn(0);
    final NodeMouseDownEvent nmd0 = new NodeMouseDownEvent(md0);

    final MouseMoveEvent mm1 = mock(MouseMoveEvent.class);
    when(mm1.getRelativeX(any(Element.class))).thenReturn(-200);
    when(mm1.getRelativeY(any(Element.class))).thenReturn(0);
    final NodeMouseMoveEvent nmm1 = new NodeMouseMoveEvent(mm1);

    final ArgumentCaptor<Transform> transformArgumentCaptor = ArgumentCaptor.forClass(Transform.class);

    mediator.handleEvent(nmd0);
    mediator.handleEvent(nmm1);

    verify(viewport,
           times(1)).setTransform(transformArgumentCaptor.capture());
    final Transform result = transformArgumentCaptor.getValue();
    assertNotNull(result);
    assertEquals(0.0,
                 result.getTranslateX(),
                 0.0);
    assertEquals(0.0,
                 result.getTranslateY(),
                 0.0);
}
项目:platypus-js    文件:WindowPanel.java   
public WindowPanel() {
    super(true);
    addDomHandler(new MouseDownHandler() {

        @Override
        public void onMouseDown(MouseDownEvent event) {
            focus();
        }
    }, MouseDownEvent.getType());
    verticalPanel = new VerticalPanel();
    super.setWidget(verticalPanel);
    setCaptionWidget(new Caption(""));
    setUndecorated(false);
    getElement().addClassName("window-panel");
    getElement().<XElement> cast().addResizingTransitionEnd(this);
    getMovableTarget().getElement().<XElement> cast().addResizingTransitionEnd(this);
}
项目:platypus-js    文件:EventsExecutor.java   
public void setMousePressed(JavaScriptObject aValue) {
    if (mousePressed != aValue) {
        if (mouseDownReg != null) {
            mouseDownReg.removeHandler();
            mouseDownReg = null;
        }
        mousePressed = aValue;
        if (mousePressed != null) {
            MouseDownHandler handler = new MouseDownHandler() {
                @Override
                public void onMouseDown(MouseDownEvent event) {
                    if (mousePressed != null) {
                        event.stopPropagation();
                        // Event.setCapture(event.getRelativeElement());
                        mouseState = MOUSE.PRESSED;
                        executeEvent(mousePressed, EventsPublisher.publish(event));
                    }
                }
            };
            if (component instanceof Widget) {
                mouseDownReg = ((Widget) component).addDomHandler(handler, MouseDownEvent.getType());
            } else if (component instanceof HasMouseDownHandlers) {
                mouseDownReg = ((HasMouseDownHandlers) component).addMouseDownHandler(handler);
            }
        }
    }
}
项目:hexa.tools    文件:DialogBoxForNormalWidget.java   
@Override
public void onMouseDown( MouseDownEvent event )
{
    if( event.getNativeEvent().getEventTarget().<Element>cast() == title )
    {
        isMoving = true;
        movingMouseOffsetX = event.getClientX();
        movingMouseOffsetY = event.getClientY();

        DOM.setCapture( title );
        event.preventDefault();
        event.stopPropagation();
    }
}