use of com.google.gwt.core.client.Callback in project gwt-cs by iSergio.
the class ImageryLayersManipulation method buildPanel.
@Override
public void buildPanel() {
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.baseLayerPicker = false;
ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
imageryLayers = csVPanel.getViewer().imageryLayers();
setupLayers();
updateLayerList();
_callback.onSuccess(null);
HorizontalPanel baseLayersHPanel = new HorizontalPanel();
baseLayersHPanel.setSpacing(5);
baseLayersHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
baseLayersHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
final ListBox baseLayersLBox = new ListBox();
baseLayersHPanel.add(baseLayersLBox);
Slider baseLayersSlider = new Slider("baseLayersAlpha", 0, 100, 100);
baseLayersSlider.setWidth("200px");
baseLayersSlider.addListener(new MSliderListener());
baseLayersHPanel.add(baseLayersSlider);
baseLayersLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
ImageryLayer baseLayer = baseLayers.get(source.getSelectedValue());
int activeLayerIndex = 0;
int numLayers = layers.size();
for (int i = 0; i < numLayers; ++i) {
if (baseLayers.containsValue(layers.get(i))) {
activeLayerIndex = i;
}
}
ImageryLayer activeLayer = layers.get(activeLayerIndex);
float alpha = activeLayer.alpha;
boolean show = activeLayer.show;
imageryLayers.remove(activeLayer, false);
imageryLayers.add(baseLayer, numLayers - activeLayerIndex - 1);
baseLayer.show = show;
baseLayer.alpha = alpha;
updateLayerList();
selectedLayer = baseLayer;
}
});
Callback<Void, Void> cesiumCreated = new Callback<Void, Void>() {
@Override
public void onFailure(Void aVoid) {
//
}
@Override
public void onSuccess(Void aVoid) {
for (Map.Entry<String, ImageryLayer> entry : baseLayers.entrySet()) {
baseLayersLBox.addItem(entry.getKey(), entry.getKey());
}
}
};
addCallback(cesiumCreated);
contentPanel.add(new HTML("<p>Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently.</p>"));
contentPanel.add(baseLayersHPanel);
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of com.google.gwt.core.client.Callback in project che by eclipse.
the class OpenFileAction method promise.
@Override
public Promise<Void> promise(final ActionEvent actionEvent) {
if (actionEvent.getParameters() == null) {
return Promises.reject(JsPromiseError.create(localization.canNotOpenFileWithoutParams()));
}
final String pathToOpen = actionEvent.getParameters().get(FILE_PARAM_ID);
if (pathToOpen == null) {
return Promises.reject(JsPromiseError.create(localization.fileToOpenIsNotSpecified()));
}
final Call<Void, Throwable> call = new Call<Void, Throwable>() {
HandlerRegistration handlerRegistration;
@Override
public void makeCall(final Callback<Void, Throwable> callback) {
actionCompletedCallback = callback;
handlerRegistration = eventBus.addHandler(ActivePartChangedEvent.TYPE, new ActivePartChangedHandler() {
@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
if (event.getActivePart() instanceof EditorPartPresenter) {
EditorPartPresenter editor = (EditorPartPresenter) event.getActivePart();
handlerRegistration.removeHandler();
if (Path.valueOf(pathToOpen).equals(editor.getEditorInput().getFile().getLocation())) {
callback.onSuccess(null);
}
}
}
});
actionPerformed(actionEvent);
}
};
return createFromCallback(call);
}
use of com.google.gwt.core.client.Callback in project che by eclipse.
the class AppContextImpl method initResourceManager.
@Override
public void initResourceManager(final Callback<ResourceManager, Exception> callback) {
if (runtime.getDevMachine() == null) {
//should never happened, but anyway
callback.onFailure(new NullPointerException("Dev machine is not initialized"));
}
if (projects != null) {
for (Project project : projects) {
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
}
projects = null;
}
resourceManager = resourceManagerFactory.newResourceManager(runtime.getDevMachine());
resourceManager.getWorkspaceProjects().then(projects -> {
AppContextImpl.this.projects = projects;
java.util.Arrays.sort(AppContextImpl.this.projects, ResourcePathComparator.getInstance());
callback.onSuccess(resourceManager);
eventBus.fireEvent(new WorkspaceReadyEvent(projects));
}).catchError(error -> {
callback.onFailure((Exception) error.getCause());
});
}
use of com.google.gwt.core.client.Callback in project kie-wb-common by kiegroup.
the class NewResourcesMenuTest method testOnWorkspaceProjectContextChangedDisabled.
@Test
@SuppressWarnings("unchecked")
public void testOnWorkspaceProjectContextChangedDisabled() {
doAnswer(new Answer() {
@Override
public Object answer(final InvocationOnMock invocation) {
final Object[] args = invocation.getArguments();
final Callback callback = (Callback) args[0];
callback.onSuccess(false);
return null;
}
}).when(handler).acceptContext(any(Callback.class));
// Arguments aren't actually used
menu.onChange(null, null);
verify(handler, times(1)).acceptContext(any(Callback.class));
final List<MenuItem> menus = menu.getMenuItems();
verify(handler, times(2)).acceptContext(any(Callback.class));
final MenuItem mi = menus.get(0);
assertFalse(mi.isEnabled());
}
use of com.google.gwt.core.client.Callback in project kie-wb-common by kiegroup.
the class NewResourcesMenuTest method testOnWorkspaceProjectContextChangedEnabled.
@Test
@SuppressWarnings("unchecked")
public void testOnWorkspaceProjectContextChangedEnabled() {
doAnswer(new Answer() {
@Override
public Object answer(final InvocationOnMock invocation) {
final Object[] args = invocation.getArguments();
final Callback callback = (Callback) args[0];
callback.onSuccess(true);
return null;
}
}).when(handler).acceptContext(any(Callback.class));
// Arguments aren't actually used
menu.onChange(null, null);
verify(handler, times(1)).acceptContext(any(Callback.class));
final List<MenuItem> menus = menu.getMenuItems();
verify(handler, times(2)).acceptContext(any(Callback.class));
final MenuItem mi = menus.get(0);
assertTrue(mi.isEnabled());
}
Aggregations