Skip to content

Commit

Permalink
AF-2700: Create Heatmap internal component
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuino committed Dec 3, 2020
1 parent 85ff91c commit c0c9185
Show file tree
Hide file tree
Showing 78 changed files with 5,624 additions and 1,051 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ public class ExternalComponentServlet extends HttpServlet {
ComponentLoader loader;

String cacheControlHeaderValue = "no-cache";
private MimetypesFileTypeMap mimetypesFileTypeMap;
private MimetypesFileTypeMap mimeTypes;

@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
mimetypesFileTypeMap = new MimetypesFileTypeMap();
mimeTypes = new MimetypesFileTypeMap();
String cacheControl = config.getInitParameter(CACHE_CONTROL_PARAM);
if (cacheControl != null) {
cacheControlHeaderValue = cacheControl;
}
addAdditionalMimeTypes();
}

@Override
Expand Down Expand Up @@ -95,7 +96,7 @@ private void handle(HttpServletRequest req, HttpServletResponse resp) throws IOE

try (InputStream assetStream = assetProvider.openAsset(assetPath)) {
int size = IOUtils.copy(assetStream, resp.getOutputStream());
String mimeType = mimetypesFileTypeMap.getContentType(pathInfo);
String mimeType = mimeTypes.getContentType(pathInfo);
resp.setContentType(mimeType);
resp.setContentLength(size);
resp.setHeader(CACHE_CONTROL_PARAM, cacheControlHeaderValue);
Expand All @@ -119,4 +120,9 @@ private void errorResponse(HttpServletResponse resp) {
}
}

private void addAdditionalMimeTypes() {
mimeTypes.addMimeTypes("text/javascript js");
mimeTypes.addMimeTypes("text/css css");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void testLoadInternalComponents() throws IOException {
externalComponentLoaderImpl.init();
List<ExternalComponent> internalComponents = externalComponentLoaderImpl.loadProvided();

assertEquals(1, internalComponents.size());
assertEquals(3, internalComponents.size());

ExternalComponent component = internalComponents.get(0);
assertEquals("logo-provided", component.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.enterprise.context.Dependent;
import javax.inject.Inject;

import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.Event;
import org.dashbuilder.client.cms.resources.i18n.ContentManagerConstants;
import org.gwtbootstrap3.client.ui.Modal;
Expand Down Expand Up @@ -187,6 +188,16 @@ public void okClick(final Event event) {
buttonPressed = ButtonPressed.OK;
presenter.onOK();
}

@SinkNative(Event.ONMOUSEDOWN)
@EventHandler("nameInput")
public void nameInputEnter(final Event event) {
if (event.getKeyCode() == KeyCodes.KEY_ENTER) {
buttonPressed = ButtonPressed.OK;
presenter.onOK();
}
}


@SinkNative(Event.ONCLICK)
@EventHandler("cancelButton")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ removeFilter=Remove filter
DisplayerErrorWidget.displayerErrorTitle=Unexpected Error
DisplayerErrorWidget.errorDetails=Details

ExternalComponentView.configurationIssueTitle=Modify DataSet Configuration
ExternalComponentView.configurationIssueDescription=Component does not support the current columns configuration.
ExternalComponentView.configurationIssueTitle=Modify Configuration
ExternalComponentView.configurationIssueDescription=Component does not support the current configuration.

loadingComponent=Loading Component
componentEditor=Component Editor
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2020 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.dashbuilder.client.editor.external;

import java.util.Collections;
import java.util.List;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import org.dashbuilder.client.editor.resources.i18n.Constants;
import org.dashbuilder.external.model.ExternalComponent;
import org.dashbuilder.external.service.ComponentService;
import org.jboss.errai.common.client.api.Caller;
import org.jboss.errai.ioc.client.container.SyncBeanManager;
import org.uberfire.ext.layout.editor.client.api.LayoutDragComponentGroup;
import org.uberfire.ext.layout.editor.client.api.LayoutDragComponentPalette;
import org.uberfire.ext.layout.editor.client.widgets.LayoutComponentPaletteGroupProvider;
import org.uberfire.ext.plugin.client.perspective.editor.events.PerspectiveEditorFocusEvent;

@ApplicationScoped
public class ComponentsGroupProducer {

private static final Constants i18n = Constants.INSTANCE;

private SyncBeanManager beanManager;
private LayoutDragComponentPalette layoutDragComponentPalette;
private Caller<ComponentService> componentService;

@Inject
public ComponentsGroupProducer(Caller<ComponentService> externalComponentService,
SyncBeanManager beanManager,
LayoutDragComponentPalette layoutDragComponentPalette) {
this.componentService = externalComponentService;
this.beanManager = beanManager;
this.layoutDragComponentPalette = layoutDragComponentPalette;
}

public void onEditorFocus(@Observes PerspectiveEditorFocusEvent event) {
loadComponents();
}

public void loadComponents() {

componentService.call((List<ExternalComponent> components) -> addExternalComponents(components))
.listExternalComponents();

componentService.call((List<ExternalComponent> components) -> addInternalComponents(components))
.listProvidedComponents();
}

public void addExternalComponents(List<ExternalComponent> components) {
String groupId = i18n.externalComponentsGroupName();
checkGroup(groupId);
components.forEach(comp -> {
layoutDragComponentPalette.addDraggableComponent(groupId,
comp.getId(),
produceDragComponent(comp));
});

}

public void addInternalComponents(List<ExternalComponent> components) {
components.stream().forEach(component -> {
String groupId = component.getCategory() != null ? component.getCategory() : i18n.internalComponentsGroupName();
checkGroup(groupId);
layoutDragComponentPalette.addDraggableComponent(groupId, component.getId(), produceDragComponent(component));
});

}

private void checkGroup(String groupId) {
if (!layoutDragComponentPalette.hasDraggableGroup(groupId)) {
layoutDragComponentPalette.addDraggableGroup(new LayoutComponentPaletteGroupProvider() {

@Override
public String getName() {
return groupId;
}

@Override
public LayoutDragComponentGroup getComponentGroup() {
return new LayoutDragComponentGroup(groupId);
}
});
}

}

ExternalComponentDragDef produceDragComponent(ExternalComponent comp) {
ExternalComponentDragDef dragComp;
if (comp.isNoData()) {
dragComp = beanManager.lookupBean(ExternalDragComponent.class).getInstance();
} else {
dragComp = beanManager.lookupBean(ExternalDisplayerDragComponent.class).getInstance();
}
dragComp.setDragInfo(comp.getName(), comp.getIcon());
dragComp.setComponentId(comp.getId());
return dragComp;
}

}

This file was deleted.

This file was deleted.

Loading

0 comments on commit c0c9185

Please sign in to comment.