List of usage examples for com.google.gwt.user.client DOM getElementAttribute
@Deprecated public static String getElementAttribute(Element elem, String attr)
From source file:cc.kune.core.client.state.LinkInterceptor.java
License:GNU Affero Public License
@Override public void onPreviewNativeEvent(final NativePreviewEvent nativeEventPreview) { final Event event = Event.as(nativeEventPreview.getNativeEvent()); final String base = GWT.getHostPageBaseURL(); if (nativeEventPreview.getTypeInt() == Event.ONCLICK) { try {//www . j a v a 2s.c o m final Element target = DOM.eventGetTarget(event); if (A.equalsIgnoreCase(target.getTagName())) { final String href = DOM.getElementAttribute(target, HREF); if (LinkInterceptorHelper.isLocal(href, base)) { // Is a local link so we try to use the history without load a new // page final String hash = LinkInterceptorHelper.getHash(href); if (hash.equals(href)) { // Is not a different hash, so continue } else { // Is a local link so we use the history history.newItem(hash); nativeEventPreview.cancel(); } } else { // External URL so just follow (normally with target="_blank") } } } catch (final Exception e) { Log.info("Error trying to intercept link clink event"); } } }
From source file:com.bkitmobile.poma.ui.client.imagechooser.ImageChooser.java
License:Open Source License
/** * This method creates the two view for displaying the images. The main view * is the one that displays all the images to select. The second view * displays the selected images with information about the image. *//*from w w w . ja v a2 s .c o m*/ private void createView() { // the thumb nail template for the main view String thumbTemplate[] = new String[] { "<tpl for='.'>", "<div class='thumb-wrap' id='{name}'>", "<div class='thumb'><img src='{url}' title='{name}'></div>", "<span>{shortName}</span></div>", "</tpl>", "<div class='x-clear'></div>" }; // the detail template for the selected image String detailTemplate[] = new String[] { "<tpl for='.'>", "<div class='details'><img src='{url}'>", "<div class='details-info'><b>Image Name:</b>", "<span>{name}</span><b>Size:</b>", "<span>{sizeString}</span><b>Last Modified:</b>", "<span>{dateString}</span></div></div>", "</tpl>", "<div class='x-clear'></div>" }; // compile the templates final XTemplate thumbsTemplate = new XTemplate(thumbTemplate); final XTemplate detailsTemplate = new XTemplate(detailTemplate); thumbsTemplate.compile(); detailsTemplate.compile(); views = new DataView[6]; for (int i = 0; i < 6; i++) { // initialize the View using the thumb nail template views[i] = new DataView("div.thumb-wrap") { public void prepareData(Data data) { ImageData newImageData = null; String name = data.getProperty("name"); String sizeString = data.getProperty("size"); data.setProperty("shortName", Format.ellipsis(data.getProperty("name"), 15)); data.setProperty("sizeString", sizeString); if (imageMap.containsKey(name)) { newImageData = (ImageData) imageMap.get(name); } else { newImageData = new ImageData(); imageMap.put(name, newImageData); } newImageData.setFileName(name); newImageData.setName(name); newImageData.setSize(Long.parseLong(data.getProperty("size"))); newImageData.setUrl(data.getProperty("url")); } }; views[i].setSingleSelect(true); views[i].setTpl(thumbsTemplate); views[i].setAutoHeight(true); views[i].setStore(stores[i]); // view.setOverCls("x-view-over"); // if there is no images that can be found, just output an message views[i].setEmptyText(constants.views_setEmptyText()); views[i].addListener(new DataViewListenerAdapter() { /** * This method is called when a selection is made changing the * previous selection * * @params view the view that this selection is for * @params selections a list of all selected items. There should * only be one as we only allow 1 selection. */ public void onSelectionChange(DataView component, Element[] selections) { // if there is a selection and show the details if (selections != null && selections.length > 0 && selections[0] != null) { // enable the ok button now there is a selection made btnOK.enable(); String id = DOM.getElementAttribute(selections[0], "id"); imageData = (ImageData) imageMap.get(id); } else { // no selection means the ok button should be disabled // and // the detail // area should be blanked out btnOK.disable(); } } }); } // end for }
From source file:com.edgenius.wiki.gwt.client.BaseEntryPoint.java
License:Open Source License
public static String getSystemTitle() { // hidden type Element titleDiv = DOM.getElementById("systemTitle"); if (titleDiv != null) { String title = DOM.getElementAttribute(titleDiv, "value"); return title; }/*from www. ja v a 2s . com*/ return SharedConstants.APP_NAME; }
From source file:com.edgenius.wiki.gwt.client.login.LoginEntryPoint.java
License:Open Source License
private void showLoginDeck() { main.clear();/*from w ww. j a v a2 s . c o m*/ main.add(logoBar); //get Hidden value from page - this value is redir URL value Element redirDiv = RootPanel.get("redirURLForLogin").getElement(); String redirUrl = DOM.getElementAttribute(redirDiv, "value"); Element regisgerDiv = RootPanel.get("regisgerDiv").getElement(); String regisger = DOM.getElementAttribute(regisgerDiv, "value"); LoginSignupDeck deck = new LoginSignupDeck(redirUrl, null, "true".equalsIgnoreCase(regisger) ? LoginDialog.SINGUP : LoginDialog.LOGIN); deck.addUserCreateListener(this); main.add(deck); DOM.setStyleAttribute(deck.getElement(), "width", "100%"); main.setCellHorizontalAlignment(logoBar, HasHorizontalAlignment.ALIGN_CENTER); main.setCellVerticalAlignment(logoBar, HasVerticalAlignment.ALIGN_BOTTOM); main.setCellHorizontalAlignment(deck, HasHorizontalAlignment.ALIGN_CENTER); }
From source file:com.edgenius.wiki.gwt.client.page.PageMain.java
License:Open Source License
public static String getShellUrl() { // hidden type Element titleDiv = DOM.getElementById("shellUrl"); if (titleDiv != null) { String title = DOM.getElementAttribute(titleDiv, "value"); if (!StringUtil.isEmpty(title) && !"null".equals(title)) { return title; }/*w w w. j a v a 2 s. c o m*/ } return null; }
From source file:com.ephesoft.dcma.gwt.admin.bm.client.view.kvextraction.advancedkvextraction.AdvancedKVExtractionView.java
License:Open Source License
/** * Constructor.//from w w w. j ava2s . c o m */ public AdvancedKVExtractionView() { super(); initWidget(BINDER.createAndBindUi(this)); this.kvExtractionTestResultView = new KVExtractionTestResultView(); valuePattern.addStyleName(AdminConstants.GWT_ADVANCED_KV_TEXT_BOX); editKey.setText(AdminConstants.EDIT_KEY); editValue.setText(AdminConstants.EDIT_VALUE); previousOptions.setText(AdminConstants.PREVIOUS); nextOptions.setText(AdminConstants.NEXT); samplePatternButton.setText(AdminConstants.SAMPLE_REGEX_BUTTON); keyPatternValidateButton.setTitle(AdminConstants.VALIDATE_BUTTON); valuePatternValidateButton.setTitle(AdminConstants.VALIDATE_BUTTON); keyPatternValidateButton.setStyleName(AdminConstants.VALIDATE_BUTTON_IMAGE); valuePatternValidateButton.setStyleName(AdminConstants.VALIDATE_BUTTON_IMAGE); saveButton.setText(AdminConstants.OK_BUTTON); cancelButton.setText(AdminConstants.CANCEL_BUTTON); saveButton.setHeight(AdminConstants.BUTTON_HEIGHT); cancelButton.setHeight(AdminConstants.BUTTON_HEIGHT); useExistingKeyLabel.setText( LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.USE_EXISTING_KEY_LABEL)); useExistingKeyLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); keyPatternLabel.setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.KEY_PATTERN) + AdminConstants.COLON); keyPatternLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); keyPatternStar.setText(AdminConstants.STAR); keyPatternStar.setStyleName(AdminConstants.FONT_RED_STYLE); setKeyPatternPanelView(); valuePatternLabel .setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.VALUE_PATTERN) + AdminConstants.COLON); valuePatternLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); valuePatternStar.setText(AdminConstants.STAR); valuePatternStar.setStyleName(AdminConstants.FONT_RED_STYLE); fetchValueLabel.setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.FETCH_VALUE) + AdminConstants.COLON); fetchValueLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); fetchValueStar.setText(AdminConstants.STAR); fetchValueStar.setStyleName(AdminConstants.FONT_RED_STYLE); kvPageValueLabel .setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.KV_PAGE_VALUE_LABEL) + AdminConstants.COLON); kvPageValueLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); kvPageValueStar.setText(AdminConstants.STAR); kvPageValueStar.setStyleName(AdminConstants.FONT_RED_STYLE); lengthLabel.setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.LENGTH_LABEL) + AdminConstants.COLON); lengthLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); lengthStar.setText(AdminConstants.STAR); lengthStar.setStyleName(AdminConstants.FONT_RED_STYLE); widthLabel.setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.WIDTH_LABEL) + AdminConstants.COLON); widthLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); widthStar.setText(AdminConstants.STAR); widthStar.setStyleName(AdminConstants.FONT_RED_STYLE); xOffsetLabel.setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.XOFFSET_LABEL) + AdminConstants.COLON); xOffsetLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); xOffsetStar.setText(AdminConstants.STAR); xOffsetStar.setStyleName(AdminConstants.FONT_RED_STYLE); yOffsetLabel.setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.YOFFSET_LABEL) + AdminConstants.COLON); yOffsetLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); yOffsetStar.setText(AdminConstants.STAR); yOffsetStar.setStyleName(AdminConstants.FONT_RED_STYLE); multiplierLabel .setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.MULTIPLIER_LABEL) + AdminConstants.COLON); multiplierLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); advancedKVLayoutPanel.setStyleName(AdminConstants.BORDER_STYLE); advancedKVLayoutPanel.setWidth("100%"); oldKVExtractionProperties.setSpacing(BatchClassManagementConstants.SIX); oldKVExtractionProperties.addStyleName("background_group"); newKVExtractionProperties.setSpacing(BatchClassManagementConstants.SIX); newKVExtractionProperties.addStyleName("background_group"); groupingKVExtractionProperties.addStyleName("right_border"); imageUpload.addStyleName(AdminConstants.BUTTON_PADDING_STYLE); imageUpload.setEncoding(FormPanel.ENCODING_MULTIPART); imageUpload.setMethod(FormPanel.METHOD_POST); imageUpload.setAction("dcma-gwt-admin/uploadImageFile"); captureKey .setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.CAPTURE_KEY_BUTTON)); captureValue.setText( LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.CAPTURE_VALUE_BUTTON)); clearButton.setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.CLEAR_BUTTON)); testAdvKvButton .setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.TEST_ADV_KV_LABEL)); validateKeyPatternTextBox = new RegExValidatableWidget<TextBox>(keyPatternText); validateKeyPatternTextBox.getWidget().addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { validateKeyPatternTextBox.setValid(false); } }); validateValuePatternTextBox = new RegExValidatableWidget<TextBox>(valuePattern); validateValuePatternTextBox.getWidget().addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { validateValuePatternTextBox.setValid(false); } }); validateMultiplierTextBox = new ValidatableWidget<TextBox>(multiplier); validateMultiplierTextBox.getWidget().addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> arg0) { validateMultiplierTextBox.toggleValidDateBox(); } }); length.setReadOnly(true); width.setReadOnly(true); xOffset.setReadOnly(true); yOffset.setReadOnly(true); initialOptionsPanel.setSpacing(BatchClassManagementConstants.THREE); secondOptionsPanel.setSpacing(BatchClassManagementConstants.THREE); optionsSlidingPanel.setWidget(initialOptionsPanel); tempImage.setVisible(false); keyValueCoordinates = new KeyValueCoordinates(this); disableAllButtons(); dimensionImage.setVisible(false); dimensionImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(final LoadEvent arg0) { // Do nothing } }); tempImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent arg0) { resetOperations(); pageImage.setVisible(true); ScreenMaskUtility.unmaskScreen(); DOM.setElementAttribute(pageImage.getElement(), "src", (DOM.getElementAttribute(dimensionImage.getElement(), "src"))); pageImage.setUrl(dimensionImage.getUrl()); originalWidth = dimensionImage.getWidth(); originalHeight = dimensionImage.getHeight(); loadImage(); } }); tempImage.addErrorHandler(new ErrorHandler() { @Override public void onError(ErrorEvent arg0) { ScreenMaskUtility.unmaskScreen(); removeAllOverlays(); presenter.setEditAdvancedKV(false); ConfirmationDialogUtil.showConfirmationDialogError( LocaleDictionary.get().getMessageValue(BatchClassManagementMessages.ERROR_UPLOAD_IMAGE)); } }); pageImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent arg0) { // loadImage(); } }); importFile.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent arg0) { imageUpload.submit(); } }); imageUpload.addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { String fileName = importFile.getFilename(); String fileExt = fileName.substring(fileName.lastIndexOf('.') + 1); if (!fileExt.equalsIgnoreCase("tiff") && !fileExt.equalsIgnoreCase("tif")) { ScreenMaskUtility.unmaskScreen(); ConfirmationDialogUtil.showConfirmationDialogError(MessageConstants.UPLOAD_IMAGE_INVALID_TYPE); event.cancel(); } batchClassID.setValue(presenter.getController().getBatchClass().getIdentifier()); docName.setValue(presenter.getController().getSelectedDocument().getName()); } }); imageUpload.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent arg0) { String result = arg0.getResults(); if (result.toLowerCase().indexOf(AdminConstants.ERROR_CODE_TEXT) > -1) { ScreenMaskUtility.unmaskScreen(); presenter.setEditAdvancedKV(false); ConfirmationDialogUtil.showConfirmationDialogError(LocaleDictionary.get() .getMessageValue(BatchClassManagementMessages.ERROR_UPLOAD_IMAGE)); return; } String fileName = importFile.getFilename(); String fileSeperatorParam = "file_seperator:"; String fileSeparator = null; int index = result.indexOf(fileSeperatorParam); if (index != -1) { int endIndex = result.indexOf('|', index); if (endIndex != -1) { fileSeparator = result.substring(index + fileSeperatorParam.length(), endIndex); } else { fileSeparator = result.substring(index + fileSeperatorParam.length()); } } if (fileName != null && fileSeparator != null) { fileName = fileName.substring(fileName.lastIndexOf(fileSeparator) + 1); } String pngFileName = fileName.substring(0, fileName.lastIndexOf(EXTENSION_CHAR) + 1) + EXTENSION_PNG; presenter.setImageNameInDTO(fileName, pngFileName); presenter.setEditAdvancedKV(false); presenter.getPageImageUrl(batchClassID.getValue(), docName.getValue(), pngFileName); } }); pageImage.addStyleName("pointer"); pageImage.addMouseDownHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent paramMouseDownEvent) { int xVal = paramMouseDownEvent.getX(); int yVal = paramMouseDownEvent.getY(); switch (lastOperation) { case KEY: Coordinates keyCoordinates = keyValueCoordinates.getKeyCoordinates(); findAndSetEditableCoordinate(xVal, yVal, keyCoordinates, true); break; case VALUE: Coordinates valueCoordinates = keyValueCoordinates.getValueCoordinates(); findAndSetEditableCoordinate(xVal, yVal, valueCoordinates, false); break; case NONE: int nativeButton = paramMouseDownEvent.getNativeButton(); if (NativeEvent.BUTTON_LEFT == nativeButton) { setEditValueAndTestAdvKvButton(); keyValueCoordinates.mouseDownat(xVal, yVal); } else if (NativeEvent.BUTTON_RIGHT == nativeButton) { pageImage.setTitle(null); int clientY = paramMouseDownEvent.getClientY(); int clientX = paramMouseDownEvent.getClientX(); if (spanList == null) { presenter.getSpanList(xVal, yVal, clientX, clientY); } else { extractSpanValue(xVal, yVal, clientX, clientY); } } break; default: break; } } }); pageImage.addMouseMoveHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent paramMouseMoveEvent) { int xVal = paramMouseMoveEvent.getX(); int yVal = paramMouseMoveEvent.getY(); Coordinates valueCoordinates = keyValueCoordinates.getValueCoordinates(); Coordinates keyCoordinates = keyValueCoordinates.getKeyCoordinates(); switch (lastOperation) { case KEY: moveMouseAt(xVal, yVal, keyCoordinates); keyCoordinates.doOverlay(); createOverlay(valueCoordinates.getX0(), valueCoordinates.getX1(), valueCoordinates.getY0(), valueCoordinates.getY1(), 1, false, true); break; case VALUE: moveMouseAt(xVal, yVal, valueCoordinates); valueCoordinates.doOverlay(); createOverlay(keyCoordinates.getX0(), keyCoordinates.getX1(), keyCoordinates.getY0(), keyCoordinates.getY1(), 1, true, false); break; case NONE: { keyValueCoordinates.mouseMoveat(xVal, yVal); break; } default: break; } } private void moveMouseAt(int xVal, int yVal, Coordinates coordinates) { switch (editableCoordinate) { case X0: if (xVal < coordinates.getX1()) { coordinates.setX0(xVal); } break; case Y0: if (yVal < coordinates.getY1()) { coordinates.setY0(yVal); } break; case X1: if (xVal > coordinates.getX0()) { coordinates.setX1(xVal); } break; case Y1: if (yVal > coordinates.getY0()) { coordinates.setY1(yVal); } break; default: break; } } }); imageScroll.addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent paramScrollEvent) { keyValueCoordinates.createNewOverlay(); contextMenu.hide(); } }); pageImage.setVisible(false); }
From source file:com.ephesoft.dcma.gwt.admin.bm.client.view.tablecolumninfo.advancedtableextraction.AdvancedTableExtractionView.java
License:Open Source License
/** * Constructor.//w ww . j a v a 2 s .c o m */ public AdvancedTableExtractionView() { super(); initWidget(BINDER.createAndBindUi(this)); colStartCoord.addStyleName(AdminConstants.WIDTH_COORDINATE_LABELS); colEndCoord.addStyleName(AdminConstants.WIDTH_COORDINATE_LABELS); saveButton.setText(AdminConstants.OK_BUTTON); cancelButton.setText(AdminConstants.CANCEL_BUTTON); saveButton.setHeight(AdminConstants.BUTTON_HEIGHT); cancelButton.setHeight(AdminConstants.BUTTON_HEIGHT); clearButton.setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.CLEAR_BUTTON)); clearAllButton .setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.CLEAR_ALL_BUTTON)); colStartCoordLabel.setText( LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.COLUMN_START_COORDINATE_LABEL) + AdminConstants.COLON); colStartCoordLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); colStartCoordStar.setText(AdminConstants.STAR); colStartCoordStar.setStyleName(AdminConstants.FONT_RED_STYLE); colEndCoordLabel.setText( LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.COLUMN_END_COORDINATE_LABEL) + AdminConstants.COLON); colEndCoordLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); colEndCoordStar.setText(AdminConstants.STAR); colEndCoordStar.setStyleName(AdminConstants.FONT_RED_STYLE); tableColumnLabel .setText(LocaleDictionary.get().getConstantValue(BatchClassManagementConstants.CHOOSE_TABLE_COLUMN) + AdminConstants.COLON); tableColumnLabel.setStyleName(AdminConstants.BOLD_TEXT_STYLE); advancedTELayoutPanel.setStyleName(AdminConstants.BORDER_STYLE); advancedTELayoutPanel.setWidth("100%"); tableColumnsInfoProperties.setSpacing(BatchClassManagementConstants.SIX); tableColumnsInfoProperties.addStyleName("background_group"); dynamicTabColInfoProperties.setSpacing(BatchClassManagementConstants.SIX); dynamicTabColInfoProperties.addStyleName("background_group"); groupingTabColInfoProperties.addStyleName("right_border"); imageUpload.addStyleName(AdminConstants.BUTTON_PADDING_STYLE); imageUpload.setEncoding(FormPanel.ENCODING_MULTIPART); imageUpload.setMethod(FormPanel.METHOD_POST); imageUpload.setAction("dcma-gwt-admin/uploadImageFile"); colStartCoord.setReadOnly(true); colEndCoord.setReadOnly(true); tempImage.setVisible(false); dimensionImage.setVisible(false); isAdvancedTableInfo.setValue(String.valueOf(Boolean.TRUE)); tableColumnCoordinates = new TableColumnCoordinates(this); tableColumnInfoList.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent arg0) { presenter.setSelectedTableColumnInfoDTO( tableColumnInfoList.getValue(tableColumnInfoList.getSelectedIndex())); } }); dimensionImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent arg0) { // TODO Auto-generated method stub } }); tempImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent arg0) { pageImage.setVisible(true); ScreenMaskUtility.unmaskScreen(); DOM.setElementAttribute(pageImage.getElement(), "src", (DOM.getElementAttribute(dimensionImage.getElement(), "src"))); pageImage.setUrl(dimensionImage.getUrl()); originalWidth = dimensionImage.getWidth(); originalHeight = dimensionImage.getHeight(); loadImage(); } }); tempImage.addErrorHandler(new ErrorHandler() { @Override public void onError(ErrorEvent arg0) { ScreenMaskUtility.unmaskScreen(); removeAllOverlays(); ConfirmationDialogUtil.showConfirmationDialogError( LocaleDictionary.get().getMessageValue(BatchClassManagementMessages.ERROR_UPLOAD_IMAGE)); } }); pageImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent arg0) { // loadImage(); } }); importFile.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent arg0) { imageUpload.submit(); } }); imageUpload.addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { ScreenMaskUtility.maskScreen(); String fileName = importFile.getFilename(); if (!fileName.toLowerCase().endsWith(AdminConstants.EXTENSION_TIFF) && !fileName.toLowerCase().endsWith(AdminConstants.EXTENSION_TIF)) { ScreenMaskUtility.unmaskScreen(); ConfirmationDialogUtil.showConfirmationDialogError(MessageConstants.UPLOAD_IMAGE_INVALID_TYPE); event.cancel(); } batchClassID.setValue(presenter.getController().getBatchClass().getIdentifier()); docName.setValue(presenter.getController().getSelectedDocument().getName()); } }); imageUpload.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent arg0) { String result = arg0.getResults(); if (result.toLowerCase().indexOf(AdminConstants.ERROR_CODE_TEXT) > -1) { ScreenMaskUtility.unmaskScreen(); ConfirmationDialogUtil.showConfirmationDialogError(LocaleDictionary.get() .getMessageValue(BatchClassManagementMessages.ERROR_UPLOAD_IMAGE)); return; } String fileName = importFile.getFilename(); String fileSeperatorParam = AdminConstants.FILE_SEPARATOR_PARAM; String fileSeparator = null; int index = result.indexOf(fileSeperatorParam); if (index != -1) { int endIndex = result.indexOf('|', index); if (endIndex != -1) { fileSeparator = result.substring(index + fileSeperatorParam.length(), endIndex); } else { fileSeparator = result.substring(index + fileSeperatorParam.length()); } } if (fileName != null && fileSeparator != null) { fileName = fileName.substring(fileName.lastIndexOf(fileSeparator) + 1); } String pngFileName = fileName.substring(0, fileName.lastIndexOf(AdminConstants.EXTENSION_CHAR) + 1) + AdminConstants.EXTENSION_PNG; presenter.getPageImageUrl(batchClassID.getValue(), docName.getValue(), pngFileName); } }); pageImage.addStyleName("pointer"); pageImage.addMouseDownHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent paramMouseDownEvent) { int xVal = paramMouseDownEvent.getX(); int yVal = paramMouseDownEvent.getY(); int nativeButton = paramMouseDownEvent.getNativeButton(); if (NativeEvent.BUTTON_LEFT == nativeButton) { tableColumnCoordinates.mouseDownat(xVal, yVal); } } }); pageImage.addMouseMoveHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent paramMouseMoveEvent) { int xVal = paramMouseMoveEvent.getX(); int yVal = paramMouseMoveEvent.getY(); tableColumnCoordinates.mouseMoveat(xVal, yVal); } }); imageScroll.addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent paramScrollEvent) { tableColumnCoordinates.createNewOverlay(); contextMenu.hide(); } }); pageImage.setVisible(false); }
From source file:com.ephesoft.dcma.gwt.rv.client.view.ImageOverlayPanel.java
License:Open Source License
/** * The <code>ImageOverlayPanel</code> method is a default constructor which * initializes default view for overlay on validation screen shown to user. *//*from w w w. j a v a2s .c o m*/ public ImageOverlayPanel() { super(); final DockLayoutPanel layoutPanel = BINDER.createAndBindUi(this); initWidget(layoutPanel); movePageButton.setStyleName("move_button"); splitButton.setStyleName("split_button"); splitButton.setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TOOLTIP_SPLIT)); deleteButton.setStyleName("delete_button"); deleteButton.setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TOOLTIP_DELETE)); duplicatePageButton.setStyleName("duplicate_button"); duplicatePageButton .setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TOOLTIP_DUPLICATE)); movePageButton.setStyleName("move_page_button"); movePageButton.setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TOOLTIP_MOVE)); zoomin.setStyleName("zoom_in"); zoomin.setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TOOLTIP_ZOOM_IN)); zoomout.setStyleName("zoom_out"); zoomout.setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TOOLTIP_ZOOM_OUT)); rotate.setStyleName("rotate_button"); fitToPage.setStyleName("fit_to_page"); fitToPage.setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TOOLTIP_FIT_TO_PAGE)); rotate.setTitle(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TOOLTIP_ROTATE)); tempImage.setVisible(false); zoomLock = new ZoomLock(this); pageImage.setUrl(EMPTY_STRING); dimensionImage.setVisible(false); dimensionImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(final LoadEvent arg0) { // Do nothing } }); tempImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(final LoadEvent loadEvent) { int width = tempImage.getWidth(); int height = tempImage.getHeight(); // For 3rd panel image load issue on IE DOM.setElementAttribute(dimensionImage.getElement(), ReviewValidateConstants.SOURCE, (DOM.getElementAttribute(tempImage.getElement(), ReviewValidateConstants.SOURCE))); final String currentBrowser = getUserAgent(); // If current browser is IE then set image width and height from dimension image. if (currentBrowser != null && currentBrowser.length() > 0 && currentBrowser.contains(ReviewValidateConstants.IE_BROWSER)) { if (width <= 0) { width = dimensionImage.getWidth(); } if (height <= 0) { height = dimensionImage.getHeight(); } } if (!(initialPageDimensions.containsKey(presenter.page.getIdentifier()))) { final ArrayList<Integer> dimensions = new ArrayList<Integer>(); dimensions.add(width); dimensions.add(height); initialPageDimensions.put(presenter.page.getIdentifier(), dimensions); } pageImage.setVisible(false); removeOverlays(); pageImage.setUrl( tempImage.getUrl().substring(0, tempImage.getUrl().indexOf(ReviewValidateConstants.QUESTION_MARK)), presenter.page.getDirection()); pageImage.setStyleName(ReviewValidateConstants.CSS_THUMBNAIL_HIGHLIGHTED); } }); pageImage.addMouseUpHandler(new MouseUpHandler() { @Override public void onMouseUp(final MouseUpEvent mouseUp) { if (presenter.batchDTO.getBatchInstanceStatus().equals(BatchInstanceStatus.READY_FOR_VALIDATION)) { final double aspectRatio = (double) (pageImage.getWidth()) / (double) (originalWidth); int xCoordinate = (int) Math.round(mouseUp.getX() / aspectRatio); int yCoordinate = (int) Math.round(mouseUp.getY() / aspectRatio); if (presenter.isTableView() && presenter.isManualTableExtraction()) { if (isFirstClick) { pageImage.setStyleName(ReviewValidateConstants.POINTER); pointCoordinate1.setxCoordinate(xCoordinate); pointCoordinate1.setyCoordinate(yCoordinate); isFirstClick = false; } else { pageImage.removeStyleName(ReviewValidateConstants.POINTER); if (xCoordinate < pointCoordinate1.getxCoordinate()) { final int temp = pointCoordinate1.getxCoordinate(); pointCoordinate1.setxCoordinate(xCoordinate); xCoordinate = temp; } if (yCoordinate < pointCoordinate1.getyCoordinate()) { final int temp = pointCoordinate1.getyCoordinate(); pointCoordinate1.setyCoordinate(yCoordinate); yCoordinate = temp; } pointCoordinate2.setxCoordinate(xCoordinate); pointCoordinate2.setyCoordinate(yCoordinate); if (presenter.getView().getTableExtractionView().isValidCoordinate(pointCoordinate1, pointCoordinate2)) { presenter.getTableHOCRContent(pointCoordinate1, pointCoordinate2); } isFirstClick = true; } } else if (!presenter.isManualTableExtraction()) { if (mouseUp.getNativeButton() == Event.BUTTON_RIGHT) { clickCount = 0; ctrlKeyPressed = false; shiftKeyPressed = false; if (!rightMouseFirstClickDone) { pageImage.addStyleName(ReviewValidateConstants.POINTER); pointCoordinate1.setxCoordinate(xCoordinate); pointCoordinate1.setyCoordinate(yCoordinate); rightMouseFirstClickDone = true; } else { if (xCoordinate < pointCoordinate1.getxCoordinate()) { final int temp = pointCoordinate1.getxCoordinate(); pointCoordinate1.setxCoordinate(xCoordinate); xCoordinate = temp; } if (yCoordinate < pointCoordinate1.getyCoordinate()) { final int temp = pointCoordinate1.getyCoordinate(); pointCoordinate1.setyCoordinate(yCoordinate); yCoordinate = temp; } pageImage.removeStyleName(ReviewValidateConstants.POINTER); pointCoordinate2.setxCoordinate(xCoordinate); pointCoordinate2.setyCoordinate(yCoordinate); rightMouseFirstClickDone = false; presenter.getHOCRContent(pointCoordinate1, pointCoordinate2, true); } } else { rightMouseFirstClickDone = false; if (shiftKeyPressed) { if (clickCount == 0) { pointCoordinate1.setxCoordinate(xCoordinate); pointCoordinate1.setyCoordinate(yCoordinate); clickCount = 1; } else { pointCoordinate2.setxCoordinate(xCoordinate); pointCoordinate2.setyCoordinate(yCoordinate); presenter.getHOCRContent(pointCoordinate1, pointCoordinate2, false); } } else if (ctrlKeyPressed) { if (clickCount == 0 || pointCoordinates == null) { pointCoordinates = new ArrayList<PointCoordinate>(); } final PointCoordinate pointCoordinate = new PointCoordinate(); pointCoordinate.setxCoordinate(xCoordinate); pointCoordinate.setyCoordinate(yCoordinate); pointCoordinates.add(pointCoordinate); presenter.getHOCRContent(pointCoordinates); clickCount++; } else { pointCoordinates = new ArrayList<PointCoordinate>(1); final PointCoordinate pointCoordinate = new PointCoordinate(); pointCoordinate.setxCoordinate(xCoordinate); pointCoordinate.setyCoordinate(yCoordinate); pointCoordinates.add(pointCoordinate); presenter.getHOCRContent(pointCoordinates); } } } } } }); splitButton.setEnabled(false); deleteButton.setEnabled(false); duplicatePageButton.setEnabled(false); movePageButton.setEnabled(false); zoomin.setEnabled(false); zoomout.setEnabled(false); rotate.setEnabled(false); fitToPage.setEnabled(false); pageImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(final LoadEvent arg0) { splitButton.setEnabled(true); deleteButton.setEnabled(true); duplicatePageButton.setEnabled(true); movePageButton.setEnabled(true); zoomin.setEnabled(true); zoomout.setEnabled(true); rotate.setEnabled(true); fitToPage.setEnabled(true); loadImage(); pageImage.setVisible(true); } }); imageScrollPanel.addScrollHandler(new ScrollHandler() { @Override public void onScroll(final ScrollEvent arg0) { processOverlay(coordinatesTypeList, imageScrollPanel.getHorizontalScrollPosition(), imageScrollPanel.getScrollPosition(), 1); } }); imageOverlayViewPanel.addStyleName("right1"); pageImage.addMouseMoveHandler(new MouseMoveHandler() { @Override public void onMouseMove(final MouseMoveEvent paramMouseMoveEvent) { if (presenter.batchDTO.getBatchInstanceStatus().equals(BatchInstanceStatus.READY_FOR_VALIDATION)) { if (presenter.isManualTableExtraction() || (!presenter.isManualTableExtraction() && rightMouseFirstClickDone)) { final double aspectRatio = (double) (pageImage.getWidth()) / (double) (originalWidth); final int xCoordinate = (int) Math.round(paramMouseMoveEvent.getX() / aspectRatio); final int yCoordinate = (int) Math.round(paramMouseMoveEvent.getY() / aspectRatio); pointCoordinate2.setxCoordinate(xCoordinate); pointCoordinate2.setyCoordinate(yCoordinate); if ((presenter.isManualTableExtraction() && !isFirstClick) || (rightMouseFirstClickDone && !presenter.isManualTableExtraction())) { // pageImage.addStyleName("pointer"); doOverlay(pointCoordinate1, pointCoordinate2); } } else { pageImage.removeStyleName(ReviewValidateConstants.POINTER); } } } }); }
From source file:com.extjs.gxt.ui.client.util.TreeBuilder.java
License:Open Source License
private static void process(TreeItem item, Element parent) { int size = DOM.getChildCount(parent); for (int i = 0; i < size; i++) { Element li = DOM.getChild(parent, i); TreeItem childItem = new TreeItem(); String id = DOM.getElementAttribute(li, "id"); if (id != null && !id.equals("")) { childItem.setId(id);//from w w w .j ava 2s . c om } childItem.setText(DOM.getElementProperty(li, "title")); item.add(childItem); for (int j = 0; j < DOM.getChildCount(li); j++) { Element subList = DOM.getChild(li, j); process(childItem, subList); } } }
From source file:com.fullmetalgalaxy.client.AppRoot.java
License:Open Source License
/** * this method should return the default history token which contain the first MiniApp * which have to be displayed on module loading. * @return/*from w w w . j a v a 2 s .com*/ */ private HistoryState getDefaultHistoryState() { if (RootPanel.get("app_history") != null) { return new HistoryState(DOM.getElementAttribute(RootPanel.get("app_history").getElement(), "content")); } return new HistoryState(); }