Fixed strange rotated image behaviour
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/image-previewer-widget@130991 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b25cac6a72
commit
4019447587
|
@ -21,7 +21,7 @@ public class ImagePreviewer implements EntryPoint {
|
|||
public void onModuleLoad() {
|
||||
|
||||
// decomment for testing purpose
|
||||
//test();
|
||||
// test();
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class ImagePreviewer implements EntryPoint {
|
|||
});
|
||||
b.setText("Show preview");
|
||||
|
||||
c.show();
|
||||
b.click();
|
||||
|
||||
RootPanel.get("image-previewer-div").add(b);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.google.gwt.event.dom.client.LoadHandler;
|
|||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
|
@ -225,7 +226,8 @@ public class Carousel extends Composite{
|
|||
|
||||
// evaluate prev index
|
||||
currentPreviewPosition =
|
||||
currentPreviewPosition == 0 ? listOfAttachmentsToShow.size() - 1 : currentPreviewPosition - 1;
|
||||
currentPreviewPosition == 0 ?
|
||||
listOfAttachmentsToShow.size() - 1 : currentPreviewPosition - 1;
|
||||
|
||||
// show the image
|
||||
showImage(currentPreviewPosition);
|
||||
|
@ -299,7 +301,6 @@ public class Carousel extends Composite{
|
|||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,9 +329,7 @@ public class Carousel extends Composite{
|
|||
*/
|
||||
private void showImage(int index){
|
||||
|
||||
// show loading image and hide the shown one
|
||||
loadingImage.setVisible(true);
|
||||
shownImage.setVisible(false);
|
||||
showLoader();
|
||||
|
||||
final EnhancedImage imageToShow = listOfAttachmentsToShow.get(index);
|
||||
final String url = imageToShow.getImageUrl();
|
||||
|
@ -348,20 +347,19 @@ public class Carousel extends Composite{
|
|||
|
||||
@Override
|
||||
public void onSuccess(Orientation result) {
|
||||
imageToShow.setOrientation(result);
|
||||
setOrientation(imageToShow, result);
|
||||
removeLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
imageToShow.setOrientation(Orientation.DO_NOT_ROTATE);
|
||||
setOrientation(imageToShow, Orientation.DO_NOT_ROTATE);
|
||||
removeLoader();
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
setOrientation(imageToShow, imageToShow.getOrientation());
|
||||
removeLoader();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -373,8 +371,8 @@ public class Carousel extends Composite{
|
|||
shownImage.setTitle(imageToShow.getToolTipToShow());
|
||||
|
||||
// change the title to the modal
|
||||
String shownTitle = imageToShow.getTitleToShow().length() > 50 ?
|
||||
imageToShow.getTitleToShow().substring(0, 50) + "..." :
|
||||
String shownTitle = imageToShow.getTitleToShow().length() > 80 ?
|
||||
imageToShow.getTitleToShow().substring(0, 80) + "..." :
|
||||
imageToShow.getTitleToShow();
|
||||
mainModalPanel.setTitle(shownTitle);
|
||||
|
||||
|
@ -386,6 +384,14 @@ public class Carousel extends Composite{
|
|||
((Element)mainModalPanel.getElement().getChildNodes().getItem(0)).addClassName("modal-header-custom");
|
||||
}
|
||||
|
||||
/**
|
||||
* Show image loader
|
||||
*/
|
||||
protected void showLoader() {
|
||||
loadingImage.setVisible(true);
|
||||
shownImage.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove image loader
|
||||
|
@ -402,11 +408,6 @@ public class Carousel extends Composite{
|
|||
*/
|
||||
private void setOrientation(EnhancedImage img, Orientation o){
|
||||
|
||||
GWT.log("Rotation is " + o);
|
||||
|
||||
// set to the img
|
||||
img.setOrientation(o);
|
||||
|
||||
// remove all the possible secondary styles..
|
||||
shownImage.removeStyleName("rotate-0");
|
||||
shownImage.removeStyleName("rotate-90");
|
||||
|
@ -427,6 +428,16 @@ public class Carousel extends Composite{
|
|||
default: shownImage.addStyleName("rotate-0");
|
||||
}
|
||||
|
||||
// few ms are needed to remove/add the style, after that we remove the loading image
|
||||
Timer t = new Timer() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
removeLoader();
|
||||
}
|
||||
};
|
||||
|
||||
t.schedule(500);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ImageOrientationServicesImpl extends RemoteServiceServlet implement
|
|||
logger.debug("Orientation is " + orientation);
|
||||
return mapIntToOrientation(orientation);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Could not get orientation", e);
|
||||
logger.warn("Could not get orientation");
|
||||
}
|
||||
|
||||
// as default
|
||||
|
|
Loading…
Reference in New Issue