Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New demo #133

Merged
merged 11 commits into from
Dec 6, 2024
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<drivers.dir>${project.basedir}/drivers</drivers.dir>
<flowingcode.commons.demo.version>4.0.0</flowingcode.commons.demo.version>
<jetty.version>11.0.14</jetty.version>
</properties>
<organization>
Expand Down Expand Up @@ -54,6 +55,11 @@
<scope>import</scope>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.flowingcode.vaadin.addons.demo</groupId>
<artifactId>commons-demo</artifactId>
<version>${flowingcode.commons.demo.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -105,6 +111,11 @@
<version>6.1.14</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.flowingcode.vaadin.addons.demo</groupId>
<artifactId>commons-demo</artifactId>
<scope>test</scope>
</dependency>
Comment on lines +114 to +118
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Warning: Multiple commons-demo dependencies found with different scopes

The verification revealed that there are two declarations of the commons-demo dependency in pom.xml:

  • One without a test scope
  • Another with test scope

This could lead to potential conflicts or unintended usage in production code. The dependency should be declared only once with a consistent scope.

🔗 Analysis chain

LGTM: Test scope is appropriate

The commons-demo dependency is correctly scoped as 'test' in the dependencies section.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the commons-demo dependency usage is confined to test files

# Search for commons-demo imports outside test directories
rg -l "import.*commons.demo" --type java | grep -v "/test/"

Length of output: 59


Script:

#!/bin/bash
# Let's try a more comprehensive search approach

# 1. First, let's check all Java files that might use commons-demo
rg -l "commons.demo" --type java

# 2. Let's also check the pom.xml for any other commons-demo references
rg "commons.demo" pom.xml -A 2 -B 2

Length of output: 828

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@
import org.junit.Ignore;

@SuppressWarnings("serial")
@Route(value = "applayout", layout = DemoLayout.class)
@Route(value = "applayout-full", layout = DemoLayout.class)
@StyleSheet("context://frontend/styles/app-layout/demo-styles.css")
@Ignore
public class ApplayoutDemoView extends VerticalLayout {

private VerticalLayout container = new VerticalLayout();
Expand Down Expand Up @@ -232,7 +231,7 @@ private Component[] createMenuItems() {
new MenuItem("Toggle", VaadinIcon.BACKSPACE).configure(mi -> mi.add(new PaperToggle())),
new MenuItem("Toggle", MenuItem.BLANK).configure(mi -> mi.add(new PaperToggle())),
new MenuItem("External link").setHref("http://www.google.com"),
new MenuItem("Internal Link", InternalView.class),
new MenuItem("Internal Link", SampleInternalView.class),

// icon as VaadinIcon enum
new MenuItem("Content", VaadinIcon.BOOK, () -> showHamletContent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.html.Span;

public class AbstractLayoutDemo extends AppLayout {
@SuppressWarnings("serial")
public class CustomAppLayout extends AppLayout {

public AbstractLayoutDemo() {
public CustomAppLayout() {
setMenuItems(new MenuItem("Item 1"), new MenuItem("Item 2"));

// menu header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
import com.vaadin.flow.router.Route;
import org.junit.Ignore;

@SuppressWarnings("serial")
@Route("internal-view")
@Ignore
public class InternalView extends Div {
public class SampleInternalView extends Div {

public InternalView() {
public SampleInternalView() {
add(new Span("Internal view"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import com.vaadin.flow.router.Route;
import org.junit.Ignore;

@Route(value = "view", layout = AbstractLayoutDemo.class)
@Ignore
public class AbstractLayoutView extends Div {
@SuppressWarnings("serial")
@Route(value = "view", layout = CustomAppLayout.class)
public class SampleView extends Div {

{
add(new Span("Hello world"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.flowingcode.vaadin.addons.applayout;

import com.flowingcode.vaadin.addons.demo.DemoSource;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.IFrame;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;

@DemoSource("/src/test/java/com/flowingcode/addons/applayout/ApplayoutDemoView.java")
@DemoSource("/frontend/styles/app-layout/demo-styles.css")
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Update DemoSource paths to match actual file locations

The DemoSource annotation paths need to be corrected to match the actual file locations in the codebase:

  • The demo view is located at /src/test/java/com/flowingcode/addons/applayout/ApplayoutDemoView.java
  • The CSS file is located at /src/test/resources/META-INF/resources/frontend/styles/app-layout/demo-styles.css
🔗 Analysis chain

Verify DemoSource paths

The DemoSource annotation path /src/test/java/com/flowingcode/addons/applayout/ doesn't match the actual package path com.flowingcode.vaadin.addons.applayout. This could cause the demo source to not be found correctly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence of the referenced files
fd -t f "ApplayoutDemoView.java" -x echo "Found demo view: {}"
fd -t f "demo-styles.css" -p "frontend/styles/app-layout" -x echo "Found CSS: {}"

Length of output: 345


Script:

#!/bin/bash
# Let's verify the actual content and location of the demo view file
cat ./src/test/java/com/flowingcode/addons/applayout/ApplayoutDemoView.java

# Let's search for any demo-styles.css file in the repository
fd -t f "demo-styles.css" -x echo "Found CSS: {}"

# Let's also check the package declaration in the demo view
grep -n "package" ./src/test/java/com/flowingcode/addons/applayout/ApplayoutDemoView.java

Length of output: 13091

@PageTitle("AppLayout Full Demo")
@SuppressWarnings("serial")
@Route(value = "applayout/applayout-demo", layout = AppLayoutDemoView.class)
public class AppLayoutDemo extends Div {

public AppLayoutDemo() {
setClassName("wrap-iframe");
IFrame iframe = new IFrame("/applayout-full");
iframe.setClassName("frame");
iframe.setSizeFull();
iframe.getElement().setAttribute("frameBorder", "0");
add(iframe);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*-
* #%L
* Template Add-on
* %%
* Copyright (C) 2023 Flowing Code
* %%
* 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.
* #L%
*/
package com.flowingcode.vaadin.addons.applayout;

import com.flowingcode.vaadin.addons.DemoLayout;
import com.flowingcode.vaadin.addons.GithubLink;
import com.flowingcode.vaadin.addons.demo.TabbedDemo;
import com.vaadin.flow.router.ParentLayout;
import com.vaadin.flow.router.Route;

@SuppressWarnings("serial")
@ParentLayout(DemoLayout.class)
@Route("applayout")
@GithubLink("https://github.com/FlowingCode/AppLayoutAddon")
public class AppLayoutDemoView extends TabbedDemo {

public AppLayoutDemoView() {
addDemo(AppLayoutDemo.class);
addDemo(ExtendingAppLayoutDemo.class);

setSizeFull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
* #L%
*/
package com.flowingcode.addons.applayout;
package com.flowingcode.vaadin.addons.applayout;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Package restructuring needs attention - multiple files still using old package

The verification reveals that multiple source files are still using the old package structure com.flowingcode.addons.applayout. This includes both main and test classes that need to be updated to maintain consistency with the new package structure.

Key files requiring package updates:

  • Main source files:
    • src/main/java/com/flowingcode/addons/applayout/AppLayout.java
    • src/main/java/com/flowingcode/addons/applayout/MenuItem.java
    • src/main/java/com/flowingcode/addons/applayout/ToolbarIconButton.java
    • And other core components in the same package
  • Test source files:
    • src/test/java/com/flowingcode/addons/applayout/ApplayoutDemoView.java
    • src/test/java/com/flowingcode/addons/applayout/integration/*
    • And related test classes
🔗 Analysis chain

Verify package restructuring impact

The package has been moved from com.flowingcode.addons.applayout to com.flowingcode.vaadin.addons.applayout. This change might affect other classes that depend on this package.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to the old package
rg "com\.flowingcode\.addons\.applayout" --type java

Length of output: 4073


import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.BeforeEnterEvent;
Expand All @@ -30,6 +30,6 @@ public class DemoView extends VerticalLayout implements BeforeEnterObserver {

@Override
public void beforeEnter(BeforeEnterEvent event) {
event.forwardTo(ApplayoutDemoView.class);
event.forwardTo(AppLayoutDemoView.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.flowingcode.vaadin.addons.applayout;

import com.flowingcode.vaadin.addons.demo.DemoSource;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.IFrame;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;

@DemoSource("/src/test/java/com/flowingcode/addons/applayout/CustomAppLayout.java")
@DemoSource("/src/test/java/com/flowingcode/addons/applayout/SampleView.java")
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix inconsistent package paths in @demosource annotations

The package paths in the @demosource annotations don't match the actual package structure. They should be updated to include "vaadin":

-@DemoSource("/src/test/java/com/flowingcode/addons/applayout/CustomAppLayout.java")
-@DemoSource("/src/test/java/com/flowingcode/addons/applayout/SampleView.java")
+@DemoSource("/src/test/java/com/flowingcode/vaadin/addons/applayout/CustomAppLayout.java")
+@DemoSource("/src/test/java/com/flowingcode/vaadin/addons/applayout/SampleView.java")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@DemoSource("/src/test/java/com/flowingcode/addons/applayout/CustomAppLayout.java")
@DemoSource("/src/test/java/com/flowingcode/addons/applayout/SampleView.java")
@DemoSource("/src/test/java/com/flowingcode/vaadin/addons/applayout/CustomAppLayout.java")
@DemoSource("/src/test/java/com/flowingcode/vaadin/addons/applayout/SampleView.java")

@PageTitle("Extending AppLayout Demo")
@SuppressWarnings("serial")
@Route(value = "applayout/extending-applayout-demo", layout = AppLayoutDemoView.class)
public class ExtendingAppLayoutDemo extends Div {

public ExtendingAppLayoutDemo() {
setClassName("wrap-iframe");
IFrame iframe = new IFrame("/view");
iframe.setClassName("frame");
iframe.setSizeFull();
iframe.getElement().setAttribute("frameBorder", "0");
add(iframe);
}
}
Loading