List of usage examples for com.google.gwt.user.client.ui MouseListener MouseListener
MouseListener
From source file:ca.upei.ic.timetable.client.CourseModelView.java
License:Apache License
public void addCourse(final int id, final JSONObject value, boolean selected) { final CheckBox box = new CheckBox(); String name = ((JSONString) value.get("name")).stringValue(); String title = ((JSONString) value.get("title")).stringValue(); String time = ((JSONString) value.get("time")).stringValue(); box.setText(name + " " + title); box.setName(Integer.toString(id)); box.setChecked(selected);// w ww .ja v a 2 s .com box.setEnabled(time.matches(".*\\d{1,2}:\\d{2,2}\\s*-\\s*\\d{1,2}:\\d{2,2}.*")); // add click listener box.addClickListener(new ClickListener() { public void onClick(Widget sender) { final CheckBox box = (CheckBox) sender; if (box.isChecked()) { controller_.select(id, value); } else { controller_.unselect(id); } } }); FocusPanel focus = PanelUtils.focusPanel(box, null, null, null, new MouseListener() { public void onMouseDown(Widget sender, int x, int y) { } public void onMouseEnter(Widget sender) { controller_.showCourseDetail(id); } public void onMouseLeave(Widget sender) { controller_.hideCourseDetail(); } public void onMouseMove(Widget sender, int x, int y) { } public void onMouseUp(Widget sender, int x, int y) { // box.setChecked( !box.isChecked() ); } }); panel_.add(focus); }
From source file:com.objetdirect.gwt.umlapi.client.gfx.IncubatorGfxPlatform.java
License:Open Source License
public void addObjectListenerToCanvas(final Widget canvas, final GfxObjectListener gfxObjectListener) { Log.trace("adding " + gfxObjectListener + " on " + canvas); final CanvasBridge canvasBridge = canvasBridges.get(canvas); final MouseListener mouseListener = new MouseListener() { /*/*from ww w .jav a 2 s .c om*/ * (non-Javadoc) * * @see com.google.gwt.user.client.ui.MouseListener#onMouseDown(com.google.gwt.user.client.ui.Widget, int, * int) */ public void onMouseDown(final Widget sender, final int x, final int y) { if (x < 0) { gfxObjectListener.mousePressed(IncubatorGfxObjectContainer.getPointedObject(-x, -y), null); } else { gfxObjectListener.mousePressed(IncubatorGfxObjectContainer.getPointedObject(x, y), null); } } /* * (non-Javadoc) * * @see com.google.gwt.user.client.ui.MouseListener#onMouseEnter(com.google.gwt.user.client.ui.Widget) */ public void onMouseEnter(final Widget sender) { // Unused } /* * (non-Javadoc) * * @see com.google.gwt.user.client.ui.MouseListener#onMouseLeave(com.google.gwt.user.client.ui.Widget) */ public void onMouseLeave(final Widget sender) { // Unused } /* * (non-Javadoc) * * @see com.google.gwt.user.client.ui.MouseListener#onMouseMove(com.google.gwt.user.client.ui.Widget, int, * int) */ public void onMouseMove(final Widget sender, final int x, final int y) { gfxObjectListener.mouseMoved(null); } /* * (non-Javadoc) * * @see com.google.gwt.user.client.ui.MouseListener#onMouseUp(com.google.gwt.user.client.ui.Widget, int, * int) */ public void onMouseUp(final Widget sender, final int x, final int y) { // TODO fix this hack : if (x < 0) { gfxObjectListener.mouseDoubleClicked(IncubatorGfxObjectContainer.getPointedObject(-x, -y), null); } else { gfxObjectListener.mouseReleased(IncubatorGfxObjectContainer.getPointedObject(x, y), null); } } }; final ClickListener clickListener = new ClickListener() { /* * (non-Javadoc) * * @see com.google.gwt.user.client.ui.ClickListener#onClick(com.google.gwt.user.client.ui.Widget) */ public void onClick(final Widget sender) { // Unused } }; Log.trace("adding mouseListener" + mouseListener); canvasBridge.addMouseListener(mouseListener); Log.trace("adding clickListener" + clickListener); canvasBridge.addClickListener(clickListener); }
From source file:com.sun.labs.aura.music.wsitm.client.ui.widget.RightMenuWidget.java
License:Open Source License
private void init(T w, Panel mainPanel) { this.w = w;//from ww w. j a v a2s. co m this.mainPanel = mainPanel; this.rightMenu = new SpannedFlowPanel(); //this.rightMenu = new SpannedVerticalPanel(); mainPanel.add(w); mainPanel.add(rightMenu); initWidget(mainPanel); rightMenuWidgets = new HashSet<Widget>(); hoverListenerManager = new HoverListenerManager(); addMouseListener(new MouseListener() { public void onMouseEnter(Widget arg0) { isHovering = true; hoverListenerManager.triggerOnMouseHover(); } public void onMouseLeave(Widget arg0) { isHovering = false; hoverListenerManager.triggerOnMouseOut(); Timer t = new Timer() { public void run() { if (!isHovering) { hoverListenerManager.triggerOnOutTimer(); } } }; t.schedule(250); } public void onMouseDown(Widget arg0, int arg1, int arg2) { } public void onMouseMove(Widget arg0, int arg1, int arg2) { } public void onMouseUp(Widget arg0, int arg1, int arg2) { } }); }
From source file:com.sun.labs.aura.music.wsitm.client.ui.widget.steerable.ResizableTagWidget.java
License:Open Source License
public ResizableTagWidget(MainPanel mainPanel, ClientDataManager cdm, SharedSteeringCIMenu sharedArtistMenu, SharedSteeringCIMenu sharedTagMenu) { super(mainPanel); this.cdm = cdm; this.sharedArtistMenu = sharedArtistMenu; this.sharedTagMenu = sharedTagMenu; int panelWidth = 480; if (Window.getClientWidth() > 1024) { panelWidth = (int) (Window.getClientWidth() * 480.0 / 1024.0); }//from ww w . j a v a2 s.c om fP = new FocusPanel(); fP.setWidth(panelWidth + "px"); fP.setHeight("450px"); flowP = new FlowPanel(); flowP.setWidth("500px"); flowP.getElement().setAttribute("style", "margin-top: 15px"); fP.add(flowP); initWidget(fP); tagCloud = new HashMap<String, SpannedNEffectPanel>(); fP.addMouseListener(new MouseListener() { @Override public void onMouseDown(Widget arg0, int newX, int newY) { lastY = newY; lastX = newX; ((FocusPanel) arg0).setFocus(false); } @Override public void onMouseEnter(Widget arg0) { } @Override public void onMouseLeave(Widget arg0) { boolean wasTrue = false; for (SpannedNEffectPanel sep : tagCloud.values()) { ResizableTag dW = sep.getTag(); if (dW.hasClicked()) { wasTrue = true; } dW.setClickFalse(); } if (wasTrue) { updateRecommendations(); } ((FocusPanel) arg0).setFocus(false); } @Override public void onMouseMove(Widget arg0, int newX, int newY) { // Take either increment from Y or X movement. Taking both // modifies the size too quickly. // -- Going up or right grows the tags. int diffY = lastY - newY; int diffX = newX - lastX; int increment = 0; if (Math.abs(diffY) > Math.abs(diffX)) { increment = diffY; } else { increment = diffX; } // Don't refresh everytime to let the browser take its breath if (Math.abs(increment) > 3) { double diff = 0; maxSize = 0; // reset maxsize to deal with when the top tag is scaled down for (SpannedNEffectPanel sep : tagCloud.values()) { ResizableTag dW = sep.getTag(); double oldSize = dW.getCurrentSize(); double tempDiff = dW.updateSize(increment, true); if (oldSize != dW.getCurrentSize()) { hasChanged = true; } if (tempDiff != 0) { diff = tempDiff; } if (Math.abs(dW.getCurrentSize()) > maxSize) { maxSize = Math.abs(dW.getCurrentSize()); } } // // Do a second pass to modify the tags that aren't being resized // if the one that is resized has reached its max/min size if (diff != 0) { diff = diff / (tagCloud.size() - 1); for (SpannedNEffectPanel sep : tagCloud.values()) { ResizableTag dW = sep.getTag(); double oldSize = dW.getCurrentSize(); dW.updateSize(diff, false); if (oldSize != dW.getCurrentSize()) { hasChanged = true; } if (Math.abs(dW.getCurrentSize()) > maxSize) { maxSize = Math.abs(dW.getCurrentSize()); } } } lastY = newY; lastX = newX; } ((FocusPanel) arg0).setFocus(false); } @Override public void onMouseUp(Widget arg0, int arg1, int arg2) { for (SpannedNEffectPanel sep : tagCloud.values()) { ResizableTag dW = sep.getTag(); dW.setClickFalse(); } ((FocusPanel) arg0).setFocus(false); updateRecommendations(); } }); }
From source file:com.totsp.gwittir.client.fx.ui.ReflectedImageGroup.java
License:Open Source License
protected void render(Collection value) { this.images = new ReflectedImage[value.size()]; this.lastSelectedIndex = -1; this.imagesPanel.clear(); if (this.imagesPanel.getRowCount() > 0) { this.imagesPanel.removeRow(0); }/*from w ww.j a v a 2s .c om*/ if (value == null) { return; } Iterator<T> it = value.iterator(); final int maxSize = (int) (baseWidth * maxScalar) + 4; this.imagesPanel.setWidth(maxSize * value.size() + "px"); for (int i = 0; it.hasNext(); i++) { final int index = i; final T selectObject = it.next(); this.images[i] = new ReflectedImage(this.getRenderer().render(selectObject).toString(), this.baseWidth, this.baseHeight, this.reflectHeight, this.opacity); this.imagesPanel.getCellFormatter().setWidth(0, index, maxSize + "px"); this.imagesPanel.getCellFormatter().setHorizontalAlignment(0, index, HasHorizontalAlignment.ALIGN_CENTER); this.imagesPanel.setWidget(0, index, this.images[i]); this.images[i].addMouseListener(new MouseListener() { final Timer t = new Timer() { public void run() { if (selectObject != selected) { images[index].setHeight((int) (baseHeight * maxScalar)); images[index].setWidth((int) (baseWidth * maxScalar)); } } }; public void onMouseUp(Widget sender, int x, int y) { } public void onMouseMove(Widget sender, int x, int y) { } public void onMouseDown(Widget sender, int x, int y) { setSelected(selectObject); } public void onMouseLeave(Widget sender) { t.cancel(); if (selectObject != selected) { images[index].setHeight(baseHeight); images[index].setWidth(baseWidth); } } public void onMouseEnter(Widget sender) { t.schedule(50); } }); } }
From source file:com.xpn.xwiki.watch.client.ui.articles.ArticleListWidget.java
License:Open Source License
/** * Set the content panel visible, also handling panel initialization. Initially, if the panel is not visible, * it will be empty and will be initialized from the feed article upon first show, to optimize DOM manipulation * on list fill. /* ww w. j ava2 s . c o m*/ */ protected void showContentPanel(boolean visible, ComplexPanel contentPanel, FeedArticle article) { if (visible && (contentPanel.getWidgetCount() == 0)) { // populate this panel HTML content = new HTML(article.getContent()); content.setStyleName(watch.getStyleName("article", "content")); contentPanel.add(content); final FeedArticle myArticle = article; content.addMouseListener(new MouseListener() { public void onMouseUp(Widget arg0, int arg1, int arg2) { Document doc = (Document) Document.get(); Selection sel = doc.getSelection(); if (sel.toString() == "") { return; } selection = sel.toString(); currentArticle = myArticle; popup.center(); } public void onMouseMove(Widget arg0, int arg1, int arg2) { } public void onMouseLeave(Widget arg0) { } public void onMouseEnter(Widget arg0) { } public void onMouseDown(Widget arg0, int arg1, int arg2) { } }); } contentPanel.setVisible(visible); }
From source file:no.eirikb.piratewars.client.MapPanel.java
License:BEER-WARE LICENSE
public MapPanel(GamePanel gamePanel2, ImageHandler imageHandler2, Map map2, int width, int height, int frameWidth, int frameHeigth) { this.gamePanel = gamePanel2; this.imageHandler = imageHandler2; this.map = map2; canvas = new Canvas(this, width, height, frameWidth, frameHeigth); add(canvas);/* ww w . jav a 2s .com*/ Timer waterTimer = new Timer() { @Override public void run() { drawWater(); } }; waterTimer.scheduleRepeating(WATERDELAY); canvas.setListener(new MouseListener() { public void onMouseDown(Widget sender, int x, int y) { if (gamePanel.myTurn() && animateMove == null) { if (x / canvas.getFrameWidth() % 2 != 0) { y -= (canvas.getFrameHeight() / 2); } Frame f = getFrame(x, y); if (moveController == null && f.getShip() != null && f.getShip().isMovable() && gamePanel.isMe(f.getShip().getUser())) { moveController = new MoveController(map.getFrames()); moveController.addFrameNodes(f, f.getShip().getSteps()); drawWater(); } else if (moveController != null) { final FrameNode node = moveController.getFrameNode(f); if (node != null && node.getFrame().getShip() == null) { final Ship ship = moveController.getStart().getShip(); moveController = null; ship.setFrame(null); final Frame end = node.getFrame(); animateMove = new AnimateMove(canvas, imageHandler, node, ship); drawWater(); animateMove.setAnimateListener(new AnimateListener() { public void done() { ship.setFrame(end); ship.setMovable(false); gamePanel.move(); animateMove.stop(); animateMove = null; drawWater(); } }); animateMove.start(); } else { moveController = null; drawWater(); } } } } public void onMouseEnter(Widget sender) { } public void onMouseLeave(Widget sender) { } public void onMouseMove(Widget sender, int x, int y) { if (x / canvas.getFrameWidth() % 2 != 0) { y -= (canvas.getFrameHeight() / 2); } Frame f = getFrame(x, y); if (lastHover != null && !f.equals(lastHover)) { canvas.drawImage(imageHandler.getWater(), lastHover, false); if (lastHover.getShip() != null) { hover(lastHover); } if (moveController != null) { FrameNode node = moveController.getFrameNode(lastHover); if (node != null) { if (lastHover.getShip() == null) { hover(lastHover, 1); } } } lastHover = null; } if (f.getType() == FrameType.WATER) { hover(f); lastHover = f; } } public void onMouseUp(Widget sender, int x, int y) { } }); }
From source file:org.gwm.splice.client.toolbar.ToolBarButton.java
License:Apache License
public ToolBarButton(String imageName, String name, int actionID, String labelText, String tooltip, boolean showBorders) { super();//from ww w . j ava 2 s . c o m if (showBorders) { inactiveStyle = "toolbarButton-over"; } else { inactiveStyle = "toolbarButton"; } if (imageName != null) { image = new Image(DesktopManager.getInstance().getSmallIconUrl(imageName)); image.setStyleName("toolbarButtonImage"); } if (labelText != null) { label = new Label(labelText); label.setStyleName("toolbarButtonLabel"); } if (label != null) { HorizontalPanel hp = new HorizontalPanel(); if (image != null) { hp.add(image); } hp.add(label); hp.setHorizontalAlignment(hp.ALIGN_CENTER); hp.setVerticalAlignment(hp.ALIGN_MIDDLE); setWidget(hp); } else if (image != null) { setWidget(image); } this.name = name; this.actionID = actionID; if (tooltip != null) { setTitle(tooltip); } setStyleName(inactiveStyle); addMouseListener(new MouseListener() { public void onMouseEnter(Widget sender) { if (!disabled) setStyleName("toolbarButton-over"); } public void onMouseMove(Widget sender, int x, int y) { if (!disabled) setStyleName("toolbarButton-over"); } public void onMouseLeave(Widget sender) { if (!disabled) setStyleName(inactiveStyle); } public void onMouseDown(Widget sender, int x, int y) { if (!disabled) setStyleName("toolbarButton-pressed"); } public void onMouseUp(Widget sender, int x, int y) { if (!disabled) setStyleName("toolbarButton-over"); } }); }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.popup.TooltipPopup.java
License:Open Source License
/** * Static factory to show a tooltip.../* w ww .java2s. c o m*/ * * @param sender * @param text */ public TooltipPopup(Widget sender, String text) { this(sender, 0, 0, text, true); if (!(sender instanceof SourcesMouseEvents)) { return; } ((SourcesMouseEvents) sender).addMouseListener(new MouseListener() { public void onMouseDown(Widget sender, int x, int y) { // TODO Auto-generated method stub } public void onMouseEnter(Widget sender) { setRelLeft(sender.getOffsetWidth() + 16); setRelTop(16); show(); } public void onMouseLeave(Widget sender) { hide(); } public void onMouseMove(Widget sender, int x, int y) { // TODO Auto-generated method stub } public void onMouseUp(Widget sender, int x, int y) { // TODO Auto-generated method stub } }); }
From source file:org.pentaho.gwt.widgets.client.filechooser.FileChooser.java
License:Open Source License
public void initUI() { if (mode == FileChooserMode.OPEN_READ_ONLY) { fileNameTextBox.setReadOnly(true); }/*from www . ja va 2 s . c om*/ // We are here because we are initiating a fresh UI for a new directory // Since there is no file selected currently, we are setting file selected to false. setFileSelected(false); String path = this.selectedPath; // find the selected item from the list List<String> pathSegments = new ArrayList<String>(); if (path != null) { int index = path.indexOf("/", 0); //$NON-NLS-1$ while (index >= 0) { int oldIndex = index; index = path.indexOf("/", oldIndex + 1); //$NON-NLS-1$ if (index >= 0) { pathSegments.add(path.substring(oldIndex + 1, index)); } } pathSegments.add(path.substring(path.lastIndexOf("/") + 1)); //$NON-NLS-1$ } selectedTreeItem = getTreeItem(pathSegments); navigationListBox = new ListBox(); navigationListBox.getElement().setId("navigationListBox"); //$NON-NLS-1$ navigationListBox.setWidth("350px"); //$NON-NLS-1$ // now we can find the tree nodes who match the path segments navigationListBox.addItem("/", "/"); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < pathSegments.size(); i++) { String segment = pathSegments.get(i); String fullPath = ""; //$NON-NLS-1$ for (int j = 0; j <= i; j++) { String segmentPath = pathSegments.get(j); if (segmentPath != null && segmentPath.length() > 0) { fullPath += "/" + segmentPath; //$NON-NLS-1$ } } if (!fullPath.equals("/")) { //$NON-NLS-1$ navigationListBox.addItem(fullPath, segment); } } navigationListBox.setSelectedIndex(navigationListBox.getItemCount() - 1); navigationListBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { changeToPath(navigationListBox.getItemText(navigationListBox.getSelectedIndex())); } }); clear(); VerticalPanel locationBar = new VerticalPanel(); locationBar.add(new Label(FileChooserEntryPoint.messages.getString("location"))); //$NON-NLS-1$ HorizontalPanel navigationBar = new HorizontalPanel(); final Image upDirImage = new Image(); upDirImage.setUrl(GWT.getModuleBaseURL() + "images/spacer.gif"); //$NON-NLS-1$ upDirImage.addStyleName("pentaho-filechooseupbutton"); //$NON-NLS-1$ upDirImage.setTitle(FileChooserEntryPoint.messages.getString("upOneLevel")); //$NON-NLS-1$ upDirImage.addMouseListener(new MouseListener() { public void onMouseDown(Widget sender, int x, int y) { } public void onMouseEnter(Widget sender) { } public void onMouseLeave(Widget sender) { } public void onMouseMove(Widget sender, int x, int y) { } public void onMouseUp(Widget sender, int x, int y) { } }); upDirImage.addClickListener(new ClickListener() { public void onClick(Widget sender) { // go up a dir TreeItem tmpItem = selectedTreeItem; List<String> parentSegments = new ArrayList<String>(); while (tmpItem != null) { RepositoryFileTree tree = (RepositoryFileTree) tmpItem.getUserObject(); if (tree.getFile() != null && tree.getFile().getName() != null) { parentSegments.add(tree.getFile().getName()); } tmpItem = tmpItem.getParentItem(); } Collections.reverse(parentSegments); String myPath = ""; //$NON-NLS-1$ // If we have a file selected then we need to go one lesser level deep final int loopCount = isFileSelected() ? parentSegments.size() - 2 : parentSegments.size() - 1; for (int i = 0; i < loopCount; i++) { String pathSegment = parentSegments.get(i); if (pathSegment != null && pathSegment.length() > 0) { myPath += "/" + pathSegment; //$NON-NLS-1$ } } if (myPath.equals("")) { //$NON-NLS-1$ myPath = "/"; //$NON-NLS-1$ } selectedTreeItem = selectedTreeItem.getParentItem(); if (selectedTreeItem == null) { selectedTreeItem = repositoryTree.getItem(0); } changeToPath(myPath); } }); navigationBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); navigationBar.add(navigationListBox); navigationBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); navigationBar.add(upDirImage); navigationBar.setCellWidth(upDirImage, "100%"); //$NON-NLS-1$ DOM.setStyleAttribute(upDirImage.getElement(), "marginLeft", "4px"); navigationBar.setWidth("100%"); //$NON-NLS-1$ locationBar.add(navigationBar); locationBar.setWidth("100%"); //$NON-NLS-1$ Label filenameLabel = new Label(FileChooserEntryPoint.messages.getString("filename")); //$NON-NLS-1$ filenameLabel.setWidth("550px"); //$NON-NLS-1$ add(filenameLabel); fileNameTextBox.setWidth("300px"); //$NON-NLS-1$ add(fileNameTextBox); add(locationBar); add(buildFilesList(selectedTreeItem)); }