repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
wildfly-extras/wildfly-camel-examples | camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/data/CustomerRepository.java | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
| import org.wildfly.camel.examples.rest.model.Customer;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction; | /*
* #%L
* Wildfly Camel :: Example :: Camel Rest Swagger
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.rest.data;
@ApplicationScoped
@Named
public class CustomerRepository {
@Inject
private EntityManager em;
@Inject
private UserTransaction userTransaction;
| // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/data/CustomerRepository.java
import org.wildfly.camel.examples.rest.model.Customer;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
/*
* #%L
* Wildfly Camel :: Example :: Camel Rest Swagger
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.rest.data;
@ApplicationScoped
@Named
public class CustomerRepository {
@Inject
private EntityManager em;
@Inject
private UserTransaction userTransaction;
| public List<Customer> findAll() { |
wildfly-extras/wildfly-camel-examples | camel-jms-tx/src/main/java/org/wildfly/camel/examples/jms/transacted/data/OrderRepository.java | // Path: camel-jms-tx/src/main/java/org/wildfly/camel/examples/jms/transacted/model/Order.java
// @XmlRootElement(name = "order")
// @XmlAccessorType(XmlAccessType.FIELD)
// @Entity
// @Table(name = "orders")
// public class Order implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private Long id;
// private String productName;
// private String productSku;
// private Integer quantity;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getProductName() {
// return productName;
// }
//
// public void setProductName(String productName) {
// this.productName = productName;
// }
//
// public String getProductSku() {
// return productSku;
// }
//
// public void setProductSku(String productSku) {
// this.productSku = productSku;
// }
//
// public Integer getQuantity() {
// return quantity;
// }
//
// public void setQuantity(Integer quantity) {
// this.quantity = quantity;
// }
// }
| import org.wildfly.camel.examples.jms.transacted.model.Order;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import java.util.List; | /*
* #%L
* Wildfly Camel :: Example :: Camel Transacted JMS
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.jms.transacted.data;
public class OrderRepository {
@Inject
private EntityManager entityManager;
/**
* Find all customer records
*
* @return A list of customers
*/ | // Path: camel-jms-tx/src/main/java/org/wildfly/camel/examples/jms/transacted/model/Order.java
// @XmlRootElement(name = "order")
// @XmlAccessorType(XmlAccessType.FIELD)
// @Entity
// @Table(name = "orders")
// public class Order implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private Long id;
// private String productName;
// private String productSku;
// private Integer quantity;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getProductName() {
// return productName;
// }
//
// public void setProductName(String productName) {
// this.productName = productName;
// }
//
// public String getProductSku() {
// return productSku;
// }
//
// public void setProductSku(String productSku) {
// this.productSku = productSku;
// }
//
// public Integer getQuantity() {
// return quantity;
// }
//
// public void setQuantity(Integer quantity) {
// this.quantity = quantity;
// }
// }
// Path: camel-jms-tx/src/main/java/org/wildfly/camel/examples/jms/transacted/data/OrderRepository.java
import org.wildfly.camel.examples.jms.transacted.model.Order;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import java.util.List;
/*
* #%L
* Wildfly Camel :: Example :: Camel Transacted JMS
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.jms.transacted.data;
public class OrderRepository {
@Inject
private EntityManager entityManager;
/**
* Find all customer records
*
* @return A list of customers
*/ | public List<Order> findAllOrders() { |
wildfly-extras/wildfly-camel-examples | camel-jpa/src/main/java/org/wildfly/camel/examples/jpa/JPARouteBuilder.java | // Path: camel-jpa-spring/src/main/java/org/wildfly/camel/examples/jpa/model/Order.java
// @Entity(name = "orders")
// @NamedQuery(name = "pendingOrders", query = "SELECT o FROM orders o WHERE o.status = 'PENDING'")
// public class Order {
//
// @Id
// @GeneratedValue
// private int id;
// private String item;
// private int amount;
// private String description;
// private String status = "PENDING";
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getItem() {
// return item;
// }
//
// public void setItem(String item) {
// this.item = item;
// }
//
// public int getAmount() {
// return amount;
// }
//
// public void setAmount(int amount) {
// this.amount = amount;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// }
| import org.wildfly.camel.examples.jpa.model.Order;
import javax.enterprise.context.ApplicationScoped;
import org.apache.camel.builder.RouteBuilder; | /*
* #%L
* Wildfly Camel :: Example :: Camel JPA
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.jpa;
@ApplicationScoped
public class JPARouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
// Route to generate orders and persist them to the database
from("timer:new-order?delay=0s&period=10s")
.bean("orderService", "generateOrder") | // Path: camel-jpa-spring/src/main/java/org/wildfly/camel/examples/jpa/model/Order.java
// @Entity(name = "orders")
// @NamedQuery(name = "pendingOrders", query = "SELECT o FROM orders o WHERE o.status = 'PENDING'")
// public class Order {
//
// @Id
// @GeneratedValue
// private int id;
// private String item;
// private int amount;
// private String description;
// private String status = "PENDING";
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getItem() {
// return item;
// }
//
// public void setItem(String item) {
// this.item = item;
// }
//
// public int getAmount() {
// return amount;
// }
//
// public void setAmount(int amount) {
// this.amount = amount;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// }
// Path: camel-jpa/src/main/java/org/wildfly/camel/examples/jpa/JPARouteBuilder.java
import org.wildfly.camel.examples.jpa.model.Order;
import javax.enterprise.context.ApplicationScoped;
import org.apache.camel.builder.RouteBuilder;
/*
* #%L
* Wildfly Camel :: Example :: Camel JPA
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.jpa;
@ApplicationScoped
public class JPARouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
// Route to generate orders and persist them to the database
from("timer:new-order?delay=0s&period=10s")
.bean("orderService", "generateOrder") | .toF("jpa:%s", Order.class.getName()) |
wildfly-extras/wildfly-camel-examples | itests/src/main/java/org/wildfly/camel/examples/test/jms/TransactedJMSExampleTest.java | // Path: itests/src/main/java/org/wildfly/camel/examples/test/common/FileCopyTestSupport.java
// public abstract class FileCopyTestSupport {
//
// @Before
// public void setUp() throws Exception {
// String packageName = getClass().getPackage().getName();
// String fileLocation = packageName.replace("org.wildfly.camel.examples.test.", "").replace(".", "/");
// String sourceFileName = sourceFilename();
// InputStream input = getClass().getResourceAsStream("/" + fileLocation + "/" + sourceFileName);
// Files.copy(input, destinationPath().resolve(sourceFileName));
// input.close();
//
// boolean await = awaitFileProcessed();
// Assert.assertTrue("Gave up waiting for file to be processed", await);
// }
//
// @After
// public void tearDown () throws IOException {
// Files.walkFileTree(destinationPath(), new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult visitFileFailed(Path file, IOException exception) throws IOException {
// exception.printStackTrace();
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exception) throws IOException {
// if (exception == null) {
// Files.delete(dir);
// }
// return FileVisitResult.CONTINUE;
// }
// });
// }
//
// private boolean awaitFileProcessed() throws Exception {
// long start = System.currentTimeMillis();
// long timeout = 15000;
// do {
// File file = processedPath().toFile();
// if (file.exists()) {
// if ((file.isDirectory() && file.list().length > 0) || (file.isFile())) {
// return true;
// }
// }
// try {
// Thread.sleep(100L);
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// return false;
// }
// } while (!((System.currentTimeMillis() - start) >= timeout));
// return false;
// }
//
// protected abstract String sourceFilename();
// protected abstract Path destinationPath();
// protected abstract Path processedPath();
// }
| import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.camel.examples.test.common.FileCopyTestSupport;
import org.wildfly.camel.test.common.http.HttpRequest;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert; | /*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.test.jms;
@RunAsClient
@RunWith(Arquillian.class)
@ServerSetup({ AbstractJMSExampleTest.JmsQueueSetup.class }) | // Path: itests/src/main/java/org/wildfly/camel/examples/test/common/FileCopyTestSupport.java
// public abstract class FileCopyTestSupport {
//
// @Before
// public void setUp() throws Exception {
// String packageName = getClass().getPackage().getName();
// String fileLocation = packageName.replace("org.wildfly.camel.examples.test.", "").replace(".", "/");
// String sourceFileName = sourceFilename();
// InputStream input = getClass().getResourceAsStream("/" + fileLocation + "/" + sourceFileName);
// Files.copy(input, destinationPath().resolve(sourceFileName));
// input.close();
//
// boolean await = awaitFileProcessed();
// Assert.assertTrue("Gave up waiting for file to be processed", await);
// }
//
// @After
// public void tearDown () throws IOException {
// Files.walkFileTree(destinationPath(), new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult visitFileFailed(Path file, IOException exception) throws IOException {
// exception.printStackTrace();
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exception) throws IOException {
// if (exception == null) {
// Files.delete(dir);
// }
// return FileVisitResult.CONTINUE;
// }
// });
// }
//
// private boolean awaitFileProcessed() throws Exception {
// long start = System.currentTimeMillis();
// long timeout = 15000;
// do {
// File file = processedPath().toFile();
// if (file.exists()) {
// if ((file.isDirectory() && file.list().length > 0) || (file.isFile())) {
// return true;
// }
// }
// try {
// Thread.sleep(100L);
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// return false;
// }
// } while (!((System.currentTimeMillis() - start) >= timeout));
// return false;
// }
//
// protected abstract String sourceFilename();
// protected abstract Path destinationPath();
// protected abstract Path processedPath();
// }
// Path: itests/src/main/java/org/wildfly/camel/examples/test/jms/TransactedJMSExampleTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.camel.examples.test.common.FileCopyTestSupport;
import org.wildfly.camel.test.common.http.HttpRequest;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
/*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.test.jms;
@RunAsClient
@RunWith(Arquillian.class)
@ServerSetup({ AbstractJMSExampleTest.JmsQueueSetup.class }) | public class TransactedJMSExampleTest extends FileCopyTestSupport { |
wildfly-extras/wildfly-camel-examples | itests/src/main/java/org/wildfly/camel/examples/test/jms/TransactedJMSSpringExampleTest.java | // Path: itests/src/main/java/org/wildfly/camel/examples/test/common/FileCopyTestSupport.java
// public abstract class FileCopyTestSupport {
//
// @Before
// public void setUp() throws Exception {
// String packageName = getClass().getPackage().getName();
// String fileLocation = packageName.replace("org.wildfly.camel.examples.test.", "").replace(".", "/");
// String sourceFileName = sourceFilename();
// InputStream input = getClass().getResourceAsStream("/" + fileLocation + "/" + sourceFileName);
// Files.copy(input, destinationPath().resolve(sourceFileName));
// input.close();
//
// boolean await = awaitFileProcessed();
// Assert.assertTrue("Gave up waiting for file to be processed", await);
// }
//
// @After
// public void tearDown () throws IOException {
// Files.walkFileTree(destinationPath(), new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult visitFileFailed(Path file, IOException exception) throws IOException {
// exception.printStackTrace();
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exception) throws IOException {
// if (exception == null) {
// Files.delete(dir);
// }
// return FileVisitResult.CONTINUE;
// }
// });
// }
//
// private boolean awaitFileProcessed() throws Exception {
// long start = System.currentTimeMillis();
// long timeout = 15000;
// do {
// File file = processedPath().toFile();
// if (file.exists()) {
// if ((file.isDirectory() && file.list().length > 0) || (file.isFile())) {
// return true;
// }
// }
// try {
// Thread.sleep(100L);
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// return false;
// }
// } while (!((System.currentTimeMillis() - start) >= timeout));
// return false;
// }
//
// protected abstract String sourceFilename();
// protected abstract Path destinationPath();
// protected abstract Path processedPath();
// }
| import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.camel.examples.test.common.FileCopyTestSupport;
import org.wildfly.camel.test.common.http.HttpRequest;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert; | /*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.test.jms;
@RunAsClient
@RunWith(Arquillian.class)
@ServerSetup({ AbstractJMSExampleTest.JmsQueueSetup.class }) | // Path: itests/src/main/java/org/wildfly/camel/examples/test/common/FileCopyTestSupport.java
// public abstract class FileCopyTestSupport {
//
// @Before
// public void setUp() throws Exception {
// String packageName = getClass().getPackage().getName();
// String fileLocation = packageName.replace("org.wildfly.camel.examples.test.", "").replace(".", "/");
// String sourceFileName = sourceFilename();
// InputStream input = getClass().getResourceAsStream("/" + fileLocation + "/" + sourceFileName);
// Files.copy(input, destinationPath().resolve(sourceFileName));
// input.close();
//
// boolean await = awaitFileProcessed();
// Assert.assertTrue("Gave up waiting for file to be processed", await);
// }
//
// @After
// public void tearDown () throws IOException {
// Files.walkFileTree(destinationPath(), new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult visitFileFailed(Path file, IOException exception) throws IOException {
// exception.printStackTrace();
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exception) throws IOException {
// if (exception == null) {
// Files.delete(dir);
// }
// return FileVisitResult.CONTINUE;
// }
// });
// }
//
// private boolean awaitFileProcessed() throws Exception {
// long start = System.currentTimeMillis();
// long timeout = 15000;
// do {
// File file = processedPath().toFile();
// if (file.exists()) {
// if ((file.isDirectory() && file.list().length > 0) || (file.isFile())) {
// return true;
// }
// }
// try {
// Thread.sleep(100L);
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// return false;
// }
// } while (!((System.currentTimeMillis() - start) >= timeout));
// return false;
// }
//
// protected abstract String sourceFilename();
// protected abstract Path destinationPath();
// protected abstract Path processedPath();
// }
// Path: itests/src/main/java/org/wildfly/camel/examples/test/jms/TransactedJMSSpringExampleTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.camel.examples.test.common.FileCopyTestSupport;
import org.wildfly.camel.test.common.http.HttpRequest;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
/*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.test.jms;
@RunAsClient
@RunWith(Arquillian.class)
@ServerSetup({ AbstractJMSExampleTest.JmsQueueSetup.class }) | public class TransactedJMSSpringExampleTest extends FileCopyTestSupport { |
wildfly-extras/wildfly-camel-examples | camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/RestRouteBuilder.java | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
//
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java
// @ApplicationScoped
// @Named
// public class CustomerService {
//
// @Inject
// CustomerRepository customerRepository;
//
// public void findAll(Exchange exchange) {
// List<Customer> customers = customerRepository.findAll();
// exchange.getOut().setBody(customers);
// }
//
// public void findById(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// exchange.getOut().setBody(customer);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
//
// public void create(Exchange exchange) {
// Customer customer = customerRepository.save(exchange.getIn().getBody(Customer.class));
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 201);
//
// String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
// exchange.getOut().setHeader("Location", URL + "/" + customer.getId());
//
// exchange.getOut().setBody(customer);
// }
//
// public void update(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// Customer updatedCustomer = customerRepository.save(exchange.getIn().getBody(Customer.class));
//
// String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
// exchange.getOut().setHeader("Location", URL + "/" + updatedCustomer.getId());
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
// exchange.getOut().setBody(updatedCustomer);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
//
// public void delete(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// customerRepository.delete(customer);
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
// }
| import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.MediaType;
import com.fasterxml.jackson.core.JsonParseException;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestParamType;
import org.wildfly.camel.examples.rest.model.Customer;
import org.wildfly.camel.examples.rest.service.CustomerService; | /*
* #%L
* Wildfly Camel :: Example :: Camel Rest Swagger
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.rest;
@ApplicationScoped
public class RestRouteBuilder extends RouteBuilder {
public void configure() throws Exception {
/**
* Configure an error handler to trap instances where the data posted to
* the REST API is invalid
*/
onException(JsonParseException.class)
.handled(true)
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400))
.setHeader(Exchange.CONTENT_TYPE, constant(MediaType.TEXT_PLAIN))
.setBody().constant("Invalid json data");
/**
* Configure Camel REST to use the camel-undertow component
*/
restConfiguration()
.bindingMode(RestBindingMode.json)
.component("undertow")
.contextPath("rest/api")
.host("localhost")
.port(8080)
.enableCORS(true)
.apiProperty("api.title", "WildFly Camel REST API")
.apiProperty("api.version", "1.0")
.apiContextPath("swagger");
/**
* Configure REST API with a base path of /customers
*/
rest("/customers").description("Customers REST service")
.get()
.description("Retrieves all customers")
.produces(MediaType.APPLICATION_JSON)
.route() | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
//
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java
// @ApplicationScoped
// @Named
// public class CustomerService {
//
// @Inject
// CustomerRepository customerRepository;
//
// public void findAll(Exchange exchange) {
// List<Customer> customers = customerRepository.findAll();
// exchange.getOut().setBody(customers);
// }
//
// public void findById(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// exchange.getOut().setBody(customer);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
//
// public void create(Exchange exchange) {
// Customer customer = customerRepository.save(exchange.getIn().getBody(Customer.class));
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 201);
//
// String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
// exchange.getOut().setHeader("Location", URL + "/" + customer.getId());
//
// exchange.getOut().setBody(customer);
// }
//
// public void update(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// Customer updatedCustomer = customerRepository.save(exchange.getIn().getBody(Customer.class));
//
// String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
// exchange.getOut().setHeader("Location", URL + "/" + updatedCustomer.getId());
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
// exchange.getOut().setBody(updatedCustomer);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
//
// public void delete(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// customerRepository.delete(customer);
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
// }
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/RestRouteBuilder.java
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.MediaType;
import com.fasterxml.jackson.core.JsonParseException;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestParamType;
import org.wildfly.camel.examples.rest.model.Customer;
import org.wildfly.camel.examples.rest.service.CustomerService;
/*
* #%L
* Wildfly Camel :: Example :: Camel Rest Swagger
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.rest;
@ApplicationScoped
public class RestRouteBuilder extends RouteBuilder {
public void configure() throws Exception {
/**
* Configure an error handler to trap instances where the data posted to
* the REST API is invalid
*/
onException(JsonParseException.class)
.handled(true)
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400))
.setHeader(Exchange.CONTENT_TYPE, constant(MediaType.TEXT_PLAIN))
.setBody().constant("Invalid json data");
/**
* Configure Camel REST to use the camel-undertow component
*/
restConfiguration()
.bindingMode(RestBindingMode.json)
.component("undertow")
.contextPath("rest/api")
.host("localhost")
.port(8080)
.enableCORS(true)
.apiProperty("api.title", "WildFly Camel REST API")
.apiProperty("api.version", "1.0")
.apiContextPath("swagger");
/**
* Configure REST API with a base path of /customers
*/
rest("/customers").description("Customers REST service")
.get()
.description("Retrieves all customers")
.produces(MediaType.APPLICATION_JSON)
.route() | .bean(CustomerService.class, "findAll") |
wildfly-extras/wildfly-camel-examples | camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/RestRouteBuilder.java | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
//
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java
// @ApplicationScoped
// @Named
// public class CustomerService {
//
// @Inject
// CustomerRepository customerRepository;
//
// public void findAll(Exchange exchange) {
// List<Customer> customers = customerRepository.findAll();
// exchange.getOut().setBody(customers);
// }
//
// public void findById(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// exchange.getOut().setBody(customer);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
//
// public void create(Exchange exchange) {
// Customer customer = customerRepository.save(exchange.getIn().getBody(Customer.class));
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 201);
//
// String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
// exchange.getOut().setHeader("Location", URL + "/" + customer.getId());
//
// exchange.getOut().setBody(customer);
// }
//
// public void update(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// Customer updatedCustomer = customerRepository.save(exchange.getIn().getBody(Customer.class));
//
// String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
// exchange.getOut().setHeader("Location", URL + "/" + updatedCustomer.getId());
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
// exchange.getOut().setBody(updatedCustomer);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
//
// public void delete(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// customerRepository.delete(customer);
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
// }
| import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.MediaType;
import com.fasterxml.jackson.core.JsonParseException;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestParamType;
import org.wildfly.camel.examples.rest.model.Customer;
import org.wildfly.camel.examples.rest.service.CustomerService; | .apiContextPath("swagger");
/**
* Configure REST API with a base path of /customers
*/
rest("/customers").description("Customers REST service")
.get()
.description("Retrieves all customers")
.produces(MediaType.APPLICATION_JSON)
.route()
.bean(CustomerService.class, "findAll")
.endRest()
.get("/{id}")
.description("Retrieves a customer for the specified id")
.param()
.name("id")
.description("Customer ID")
.type(RestParamType.path)
.dataType("int")
.endParam()
.produces(MediaType.APPLICATION_JSON)
.route()
.bean(CustomerService.class, "findById")
.endRest()
.post()
.description("Creates a new customer")
.consumes(MediaType.APPLICATION_JSON)
.produces(MediaType.APPLICATION_JSON) | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
//
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java
// @ApplicationScoped
// @Named
// public class CustomerService {
//
// @Inject
// CustomerRepository customerRepository;
//
// public void findAll(Exchange exchange) {
// List<Customer> customers = customerRepository.findAll();
// exchange.getOut().setBody(customers);
// }
//
// public void findById(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// exchange.getOut().setBody(customer);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
//
// public void create(Exchange exchange) {
// Customer customer = customerRepository.save(exchange.getIn().getBody(Customer.class));
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 201);
//
// String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
// exchange.getOut().setHeader("Location", URL + "/" + customer.getId());
//
// exchange.getOut().setBody(customer);
// }
//
// public void update(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// Customer updatedCustomer = customerRepository.save(exchange.getIn().getBody(Customer.class));
//
// String URL = exchange.getIn().getHeader(Exchange.HTTP_URL, String.class);
// exchange.getOut().setHeader("Location", URL + "/" + updatedCustomer.getId());
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
// exchange.getOut().setBody(updatedCustomer);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
//
// public void delete(Exchange exchange) {
// Long id = exchange.getIn().getHeader("id", Long.class);
// Customer customer = customerRepository.findById(id);
//
// if (customer != null) {
// customerRepository.delete(customer);
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 204);
// } else {
// exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
// }
// }
// }
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/RestRouteBuilder.java
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.MediaType;
import com.fasterxml.jackson.core.JsonParseException;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestParamType;
import org.wildfly.camel.examples.rest.model.Customer;
import org.wildfly.camel.examples.rest.service.CustomerService;
.apiContextPath("swagger");
/**
* Configure REST API with a base path of /customers
*/
rest("/customers").description("Customers REST service")
.get()
.description("Retrieves all customers")
.produces(MediaType.APPLICATION_JSON)
.route()
.bean(CustomerService.class, "findAll")
.endRest()
.get("/{id}")
.description("Retrieves a customer for the specified id")
.param()
.name("id")
.description("Customer ID")
.type(RestParamType.path)
.dataType("int")
.endParam()
.produces(MediaType.APPLICATION_JSON)
.route()
.bean(CustomerService.class, "findById")
.endRest()
.post()
.description("Creates a new customer")
.consumes(MediaType.APPLICATION_JSON)
.produces(MediaType.APPLICATION_JSON) | .type(Customer.class) |
wildfly-extras/wildfly-camel-examples | camel-jpa/src/main/java/org/wildfly/camel/examples/jpa/processor/JpaResultProcessor.java | // Path: camel-jpa-spring/src/main/java/org/wildfly/camel/examples/jpa/model/Order.java
// @Entity(name = "orders")
// @NamedQuery(name = "pendingOrders", query = "SELECT o FROM orders o WHERE o.status = 'PENDING'")
// public class Order {
//
// @Id
// @GeneratedValue
// private int id;
// private String item;
// private int amount;
// private String description;
// private String status = "PENDING";
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getItem() {
// return item;
// }
//
// public void setItem(String item) {
// this.item = item;
// }
//
// public int getAmount() {
// return amount;
// }
//
// public void setAmount(int amount) {
// this.amount = amount;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// }
| import java.util.List;
import javax.inject.Named;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.wildfly.camel.examples.jpa.model.Order; | /*
* #%L
* Wildfly Camel :: Example :: Camel JPA
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.jpa.processor;
@Named
public class JpaResultProcessor implements Processor {
@SuppressWarnings("unchecked")
@Override
public void process(Exchange exchange) throws Exception { | // Path: camel-jpa-spring/src/main/java/org/wildfly/camel/examples/jpa/model/Order.java
// @Entity(name = "orders")
// @NamedQuery(name = "pendingOrders", query = "SELECT o FROM orders o WHERE o.status = 'PENDING'")
// public class Order {
//
// @Id
// @GeneratedValue
// private int id;
// private String item;
// private int amount;
// private String description;
// private String status = "PENDING";
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getItem() {
// return item;
// }
//
// public void setItem(String item) {
// this.item = item;
// }
//
// public int getAmount() {
// return amount;
// }
//
// public void setAmount(int amount) {
// this.amount = amount;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// }
// Path: camel-jpa/src/main/java/org/wildfly/camel/examples/jpa/processor/JpaResultProcessor.java
import java.util.List;
import javax.inject.Named;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.wildfly.camel.examples.jpa.model.Order;
/*
* #%L
* Wildfly Camel :: Example :: Camel JPA
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.jpa.processor;
@Named
public class JpaResultProcessor implements Processor {
@SuppressWarnings("unchecked")
@Override
public void process(Exchange exchange) throws Exception { | List<Order> orders = exchange.getIn().getBody(List.class); |
wildfly-extras/wildfly-camel-examples | camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/data/CustomerRepository.java
// @ApplicationScoped
// @Named
// public class CustomerRepository {
//
// @Inject
// private EntityManager em;
//
// @Inject
// private UserTransaction userTransaction;
//
// public List<Customer> findAll() {
// CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
// CriteriaQuery<Customer> query = criteriaBuilder.createQuery(Customer.class);
// query.select(query.from(Customer.class));
// return em.createQuery(query).getResultList();
// }
//
// public Customer findById(Long id) {
// return em.find(Customer.class, id);
// }
//
// public Customer save(Customer customer) {
// try {
// try {
// userTransaction.begin();
// return em.merge(customer);
// } finally {
// userTransaction.commit();
// }
// } catch (Exception e) {
// try {
// userTransaction.rollback();
// } catch (SystemException se) {
// throw new RuntimeException(se);
// }
// throw new RuntimeException(e);
// }
// }
//
// public void delete(Customer customer) {
// try {
// try {
// userTransaction.begin();
// if (!em.contains(customer)) {
// customer = em.merge(customer);
// }
// em.remove(customer);
// } finally {
// userTransaction.commit();
// }
// } catch (Exception e) {
// try {
// userTransaction.rollback();
// } catch (SystemException se) {
// throw new RuntimeException(se);
// }
// throw new RuntimeException(e);
// }
// }
// }
//
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
| import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.camel.Exchange;
import org.wildfly.camel.examples.rest.data.CustomerRepository;
import org.wildfly.camel.examples.rest.model.Customer; | /*
* #%L
* Wildfly Camel :: Example :: Camel Rest Swagger
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.rest.service;
@ApplicationScoped
@Named
public class CustomerService {
@Inject | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/data/CustomerRepository.java
// @ApplicationScoped
// @Named
// public class CustomerRepository {
//
// @Inject
// private EntityManager em;
//
// @Inject
// private UserTransaction userTransaction;
//
// public List<Customer> findAll() {
// CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
// CriteriaQuery<Customer> query = criteriaBuilder.createQuery(Customer.class);
// query.select(query.from(Customer.class));
// return em.createQuery(query).getResultList();
// }
//
// public Customer findById(Long id) {
// return em.find(Customer.class, id);
// }
//
// public Customer save(Customer customer) {
// try {
// try {
// userTransaction.begin();
// return em.merge(customer);
// } finally {
// userTransaction.commit();
// }
// } catch (Exception e) {
// try {
// userTransaction.rollback();
// } catch (SystemException se) {
// throw new RuntimeException(se);
// }
// throw new RuntimeException(e);
// }
// }
//
// public void delete(Customer customer) {
// try {
// try {
// userTransaction.begin();
// if (!em.contains(customer)) {
// customer = em.merge(customer);
// }
// em.remove(customer);
// } finally {
// userTransaction.commit();
// }
// } catch (Exception e) {
// try {
// userTransaction.rollback();
// } catch (SystemException se) {
// throw new RuntimeException(se);
// }
// throw new RuntimeException(e);
// }
// }
// }
//
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.camel.Exchange;
import org.wildfly.camel.examples.rest.data.CustomerRepository;
import org.wildfly.camel.examples.rest.model.Customer;
/*
* #%L
* Wildfly Camel :: Example :: Camel Rest Swagger
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.rest.service;
@ApplicationScoped
@Named
public class CustomerService {
@Inject | CustomerRepository customerRepository; |
wildfly-extras/wildfly-camel-examples | camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/data/CustomerRepository.java
// @ApplicationScoped
// @Named
// public class CustomerRepository {
//
// @Inject
// private EntityManager em;
//
// @Inject
// private UserTransaction userTransaction;
//
// public List<Customer> findAll() {
// CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
// CriteriaQuery<Customer> query = criteriaBuilder.createQuery(Customer.class);
// query.select(query.from(Customer.class));
// return em.createQuery(query).getResultList();
// }
//
// public Customer findById(Long id) {
// return em.find(Customer.class, id);
// }
//
// public Customer save(Customer customer) {
// try {
// try {
// userTransaction.begin();
// return em.merge(customer);
// } finally {
// userTransaction.commit();
// }
// } catch (Exception e) {
// try {
// userTransaction.rollback();
// } catch (SystemException se) {
// throw new RuntimeException(se);
// }
// throw new RuntimeException(e);
// }
// }
//
// public void delete(Customer customer) {
// try {
// try {
// userTransaction.begin();
// if (!em.contains(customer)) {
// customer = em.merge(customer);
// }
// em.remove(customer);
// } finally {
// userTransaction.commit();
// }
// } catch (Exception e) {
// try {
// userTransaction.rollback();
// } catch (SystemException se) {
// throw new RuntimeException(se);
// }
// throw new RuntimeException(e);
// }
// }
// }
//
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
| import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.camel.Exchange;
import org.wildfly.camel.examples.rest.data.CustomerRepository;
import org.wildfly.camel.examples.rest.model.Customer; | /*
* #%L
* Wildfly Camel :: Example :: Camel Rest Swagger
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.rest.service;
@ApplicationScoped
@Named
public class CustomerService {
@Inject
CustomerRepository customerRepository;
public void findAll(Exchange exchange) { | // Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/data/CustomerRepository.java
// @ApplicationScoped
// @Named
// public class CustomerRepository {
//
// @Inject
// private EntityManager em;
//
// @Inject
// private UserTransaction userTransaction;
//
// public List<Customer> findAll() {
// CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
// CriteriaQuery<Customer> query = criteriaBuilder.createQuery(Customer.class);
// query.select(query.from(Customer.class));
// return em.createQuery(query).getResultList();
// }
//
// public Customer findById(Long id) {
// return em.find(Customer.class, id);
// }
//
// public Customer save(Customer customer) {
// try {
// try {
// userTransaction.begin();
// return em.merge(customer);
// } finally {
// userTransaction.commit();
// }
// } catch (Exception e) {
// try {
// userTransaction.rollback();
// } catch (SystemException se) {
// throw new RuntimeException(se);
// }
// throw new RuntimeException(e);
// }
// }
//
// public void delete(Customer customer) {
// try {
// try {
// userTransaction.begin();
// if (!em.contains(customer)) {
// customer = em.merge(customer);
// }
// em.remove(customer);
// } finally {
// userTransaction.commit();
// }
// } catch (Exception e) {
// try {
// userTransaction.rollback();
// } catch (SystemException se) {
// throw new RuntimeException(se);
// }
// throw new RuntimeException(e);
// }
// }
// }
//
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/model/Customer.java
// @Entity
// @Table(name = "customer")
// public class Customer implements Serializable {
//
// private static final long serialVersionUID = -2372350530824400584L;
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// private Long id;
// private String firstName;
// private String lastName;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// @Override
// public String toString() {
// return "Customer{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
// }
// }
// Path: camel-rest-swagger/src/main/java/org/wildfly/camel/examples/rest/service/CustomerService.java
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.camel.Exchange;
import org.wildfly.camel.examples.rest.data.CustomerRepository;
import org.wildfly.camel.examples.rest.model.Customer;
/*
* #%L
* Wildfly Camel :: Example :: Camel Rest Swagger
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.rest.service;
@ApplicationScoped
@Named
public class CustomerService {
@Inject
CustomerRepository customerRepository;
public void findAll(Exchange exchange) { | List<Customer> customers = customerRepository.findAll(); |
wildfly-extras/wildfly-camel-examples | camel-jms-spring/src/main/java/org/wildfly/camel/examples/jms/JmsServlet.java | // Path: camel-jms-spring/src/main/java/org/wildfly/camel/examples/jms/OrderGenerator.java
// public static final String[] COUNTRIES = {"UK", "US", "Other"};
| import static org.wildfly.camel.examples.jms.OrderGenerator.COUNTRIES;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map; | /*
* #%L
* Wildfly Camel :: Example :: Camel JMS Spring
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.jms;
@SuppressWarnings("serial")
@WebServlet(name = "HttpServiceServlet", urlPatterns = {"/orders/*"}, loadOnStartup = 1)
public class JmsServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//Work out a count of order files processed for each country
Map<String, Integer> orderCounts = new HashMap<>();
| // Path: camel-jms-spring/src/main/java/org/wildfly/camel/examples/jms/OrderGenerator.java
// public static final String[] COUNTRIES = {"UK", "US", "Other"};
// Path: camel-jms-spring/src/main/java/org/wildfly/camel/examples/jms/JmsServlet.java
import static org.wildfly.camel.examples.jms.OrderGenerator.COUNTRIES;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
/*
* #%L
* Wildfly Camel :: Example :: Camel JMS Spring
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.jms;
@SuppressWarnings("serial")
@WebServlet(name = "HttpServiceServlet", urlPatterns = {"/orders/*"}, loadOnStartup = 1)
public class JmsServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//Work out a count of order files processed for each country
Map<String, Integer> orderCounts = new HashMap<>();
| for (String country : COUNTRIES) { |
wildfly-extras/wildfly-camel-examples | camel-activemq/src/main/java/org/wildfly/camel/examples/activemq/OrdersServlet.java | // Path: camel-activemq/src/main/java/org/wildfly/camel/examples/activemq/OrderGenerator.java
// public static final String[] COUNTRIES = {"UK", "US", "Other"};
| import static org.wildfly.camel.examples.activemq.OrderGenerator.COUNTRIES;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map; | /*
* #%L
* Wildfly Camel :: Example :: Camel ActiveMQ
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.activemq;
@SuppressWarnings("serial")
@WebServlet(name = "HttpServiceServlet", urlPatterns = {"/orders/*"}, loadOnStartup = 1)
public class OrdersServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//Work out a count of order files processed for each country
Map<String, Integer> orderCounts = new HashMap<>();
| // Path: camel-activemq/src/main/java/org/wildfly/camel/examples/activemq/OrderGenerator.java
// public static final String[] COUNTRIES = {"UK", "US", "Other"};
// Path: camel-activemq/src/main/java/org/wildfly/camel/examples/activemq/OrdersServlet.java
import static org.wildfly.camel.examples.activemq.OrderGenerator.COUNTRIES;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
/*
* #%L
* Wildfly Camel :: Example :: Camel ActiveMQ
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* 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 org.wildfly.camel.examples.activemq;
@SuppressWarnings("serial")
@WebServlet(name = "HttpServiceServlet", urlPatterns = {"/orders/*"}, loadOnStartup = 1)
public class OrdersServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//Work out a count of order files processed for each country
Map<String, Integer> orderCounts = new HashMap<>();
| for (String country : COUNTRIES) { |
wildfly-extras/wildfly-camel-examples | itests/src/main/java/org/wildfly/camel/examples/test/jms/JMSMDBExampleTest.java | // Path: itests/src/main/java/org/wildfly/camel/examples/test/common/ServerLogReader.java
// public class ServerLogReader {
// private static final Path SERVER_LOG = Paths.get(System.getProperty("jboss.home.dir"), "standalone/log/server.log");
//
// /**
// * @param message The log message to match on
// * @param timeout The timeout period in milliseconds for the log message to appear
// * @return true if the log message was found else false
// */
// public static boolean awaitLogMessage(String message, long timeout) {
// long start = System.currentTimeMillis();
// do {
// try {
// List<String> logLines = Files.readAllLines(SERVER_LOG);
// if (logLines.stream().filter(line -> line.matches(message)).count() > 0) {
// return true;
// }
// } catch (Exception e) {
// e.printStackTrace();
// return false;
// }
// try {
// Thread.sleep(100L);
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// return false;
// }
// } while (!((System.currentTimeMillis() - start) >= timeout));
// return false;
// }
// }
| import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.camel.examples.test.common.ServerLogReader;
import org.wildfly.camel.test.common.utils.JMSUtils;
import java.io.File;
import java.io.IOException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive; | /*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.test.jms;
@RunAsClient
@RunWith(Arquillian.class)
@ServerSetup({ JMSMDBExampleTest.JmsQueueSetup.class })
public class JMSMDBExampleTest {
private static String ORDERS_QUEUE = "OrdersQueue";
private static String ORDERS_QUEUE_JNDI = "java:/jms/queue/OrdersQueue";
static class JmsQueueSetup implements ServerSetupTask {
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
JMSUtils.createJmsQueue(ORDERS_QUEUE, ORDERS_QUEUE_JNDI, managementClient.getControllerClient());
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
JMSUtils.removeJmsQueue(ORDERS_QUEUE, managementClient.getControllerClient());
}
}
@Deployment(testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/examples/example-camel-jms-mdb.war"));
}
@Test
public void testJMSMDBRoute() throws IOException { | // Path: itests/src/main/java/org/wildfly/camel/examples/test/common/ServerLogReader.java
// public class ServerLogReader {
// private static final Path SERVER_LOG = Paths.get(System.getProperty("jboss.home.dir"), "standalone/log/server.log");
//
// /**
// * @param message The log message to match on
// * @param timeout The timeout period in milliseconds for the log message to appear
// * @return true if the log message was found else false
// */
// public static boolean awaitLogMessage(String message, long timeout) {
// long start = System.currentTimeMillis();
// do {
// try {
// List<String> logLines = Files.readAllLines(SERVER_LOG);
// if (logLines.stream().filter(line -> line.matches(message)).count() > 0) {
// return true;
// }
// } catch (Exception e) {
// e.printStackTrace();
// return false;
// }
// try {
// Thread.sleep(100L);
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// return false;
// }
// } while (!((System.currentTimeMillis() - start) >= timeout));
// return false;
// }
// }
// Path: itests/src/main/java/org/wildfly/camel/examples/test/jms/JMSMDBExampleTest.java
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.camel.examples.test.common.ServerLogReader;
import org.wildfly.camel.test.common.utils.JMSUtils;
import java.io.File;
import java.io.IOException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
/*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2017 RedHat
* %%
* 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 org.wildfly.camel.examples.test.jms;
@RunAsClient
@RunWith(Arquillian.class)
@ServerSetup({ JMSMDBExampleTest.JmsQueueSetup.class })
public class JMSMDBExampleTest {
private static String ORDERS_QUEUE = "OrdersQueue";
private static String ORDERS_QUEUE_JNDI = "java:/jms/queue/OrdersQueue";
static class JmsQueueSetup implements ServerSetupTask {
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
JMSUtils.createJmsQueue(ORDERS_QUEUE, ORDERS_QUEUE_JNDI, managementClient.getControllerClient());
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
JMSUtils.removeJmsQueue(ORDERS_QUEUE, managementClient.getControllerClient());
}
}
@Deployment(testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/examples/example-camel-jms-mdb.war"));
}
@Test
public void testJMSMDBRoute() throws IOException { | boolean logMessagePresent = ServerLogReader.awaitLogMessage(".*Received message: Message [0-9].*", 10000); |
solita/phantom-runner | src/main/java/fi/solita/phantomrunner/JavascriptTestInterpreterConfiguration.java | // Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTestInterpreter.java
// public interface JavascriptTestInterpreter {
//
// /**
// * Provides a test file data as String to the interpreter for parsing. This is the main entry point
// * for parsing the tests and the returned tests should be interpreter specific implementations.
// */
// List<JavascriptTest> listTestsFrom(String data);
//
// /**
// * Returns a HTML file which will be used as the "test runner" for this interpreter.
// *
// * @param additionalJsFilePaths An array of resource paths which should be added to the page
// * before the test file
// * @param testFilePath A resource path to the JavaScript test file to be embedded to the test runner page
// */
// String getTestHTML(String[] additionalJsFilePaths, String testFilePath);
//
//
// /**
// * Returns a resource path array for all JavaScript library files needed for by the JavaScript test
// * framework this interpreter represents.
// */
// String[] getLibPaths();
//
// /**
// * Returns the path to the JavaScript runner file for this interpreter. This runner file is the real
// * glue between PhantomJS and the testing framework. It should call the testing framework API and do
// * the dirty work needed for the actual tests to run. It is also responsible of actually evaluating the
// * data from the tests etc.
// */
// String getRunnerPath();
//
// /**
// * Evaluate the given JSON result data received from the JavaScript runner. Did the executed test pass or
// * not?
// */
// boolean evaluateResult(JsonNode resultTree);
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import fi.solita.phantomrunner.testinterpreter.JavascriptTestInterpreter;
| /**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface JavascriptTestInterpreterConfiguration {
/**
* Interpreter class to be used for the test execution. This class with it's resource files provide
* {@link PhantomRunner} way to execute and interpret JavaScript tests and binds them to JUnit test framework.
* All implementations of {@link JavascriptTestInterpreter} provide a version of the actual testing library
* JavaScript file but if the version used is old you may override the library file(s) with
* {@link JavascriptTestInterpreterConfiguration#libraryFilePaths()}. Please note though that this <b>may</b>
* break the interpreter if the semantics of the library have changed a lot.
*/
| // Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTestInterpreter.java
// public interface JavascriptTestInterpreter {
//
// /**
// * Provides a test file data as String to the interpreter for parsing. This is the main entry point
// * for parsing the tests and the returned tests should be interpreter specific implementations.
// */
// List<JavascriptTest> listTestsFrom(String data);
//
// /**
// * Returns a HTML file which will be used as the "test runner" for this interpreter.
// *
// * @param additionalJsFilePaths An array of resource paths which should be added to the page
// * before the test file
// * @param testFilePath A resource path to the JavaScript test file to be embedded to the test runner page
// */
// String getTestHTML(String[] additionalJsFilePaths, String testFilePath);
//
//
// /**
// * Returns a resource path array for all JavaScript library files needed for by the JavaScript test
// * framework this interpreter represents.
// */
// String[] getLibPaths();
//
// /**
// * Returns the path to the JavaScript runner file for this interpreter. This runner file is the real
// * glue between PhantomJS and the testing framework. It should call the testing framework API and do
// * the dirty work needed for the actual tests to run. It is also responsible of actually evaluating the
// * data from the tests etc.
// */
// String getRunnerPath();
//
// /**
// * Evaluate the given JSON result data received from the JavaScript runner. Did the executed test pass or
// * not?
// */
// boolean evaluateResult(JsonNode resultTree);
//
// }
// Path: src/main/java/fi/solita/phantomrunner/JavascriptTestInterpreterConfiguration.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import fi.solita.phantomrunner.testinterpreter.JavascriptTestInterpreter;
/**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface JavascriptTestInterpreterConfiguration {
/**
* Interpreter class to be used for the test execution. This class with it's resource files provide
* {@link PhantomRunner} way to execute and interpret JavaScript tests and binds them to JUnit test framework.
* All implementations of {@link JavascriptTestInterpreter} provide a version of the actual testing library
* JavaScript file but if the version used is old you may override the library file(s) with
* {@link JavascriptTestInterpreterConfiguration#libraryFilePaths()}. Please note though that this <b>may</b>
* break the interpreter if the semantics of the library have changed a lot.
*/
| Class<? extends JavascriptTestInterpreter> interpreterClass();
|
solita/phantom-runner | src/main/java/fi/solita/phantomrunner/PhantomProcessNotifier.java | // Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTest.java
// public interface JavascriptTest {
//
// /**
// * Returns the name of this test if available. Implementations should never return null.
// */
// String getTestName();
//
// /**
// * Returns the JavaScript test as String which this object represents.
// */
// String getTestData();
//
// /**
// * Converts this test to JUnit {@link Description} object. A class is provided as parameter to satisfy
// * {@link Description} constructor needs since with JavaScript tests there are no concrete test classes
// * to link into {@link Description}.
// */
// Description asDescription(Class<?> parentTestClass);
//
// /**
// * Executes this test. Provided {@link RunNotifier} should be used to report test execution results
// * for JUnit and {@link PhantomProcessNotifier} can be used to communicate with PhantomJS and trigger
// * the test execution in the browser.
// */
// void run(RunNotifier notifier, PhantomProcessNotifier processNotifier);
//
// /**
// * Is this a single test or a suite of multiple tests?
// */
// boolean isTest();
//
// /**
// * Returns the name of this test suite if available (that is, if {@link #isTest()} returns false).
// */
// String getSuiteName();
// }
| import fi.solita.phantomrunner.testinterpreter.JavascriptTest;
import com.fasterxml.jackson.databind.JsonNode;
| /**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
/**
* <p>Notifier which informs the PhantomJs process of two things:</p>
*
* <ul>
* <li>Test file is about to be executed (an HTML file containing the test script)</li>
* <li>A test described in the above test file is about to be executed</li>
* </ul>
*/
public interface PhantomProcessNotifier {
/**
* Initializes a JavaScript test file in the PhantomJs for execution. Always call this before
* calling {@link #runTest(JavascriptTest)} to ensure PhantomJs is aware of the tests.
*
* @param testFileData An HTML file containing the actual test data as inline script
*/
void initializeTestRun(String testFileData);
/**
* Executes the given test at PhantomJs.
*
* @param javascriptTest
* @return JsonNode containing the result JSON generated at JavaScript code
*/
| // Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTest.java
// public interface JavascriptTest {
//
// /**
// * Returns the name of this test if available. Implementations should never return null.
// */
// String getTestName();
//
// /**
// * Returns the JavaScript test as String which this object represents.
// */
// String getTestData();
//
// /**
// * Converts this test to JUnit {@link Description} object. A class is provided as parameter to satisfy
// * {@link Description} constructor needs since with JavaScript tests there are no concrete test classes
// * to link into {@link Description}.
// */
// Description asDescription(Class<?> parentTestClass);
//
// /**
// * Executes this test. Provided {@link RunNotifier} should be used to report test execution results
// * for JUnit and {@link PhantomProcessNotifier} can be used to communicate with PhantomJS and trigger
// * the test execution in the browser.
// */
// void run(RunNotifier notifier, PhantomProcessNotifier processNotifier);
//
// /**
// * Is this a single test or a suite of multiple tests?
// */
// boolean isTest();
//
// /**
// * Returns the name of this test suite if available (that is, if {@link #isTest()} returns false).
// */
// String getSuiteName();
// }
// Path: src/main/java/fi/solita/phantomrunner/PhantomProcessNotifier.java
import fi.solita.phantomrunner.testinterpreter.JavascriptTest;
import com.fasterxml.jackson.databind.JsonNode;
/**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
/**
* <p>Notifier which informs the PhantomJs process of two things:</p>
*
* <ul>
* <li>Test file is about to be executed (an HTML file containing the test script)</li>
* <li>A test described in the above test file is about to be executed</li>
* </ul>
*/
public interface PhantomProcessNotifier {
/**
* Initializes a JavaScript test file in the PhantomJs for execution. Always call this before
* calling {@link #runTest(JavascriptTest)} to ensure PhantomJs is aware of the tests.
*
* @param testFileData An HTML file containing the actual test data as inline script
*/
void initializeTestRun(String testFileData);
/**
* Executes the given test at PhantomJs.
*
* @param javascriptTest
* @return JsonNode containing the result JSON generated at JavaScript code
*/
| JsonNode runTest(JavascriptTest javascriptTest);
|
solita/phantom-runner | src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTestScanner.java | // Path: src/main/java/fi/solita/phantomrunner/util/ClassUtils.java
// public class ClassUtils {
//
// @SuppressWarnings("unchecked")
// public static <T extends Annotation> T findClassAnnotation(Class<T> annotationClass, Class<?> fromClass, boolean required) {
// for (Annotation a : fromClass.getAnnotations()) {
// if (a.annotationType().equals(annotationClass)) {
// return (T) a;
// }
// }
//
// if (required) {
// throw new IllegalStateException(String.format(
// "Illegal PhantomRunner configuration, no %s annotation found at %s type level",
// annotationClass.getName(), fromClass.getName()));
// }
// return null;
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import fi.solita.phantomrunner.PhantomConfiguration;
import fi.solita.phantomrunner.util.ClassUtils;
| /**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner.testinterpreter;
/**
* Scanner for JavaScript test files.
*/
public class JavascriptTestScanner {
private final Class<?> testClass;
private final JavascriptTestInterpreter interpreter;
public JavascriptTestScanner(Class<?> testClass, JavascriptTestInterpreter interpreter) {
this.testClass = testClass;
this.interpreter = interpreter;
}
public void parseTests(TestScannerListener listener) {
try {
for (File f : scanForTests()) {
String data = FileUtils.fileRead(f, "UTF-8");
listener.fileScanned("file://" + f.getAbsolutePath(), data, interpreter.listTestsFrom(data));
}
} catch (IOException e) {
throw new JavascriptInterpreterException("Error occured while reading Javascript test file", e);
}
}
private Iterable<File> scanForTests() {
List<File> foundFiles = new ArrayList<File>();
| // Path: src/main/java/fi/solita/phantomrunner/util/ClassUtils.java
// public class ClassUtils {
//
// @SuppressWarnings("unchecked")
// public static <T extends Annotation> T findClassAnnotation(Class<T> annotationClass, Class<?> fromClass, boolean required) {
// for (Annotation a : fromClass.getAnnotations()) {
// if (a.annotationType().equals(annotationClass)) {
// return (T) a;
// }
// }
//
// if (required) {
// throw new IllegalStateException(String.format(
// "Illegal PhantomRunner configuration, no %s annotation found at %s type level",
// annotationClass.getName(), fromClass.getName()));
// }
// return null;
// }
//
// }
// Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTestScanner.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import fi.solita.phantomrunner.PhantomConfiguration;
import fi.solita.phantomrunner.util.ClassUtils;
/**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner.testinterpreter;
/**
* Scanner for JavaScript test files.
*/
public class JavascriptTestScanner {
private final Class<?> testClass;
private final JavascriptTestInterpreter interpreter;
public JavascriptTestScanner(Class<?> testClass, JavascriptTestInterpreter interpreter) {
this.testClass = testClass;
this.interpreter = interpreter;
}
public void parseTests(TestScannerListener listener) {
try {
for (File f : scanForTests()) {
String data = FileUtils.fileRead(f, "UTF-8");
listener.fileScanned("file://" + f.getAbsolutePath(), data, interpreter.listTestsFrom(data));
}
} catch (IOException e) {
throw new JavascriptInterpreterException("Error occured while reading Javascript test file", e);
}
}
private Iterable<File> scanForTests() {
List<File> foundFiles = new ArrayList<File>();
| for (String included : findMatchingIncludedFilePaths(ClassUtils.findClassAnnotation(PhantomConfiguration.class, testClass, true))) {
|
solita/phantom-runner | src/main/java/fi/solita/phantomrunner/jetty/WebsocketPhantomNotifier.java | // Path: src/main/java/fi/solita/phantomrunner/PhantomProcessNotifier.java
// public interface PhantomProcessNotifier {
//
// /**
// * Initializes a JavaScript test file in the PhantomJs for execution. Always call this before
// * calling {@link #runTest(JavascriptTest)} to ensure PhantomJs is aware of the tests.
// *
// * @param testFileData An HTML file containing the actual test data as inline script
// */
// void initializeTestRun(String testFileData);
//
// /**
// * Executes the given test at PhantomJs.
// *
// * @param javascriptTest
// * @return JsonNode containing the result JSON generated at JavaScript code
// */
// JsonNode runTest(JavascriptTest javascriptTest);
//
// }
//
// Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTest.java
// public interface JavascriptTest {
//
// /**
// * Returns the name of this test if available. Implementations should never return null.
// */
// String getTestName();
//
// /**
// * Returns the JavaScript test as String which this object represents.
// */
// String getTestData();
//
// /**
// * Converts this test to JUnit {@link Description} object. A class is provided as parameter to satisfy
// * {@link Description} constructor needs since with JavaScript tests there are no concrete test classes
// * to link into {@link Description}.
// */
// Description asDescription(Class<?> parentTestClass);
//
// /**
// * Executes this test. Provided {@link RunNotifier} should be used to report test execution results
// * for JUnit and {@link PhantomProcessNotifier} can be used to communicate with PhantomJS and trigger
// * the test execution in the browser.
// */
// void run(RunNotifier notifier, PhantomProcessNotifier processNotifier);
//
// /**
// * Is this a single test or a suite of multiple tests?
// */
// boolean isTest();
//
// /**
// * Returns the name of this test suite if available (that is, if {@link #isTest()} returns false).
// */
// String getSuiteName();
// }
| import java.io.IOException;
import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import fi.solita.phantomrunner.PhantomProcessNotifier;
import fi.solita.phantomrunner.testinterpreter.JavascriptTest;
| /**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner.jetty;
/**
* Notifier implementation which sends messages to PhantomJS via websocket.
*/
public class WebsocketPhantomNotifier implements PhantomProcessNotifier {
private final ObjectMapper mapper = new ObjectMapper();
private final PhantomWebSocketHandler handler;
public WebsocketPhantomNotifier(PhantomWebSocketHandler interpreterHandler) {
this.handler = interpreterHandler;
}
@Override
public void initializeTestRun(String testFileData) {
ImmutableMap.Builder<String, Object> json = ImmutableMap.builder();
send(json
.put("type", "init")
.put("testFileData", testFileData)
.build());
}
@Override
| // Path: src/main/java/fi/solita/phantomrunner/PhantomProcessNotifier.java
// public interface PhantomProcessNotifier {
//
// /**
// * Initializes a JavaScript test file in the PhantomJs for execution. Always call this before
// * calling {@link #runTest(JavascriptTest)} to ensure PhantomJs is aware of the tests.
// *
// * @param testFileData An HTML file containing the actual test data as inline script
// */
// void initializeTestRun(String testFileData);
//
// /**
// * Executes the given test at PhantomJs.
// *
// * @param javascriptTest
// * @return JsonNode containing the result JSON generated at JavaScript code
// */
// JsonNode runTest(JavascriptTest javascriptTest);
//
// }
//
// Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTest.java
// public interface JavascriptTest {
//
// /**
// * Returns the name of this test if available. Implementations should never return null.
// */
// String getTestName();
//
// /**
// * Returns the JavaScript test as String which this object represents.
// */
// String getTestData();
//
// /**
// * Converts this test to JUnit {@link Description} object. A class is provided as parameter to satisfy
// * {@link Description} constructor needs since with JavaScript tests there are no concrete test classes
// * to link into {@link Description}.
// */
// Description asDescription(Class<?> parentTestClass);
//
// /**
// * Executes this test. Provided {@link RunNotifier} should be used to report test execution results
// * for JUnit and {@link PhantomProcessNotifier} can be used to communicate with PhantomJS and trigger
// * the test execution in the browser.
// */
// void run(RunNotifier notifier, PhantomProcessNotifier processNotifier);
//
// /**
// * Is this a single test or a suite of multiple tests?
// */
// boolean isTest();
//
// /**
// * Returns the name of this test suite if available (that is, if {@link #isTest()} returns false).
// */
// String getSuiteName();
// }
// Path: src/main/java/fi/solita/phantomrunner/jetty/WebsocketPhantomNotifier.java
import java.io.IOException;
import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import fi.solita.phantomrunner.PhantomProcessNotifier;
import fi.solita.phantomrunner.testinterpreter.JavascriptTest;
/**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner.jetty;
/**
* Notifier implementation which sends messages to PhantomJS via websocket.
*/
public class WebsocketPhantomNotifier implements PhantomProcessNotifier {
private final ObjectMapper mapper = new ObjectMapper();
private final PhantomWebSocketHandler handler;
public WebsocketPhantomNotifier(PhantomWebSocketHandler interpreterHandler) {
this.handler = interpreterHandler;
}
@Override
public void initializeTestRun(String testFileData) {
ImmutableMap.Builder<String, Object> json = ImmutableMap.builder();
send(json
.put("type", "init")
.put("testFileData", testFileData)
.build());
}
@Override
| public JsonNode runTest(JavascriptTest javascriptTest) {
|
solita/phantom-runner | src/main/java/fi/solita/phantomrunner/browserserver/HttpPhantomJsServerNotifier.java | // Path: src/main/java/fi/solita/phantomrunner/PhantomProcessNotifier.java
// public interface PhantomProcessNotifier {
//
// /**
// * Initializes a JavaScript test file in the PhantomJs for execution. Always call this before
// * calling {@link #runTest(JavascriptTest)} to ensure PhantomJs is aware of the tests.
// *
// * @param testFileData An HTML file containing the actual test data as inline script
// */
// void initializeTestRun(String testFileData);
//
// /**
// * Executes the given test at PhantomJs.
// *
// * @param javascriptTest
// * @return JsonNode containing the result JSON generated at JavaScript code
// */
// JsonNode runTest(JavascriptTest javascriptTest);
//
// }
//
// Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTest.java
// public interface JavascriptTest {
//
// /**
// * Returns the name of this test if available. Implementations should never return null.
// */
// String getTestName();
//
// /**
// * Returns the JavaScript test as String which this object represents.
// */
// String getTestData();
//
// /**
// * Converts this test to JUnit {@link Description} object. A class is provided as parameter to satisfy
// * {@link Description} constructor needs since with JavaScript tests there are no concrete test classes
// * to link into {@link Description}.
// */
// Description asDescription(Class<?> parentTestClass);
//
// /**
// * Executes this test. Provided {@link RunNotifier} should be used to report test execution results
// * for JUnit and {@link PhantomProcessNotifier} can be used to communicate with PhantomJS and trigger
// * the test execution in the browser.
// */
// void run(RunNotifier notifier, PhantomProcessNotifier processNotifier);
//
// /**
// * Is this a single test or a suite of multiple tests?
// */
// boolean isTest();
//
// /**
// * Returns the name of this test suite if available (that is, if {@link #isTest()} returns false).
// */
// String getSuiteName();
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import fi.solita.phantomrunner.PhantomProcessNotifier;
import fi.solita.phantomrunner.testinterpreter.JavascriptTest;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import com.fasterxml.jackson.databind.JsonNode;
| /**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner.browserserver;
/**
* {@link PhantomProcessNotifier} implementation which calls external HTTP server (PhantomJs web server) with
* regular HTTP POST requests.
*/
public class HttpPhantomJsServerNotifier implements PhantomProcessNotifier {
private final HttpClient client = new HttpClient();
private final ObjectMapper mapper = new ObjectMapper();
@Override
public void initializeTestRun(String testFileData) {
ImmutableMap.Builder<String, Object> json = ImmutableMap.builder();
send(json
.put("type", "init")
.put("testFileData", testFileData)
.build());
}
@Override
| // Path: src/main/java/fi/solita/phantomrunner/PhantomProcessNotifier.java
// public interface PhantomProcessNotifier {
//
// /**
// * Initializes a JavaScript test file in the PhantomJs for execution. Always call this before
// * calling {@link #runTest(JavascriptTest)} to ensure PhantomJs is aware of the tests.
// *
// * @param testFileData An HTML file containing the actual test data as inline script
// */
// void initializeTestRun(String testFileData);
//
// /**
// * Executes the given test at PhantomJs.
// *
// * @param javascriptTest
// * @return JsonNode containing the result JSON generated at JavaScript code
// */
// JsonNode runTest(JavascriptTest javascriptTest);
//
// }
//
// Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTest.java
// public interface JavascriptTest {
//
// /**
// * Returns the name of this test if available. Implementations should never return null.
// */
// String getTestName();
//
// /**
// * Returns the JavaScript test as String which this object represents.
// */
// String getTestData();
//
// /**
// * Converts this test to JUnit {@link Description} object. A class is provided as parameter to satisfy
// * {@link Description} constructor needs since with JavaScript tests there are no concrete test classes
// * to link into {@link Description}.
// */
// Description asDescription(Class<?> parentTestClass);
//
// /**
// * Executes this test. Provided {@link RunNotifier} should be used to report test execution results
// * for JUnit and {@link PhantomProcessNotifier} can be used to communicate with PhantomJS and trigger
// * the test execution in the browser.
// */
// void run(RunNotifier notifier, PhantomProcessNotifier processNotifier);
//
// /**
// * Is this a single test or a suite of multiple tests?
// */
// boolean isTest();
//
// /**
// * Returns the name of this test suite if available (that is, if {@link #isTest()} returns false).
// */
// String getSuiteName();
// }
// Path: src/main/java/fi/solita/phantomrunner/browserserver/HttpPhantomJsServerNotifier.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import fi.solita.phantomrunner.PhantomProcessNotifier;
import fi.solita.phantomrunner.testinterpreter.JavascriptTest;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import com.fasterxml.jackson.databind.JsonNode;
/**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner.browserserver;
/**
* {@link PhantomProcessNotifier} implementation which calls external HTTP server (PhantomJs web server) with
* regular HTTP POST requests.
*/
public class HttpPhantomJsServerNotifier implements PhantomProcessNotifier {
private final HttpClient client = new HttpClient();
private final ObjectMapper mapper = new ObjectMapper();
@Override
public void initializeTestRun(String testFileData) {
ImmutableMap.Builder<String, Object> json = ImmutableMap.builder();
send(json
.put("type", "init")
.put("testFileData", testFileData)
.build());
}
@Override
| public JsonNode runTest(JavascriptTest javascriptTest) {
|
solita/phantom-runner | src/main/java/fi/solita/phantomrunner/PhantomServerFactory.java | // Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTestInterpreter.java
// public interface JavascriptTestInterpreter {
//
// /**
// * Provides a test file data as String to the interpreter for parsing. This is the main entry point
// * for parsing the tests and the returned tests should be interpreter specific implementations.
// */
// List<JavascriptTest> listTestsFrom(String data);
//
// /**
// * Returns a HTML file which will be used as the "test runner" for this interpreter.
// *
// * @param additionalJsFilePaths An array of resource paths which should be added to the page
// * before the test file
// * @param testFilePath A resource path to the JavaScript test file to be embedded to the test runner page
// */
// String getTestHTML(String[] additionalJsFilePaths, String testFilePath);
//
//
// /**
// * Returns a resource path array for all JavaScript library files needed for by the JavaScript test
// * framework this interpreter represents.
// */
// String[] getLibPaths();
//
// /**
// * Returns the path to the JavaScript runner file for this interpreter. This runner file is the real
// * glue between PhantomJS and the testing framework. It should call the testing framework API and do
// * the dirty work needed for the actual tests to run. It is also responsible of actually evaluating the
// * data from the tests etc.
// */
// String getRunnerPath();
//
// /**
// * Evaluate the given JSON result data received from the JavaScript runner. Did the executed test pass or
// * not?
// */
// boolean evaluateResult(JsonNode resultTree);
//
// }
| import fi.solita.phantomrunner.testinterpreter.JavascriptTestInterpreter;
import java.lang.reflect.Constructor;
| /**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
public class PhantomServerFactory {
private final PhantomServerConfiguration config;
| // Path: src/main/java/fi/solita/phantomrunner/testinterpreter/JavascriptTestInterpreter.java
// public interface JavascriptTestInterpreter {
//
// /**
// * Provides a test file data as String to the interpreter for parsing. This is the main entry point
// * for parsing the tests and the returned tests should be interpreter specific implementations.
// */
// List<JavascriptTest> listTestsFrom(String data);
//
// /**
// * Returns a HTML file which will be used as the "test runner" for this interpreter.
// *
// * @param additionalJsFilePaths An array of resource paths which should be added to the page
// * before the test file
// * @param testFilePath A resource path to the JavaScript test file to be embedded to the test runner page
// */
// String getTestHTML(String[] additionalJsFilePaths, String testFilePath);
//
//
// /**
// * Returns a resource path array for all JavaScript library files needed for by the JavaScript test
// * framework this interpreter represents.
// */
// String[] getLibPaths();
//
// /**
// * Returns the path to the JavaScript runner file for this interpreter. This runner file is the real
// * glue between PhantomJS and the testing framework. It should call the testing framework API and do
// * the dirty work needed for the actual tests to run. It is also responsible of actually evaluating the
// * data from the tests etc.
// */
// String getRunnerPath();
//
// /**
// * Evaluate the given JSON result data received from the JavaScript runner. Did the executed test pass or
// * not?
// */
// boolean evaluateResult(JsonNode resultTree);
//
// }
// Path: src/main/java/fi/solita/phantomrunner/PhantomServerFactory.java
import fi.solita.phantomrunner.testinterpreter.JavascriptTestInterpreter;
import java.lang.reflect.Constructor;
/**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
public class PhantomServerFactory {
private final PhantomServerConfiguration config;
| private final JavascriptTestInterpreter interpreter;
|
solita/phantom-runner | src/main/java/fi/solita/phantomrunner/PhantomProcess.java | // Path: src/main/java/fi/solita/phantomrunner/stream/StreamPiper.java
// public class StreamPiper implements Runnable {
//
// private final InputStream in;
// private final OutputStream out;
//
// public StreamPiper(InputStream in, OutputStream out) {
// this.in = in;
// this.out = out;
// }
//
// @Override
// public void run() {
// try {
// int read = -1;
// while ((read = in.read()) != -1) {
// out.write(read);
// }
// } catch (IOException ioe) {
// throw new RuntimeException(ioe);
// }
// }
// }
//
// Path: src/main/java/fi/solita/phantomrunner/util/Strings.java
// public class Strings {
//
// public static String firstMatch(String str, String regex) {
// Pattern p = Pattern.compile(regex);
// Matcher m = p.matcher(str);
// if (!m.find()) {
// throw new IllegalArgumentException("No match found for String: " + str);
// }
// return str.substring(m.start(), m.end());
// }
//
// public static List<String> splitTokens(String str, String regex) {
// return splitTokens(str, regex, 0);
// }
//
// public static List<String> splitTokens(String str, String regex, int flags) {
// Pattern p = Pattern.compile(regex, flags);
// Matcher m = p.matcher(str);
// List<String> result = new ArrayList<String>();
// while (m.find()) {
// result.add(m.group());
// }
// return result;
// }
//
// public static String indentLines(String str, int indentAmount) {
// StringBuilder builder = new StringBuilder();
// for (String line : str.split("\n")) {
// for (int i = 0; i < indentAmount; i++) {
// builder.append(' ');
// }
// builder.append(line);
// }
// return builder.toString();
// }
//
// public static String streamToString(InputStream stream) throws IOException {
// StringWriter writer = new StringWriter();
// IOUtil.copy(stream, writer, "UTF-8");
// return writer.toString();
// }
//
// public static List<String> stringList(String...str) {
// return Arrays.asList(str);
// }
//
// public static List<String> stringList(String str, String... strs) {
// Builder<String> builder = ImmutableList.builder();
// builder.add(str);
// builder.add(strs);
// return builder.build();
// }
// }
| import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import fi.solita.phantomrunner.stream.StreamPiper;
import fi.solita.phantomrunner.util.Strings;
| /**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
/**
* Class abstracting the PhantomJs process. Registers a shutdown hook for killing the process when JVM
* exits and provides a input stream piping to standard out.
*/
public class PhantomProcess {
private final String path;
private final Process phantomProcess;
public PhantomProcess(PhantomConfiguration config, String...jsFilePaths) {
this.path = config.phantomPath();
try {
| // Path: src/main/java/fi/solita/phantomrunner/stream/StreamPiper.java
// public class StreamPiper implements Runnable {
//
// private final InputStream in;
// private final OutputStream out;
//
// public StreamPiper(InputStream in, OutputStream out) {
// this.in = in;
// this.out = out;
// }
//
// @Override
// public void run() {
// try {
// int read = -1;
// while ((read = in.read()) != -1) {
// out.write(read);
// }
// } catch (IOException ioe) {
// throw new RuntimeException(ioe);
// }
// }
// }
//
// Path: src/main/java/fi/solita/phantomrunner/util/Strings.java
// public class Strings {
//
// public static String firstMatch(String str, String regex) {
// Pattern p = Pattern.compile(regex);
// Matcher m = p.matcher(str);
// if (!m.find()) {
// throw new IllegalArgumentException("No match found for String: " + str);
// }
// return str.substring(m.start(), m.end());
// }
//
// public static List<String> splitTokens(String str, String regex) {
// return splitTokens(str, regex, 0);
// }
//
// public static List<String> splitTokens(String str, String regex, int flags) {
// Pattern p = Pattern.compile(regex, flags);
// Matcher m = p.matcher(str);
// List<String> result = new ArrayList<String>();
// while (m.find()) {
// result.add(m.group());
// }
// return result;
// }
//
// public static String indentLines(String str, int indentAmount) {
// StringBuilder builder = new StringBuilder();
// for (String line : str.split("\n")) {
// for (int i = 0; i < indentAmount; i++) {
// builder.append(' ');
// }
// builder.append(line);
// }
// return builder.toString();
// }
//
// public static String streamToString(InputStream stream) throws IOException {
// StringWriter writer = new StringWriter();
// IOUtil.copy(stream, writer, "UTF-8");
// return writer.toString();
// }
//
// public static List<String> stringList(String...str) {
// return Arrays.asList(str);
// }
//
// public static List<String> stringList(String str, String... strs) {
// Builder<String> builder = ImmutableList.builder();
// builder.add(str);
// builder.add(strs);
// return builder.build();
// }
// }
// Path: src/main/java/fi/solita/phantomrunner/PhantomProcess.java
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import fi.solita.phantomrunner.stream.StreamPiper;
import fi.solita.phantomrunner.util.Strings;
/**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
/**
* Class abstracting the PhantomJs process. Registers a shutdown hook for killing the process when JVM
* exits and provides a input stream piping to standard out.
*/
public class PhantomProcess {
private final String path;
private final Process phantomProcess;
public PhantomProcess(PhantomConfiguration config, String...jsFilePaths) {
this.path = config.phantomPath();
try {
| this.phantomProcess = new ProcessBuilder(Strings.stringList(path, jsFilePaths)).start();
|
solita/phantom-runner | src/main/java/fi/solita/phantomrunner/PhantomProcess.java | // Path: src/main/java/fi/solita/phantomrunner/stream/StreamPiper.java
// public class StreamPiper implements Runnable {
//
// private final InputStream in;
// private final OutputStream out;
//
// public StreamPiper(InputStream in, OutputStream out) {
// this.in = in;
// this.out = out;
// }
//
// @Override
// public void run() {
// try {
// int read = -1;
// while ((read = in.read()) != -1) {
// out.write(read);
// }
// } catch (IOException ioe) {
// throw new RuntimeException(ioe);
// }
// }
// }
//
// Path: src/main/java/fi/solita/phantomrunner/util/Strings.java
// public class Strings {
//
// public static String firstMatch(String str, String regex) {
// Pattern p = Pattern.compile(regex);
// Matcher m = p.matcher(str);
// if (!m.find()) {
// throw new IllegalArgumentException("No match found for String: " + str);
// }
// return str.substring(m.start(), m.end());
// }
//
// public static List<String> splitTokens(String str, String regex) {
// return splitTokens(str, regex, 0);
// }
//
// public static List<String> splitTokens(String str, String regex, int flags) {
// Pattern p = Pattern.compile(regex, flags);
// Matcher m = p.matcher(str);
// List<String> result = new ArrayList<String>();
// while (m.find()) {
// result.add(m.group());
// }
// return result;
// }
//
// public static String indentLines(String str, int indentAmount) {
// StringBuilder builder = new StringBuilder();
// for (String line : str.split("\n")) {
// for (int i = 0; i < indentAmount; i++) {
// builder.append(' ');
// }
// builder.append(line);
// }
// return builder.toString();
// }
//
// public static String streamToString(InputStream stream) throws IOException {
// StringWriter writer = new StringWriter();
// IOUtil.copy(stream, writer, "UTF-8");
// return writer.toString();
// }
//
// public static List<String> stringList(String...str) {
// return Arrays.asList(str);
// }
//
// public static List<String> stringList(String str, String... strs) {
// Builder<String> builder = ImmutableList.builder();
// builder.add(str);
// builder.add(strs);
// return builder.build();
// }
// }
| import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import fi.solita.phantomrunner.stream.StreamPiper;
import fi.solita.phantomrunner.util.Strings;
| /**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
/**
* Class abstracting the PhantomJs process. Registers a shutdown hook for killing the process when JVM
* exits and provides a input stream piping to standard out.
*/
public class PhantomProcess {
private final String path;
private final Process phantomProcess;
public PhantomProcess(PhantomConfiguration config, String...jsFilePaths) {
this.path = config.phantomPath();
try {
this.phantomProcess = new ProcessBuilder(Strings.stringList(path, jsFilePaths)).start();
ExecutorService pool = Executors.newFixedThreadPool(2);
| // Path: src/main/java/fi/solita/phantomrunner/stream/StreamPiper.java
// public class StreamPiper implements Runnable {
//
// private final InputStream in;
// private final OutputStream out;
//
// public StreamPiper(InputStream in, OutputStream out) {
// this.in = in;
// this.out = out;
// }
//
// @Override
// public void run() {
// try {
// int read = -1;
// while ((read = in.read()) != -1) {
// out.write(read);
// }
// } catch (IOException ioe) {
// throw new RuntimeException(ioe);
// }
// }
// }
//
// Path: src/main/java/fi/solita/phantomrunner/util/Strings.java
// public class Strings {
//
// public static String firstMatch(String str, String regex) {
// Pattern p = Pattern.compile(regex);
// Matcher m = p.matcher(str);
// if (!m.find()) {
// throw new IllegalArgumentException("No match found for String: " + str);
// }
// return str.substring(m.start(), m.end());
// }
//
// public static List<String> splitTokens(String str, String regex) {
// return splitTokens(str, regex, 0);
// }
//
// public static List<String> splitTokens(String str, String regex, int flags) {
// Pattern p = Pattern.compile(regex, flags);
// Matcher m = p.matcher(str);
// List<String> result = new ArrayList<String>();
// while (m.find()) {
// result.add(m.group());
// }
// return result;
// }
//
// public static String indentLines(String str, int indentAmount) {
// StringBuilder builder = new StringBuilder();
// for (String line : str.split("\n")) {
// for (int i = 0; i < indentAmount; i++) {
// builder.append(' ');
// }
// builder.append(line);
// }
// return builder.toString();
// }
//
// public static String streamToString(InputStream stream) throws IOException {
// StringWriter writer = new StringWriter();
// IOUtil.copy(stream, writer, "UTF-8");
// return writer.toString();
// }
//
// public static List<String> stringList(String...str) {
// return Arrays.asList(str);
// }
//
// public static List<String> stringList(String str, String... strs) {
// Builder<String> builder = ImmutableList.builder();
// builder.add(str);
// builder.add(strs);
// return builder.build();
// }
// }
// Path: src/main/java/fi/solita/phantomrunner/PhantomProcess.java
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import fi.solita.phantomrunner.stream.StreamPiper;
import fi.solita.phantomrunner.util.Strings;
/**
* The MIT License (MIT)
*
* Copyright (c) 2012 Solita Oy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package fi.solita.phantomrunner;
/**
* Class abstracting the PhantomJs process. Registers a shutdown hook for killing the process when JVM
* exits and provides a input stream piping to standard out.
*/
public class PhantomProcess {
private final String path;
private final Process phantomProcess;
public PhantomProcess(PhantomConfiguration config, String...jsFilePaths) {
this.path = config.phantomPath();
try {
this.phantomProcess = new ProcessBuilder(Strings.stringList(path, jsFilePaths)).start();
ExecutorService pool = Executors.newFixedThreadPool(2);
| final Future<?> inFuture = pool.submit(new StreamPiper(this.phantomProcess.getInputStream(), System.out));
|
zhihu/mirror | app/src/main/java/com/zhihu/android/app/mirror/widget/ArtboardView.java | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/AnimUtils.java
// public class AnimUtils {
// public static final int DURATION = 300; // ms
//
// public static void showViewAlphaAnim(final View view, TimeInterpolator interpolator, final boolean visible) {
// if (visible && view.getVisibility() == View.VISIBLE
// || !visible && view.getVisibility() != View.VISIBLE) {
// return;
// }
//
// float fromAlpha = visible ? 0.0F : 1.0F;
// float toAlpha = visible ? 1.0F : 0.0F;
// view.setAlpha(fromAlpha);
// view.setVisibility(View.VISIBLE);
// view.animate().alpha(toAlpha)
// .setDuration(DURATION)
// .setInterpolator(interpolator)
// .setListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animator) {
// if (visible) {
// view.setAlpha(1.0F);
// view.setVisibility(View.VISIBLE);
// } else {
// view.setAlpha(0.0F);
// view.setVisibility(View.INVISIBLE);
// }
// }
// })
// .start();
// }
// }
//
// Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
| import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import java.math.BigDecimal;
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.AnimUtils;
import com.zhihu.android.app.mirror.util.DisplayUtils;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PointF;
import android.support.annotation.NonNull;
import android.support.v4.view.animation.PathInterpolatorCompat;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View; | /*
* Mirror - Yet another Sketch Mirror App for Android.
* Copyright (C) 2016 Zhihu Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.zhihu.android.app.mirror.widget;
// https://github.com/nickbutcher/plaid/blob/master/app/src/main/java/io/plaidapp/ui/widget/ElasticDragDismissFrameLayout.java
public class ArtboardView extends SubsamplingScaleImageView implements View.OnTouchListener {
public interface ArtboardViewCallback {
void onDrag(ArtboardView view, float dragDismissDistance, float dragTo);
void onDragDismiss(ArtboardView view, boolean isDragDown);
}
private float mDragDismissDistance;
private float mDragElacticity;
private ObjectAnimator mTransYAnim;
private float mActionDownY;
private float mDragDistance;
private boolean mIsDragDown; // drag direction to screen bottom
private ArtboardViewCallback mCallback;
private GestureDetector mGestureDetector;
public ArtboardView(Context context) {
super(context);
init(null);
}
public ArtboardView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
private void init(AttributeSet attrs) { | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/AnimUtils.java
// public class AnimUtils {
// public static final int DURATION = 300; // ms
//
// public static void showViewAlphaAnim(final View view, TimeInterpolator interpolator, final boolean visible) {
// if (visible && view.getVisibility() == View.VISIBLE
// || !visible && view.getVisibility() != View.VISIBLE) {
// return;
// }
//
// float fromAlpha = visible ? 0.0F : 1.0F;
// float toAlpha = visible ? 1.0F : 0.0F;
// view.setAlpha(fromAlpha);
// view.setVisibility(View.VISIBLE);
// view.animate().alpha(toAlpha)
// .setDuration(DURATION)
// .setInterpolator(interpolator)
// .setListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animator) {
// if (visible) {
// view.setAlpha(1.0F);
// view.setVisibility(View.VISIBLE);
// } else {
// view.setAlpha(0.0F);
// view.setVisibility(View.INVISIBLE);
// }
// }
// })
// .start();
// }
// }
//
// Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
// Path: app/src/main/java/com/zhihu/android/app/mirror/widget/ArtboardView.java
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import java.math.BigDecimal;
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.AnimUtils;
import com.zhihu.android.app.mirror.util.DisplayUtils;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PointF;
import android.support.annotation.NonNull;
import android.support.v4.view.animation.PathInterpolatorCompat;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
/*
* Mirror - Yet another Sketch Mirror App for Android.
* Copyright (C) 2016 Zhihu Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.zhihu.android.app.mirror.widget;
// https://github.com/nickbutcher/plaid/blob/master/app/src/main/java/io/plaidapp/ui/widget/ElasticDragDismissFrameLayout.java
public class ArtboardView extends SubsamplingScaleImageView implements View.OnTouchListener {
public interface ArtboardViewCallback {
void onDrag(ArtboardView view, float dragDismissDistance, float dragTo);
void onDragDismiss(ArtboardView view, boolean isDragDown);
}
private float mDragDismissDistance;
private float mDragElacticity;
private ObjectAnimator mTransYAnim;
private float mActionDownY;
private float mDragDistance;
private boolean mIsDragDown; // drag direction to screen bottom
private ArtboardViewCallback mCallback;
private GestureDetector mGestureDetector;
public ArtboardView(Context context) {
super(context);
init(null);
}
public ArtboardView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
private void init(AttributeSet attrs) { | mDragDismissDistance = DisplayUtils.dp2px(getContext(), 112.0F); |
zhihu/mirror | app/src/main/java/com/zhihu/android/app/mirror/widget/ArtboardView.java | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/AnimUtils.java
// public class AnimUtils {
// public static final int DURATION = 300; // ms
//
// public static void showViewAlphaAnim(final View view, TimeInterpolator interpolator, final boolean visible) {
// if (visible && view.getVisibility() == View.VISIBLE
// || !visible && view.getVisibility() != View.VISIBLE) {
// return;
// }
//
// float fromAlpha = visible ? 0.0F : 1.0F;
// float toAlpha = visible ? 1.0F : 0.0F;
// view.setAlpha(fromAlpha);
// view.setVisibility(View.VISIBLE);
// view.animate().alpha(toAlpha)
// .setDuration(DURATION)
// .setInterpolator(interpolator)
// .setListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animator) {
// if (visible) {
// view.setAlpha(1.0F);
// view.setVisibility(View.VISIBLE);
// } else {
// view.setAlpha(0.0F);
// view.setVisibility(View.INVISIBLE);
// }
// }
// })
// .start();
// }
// }
//
// Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
| import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import java.math.BigDecimal;
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.AnimUtils;
import com.zhihu.android.app.mirror.util.DisplayUtils;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PointF;
import android.support.annotation.NonNull;
import android.support.v4.view.animation.PathInterpolatorCompat;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View; | mDragElacticity = array.getFloat(R.styleable.ArtboardView_avDragElasticity, mDragElacticity);
array.recycle();
}
mGestureDetector = new GestureDetector(getContext(), buildSimpleOnGestureListener());
setOnTouchListener(this);
}
// always scale to the screen width side
private GestureDetector.SimpleOnGestureListener buildSimpleOnGestureListener() {
return new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent event) {
if (!isReady()) {
return true;
}
float scale;
float screenWidth = DisplayUtils.getScreenWidth(getContext());
if (getSWidth() >= getSHeight()) {
if (getSWidth() >= screenWidth) {
scale = getMinScale();
} else {
scale = screenWidth / (float) getSWidth();
}
} else {
scale = screenWidth / (float) getSWidth();
}
animateScaleAndCenter(!isScaling() ? scale : getMinScale(), new PointF(event.getX(), event.getY())) | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/AnimUtils.java
// public class AnimUtils {
// public static final int DURATION = 300; // ms
//
// public static void showViewAlphaAnim(final View view, TimeInterpolator interpolator, final boolean visible) {
// if (visible && view.getVisibility() == View.VISIBLE
// || !visible && view.getVisibility() != View.VISIBLE) {
// return;
// }
//
// float fromAlpha = visible ? 0.0F : 1.0F;
// float toAlpha = visible ? 1.0F : 0.0F;
// view.setAlpha(fromAlpha);
// view.setVisibility(View.VISIBLE);
// view.animate().alpha(toAlpha)
// .setDuration(DURATION)
// .setInterpolator(interpolator)
// .setListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animator) {
// if (visible) {
// view.setAlpha(1.0F);
// view.setVisibility(View.VISIBLE);
// } else {
// view.setAlpha(0.0F);
// view.setVisibility(View.INVISIBLE);
// }
// }
// })
// .start();
// }
// }
//
// Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
// Path: app/src/main/java/com/zhihu/android/app/mirror/widget/ArtboardView.java
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import java.math.BigDecimal;
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.AnimUtils;
import com.zhihu.android.app.mirror.util.DisplayUtils;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PointF;
import android.support.annotation.NonNull;
import android.support.v4.view.animation.PathInterpolatorCompat;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
mDragElacticity = array.getFloat(R.styleable.ArtboardView_avDragElasticity, mDragElacticity);
array.recycle();
}
mGestureDetector = new GestureDetector(getContext(), buildSimpleOnGestureListener());
setOnTouchListener(this);
}
// always scale to the screen width side
private GestureDetector.SimpleOnGestureListener buildSimpleOnGestureListener() {
return new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent event) {
if (!isReady()) {
return true;
}
float scale;
float screenWidth = DisplayUtils.getScreenWidth(getContext());
if (getSWidth() >= getSHeight()) {
if (getSWidth() >= screenWidth) {
scale = getMinScale();
} else {
scale = screenWidth / (float) getSWidth();
}
} else {
scale = screenWidth / (float) getSWidth();
}
animateScaleAndCenter(!isScaling() ? scale : getMinScale(), new PointF(event.getX(), event.getY())) | .withDuration(AnimUtils.DURATION) |
zhihu/mirror | app/src/main/java/com/zhihu/android/app/mirror/widget/ConnectStatusLayout.java | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
| import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.DisplayUtils;
import android.content.Context;
import android.support.annotation.IntDef;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; |
public ConnectStatusLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ConnectStatusLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setConnectStatus(@ConnectStatus int status, String tmpl) {
switch (status) {
case CONNECTED:
mPointView.stopBreath();
mMessageView.setText(getResources().getString(R.string.connect_status_connected, tmpl));
break;
case DISCONNECTED:
mPointView.startBreath();
mMessageView.setText(getResources().getString(R.string.connect_status_disconnected, tmpl));
break;
case CONNECTING:
default:
mPointView.startBreath();
mMessageView.setText(getResources().getString(R.string.connect_status_connecting, tmpl));
break;
}
}
@Override
public void onFinishInflate() {
super.onFinishInflate(); | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
// Path: app/src/main/java/com/zhihu/android/app/mirror/widget/ConnectStatusLayout.java
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.DisplayUtils;
import android.content.Context;
import android.support.annotation.IntDef;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
public ConnectStatusLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ConnectStatusLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setConnectStatus(@ConnectStatus int status, String tmpl) {
switch (status) {
case CONNECTED:
mPointView.stopBreath();
mMessageView.setText(getResources().getString(R.string.connect_status_connected, tmpl));
break;
case DISCONNECTED:
mPointView.startBreath();
mMessageView.setText(getResources().getString(R.string.connect_status_disconnected, tmpl));
break;
case CONNECTING:
default:
mPointView.startBreath();
mMessageView.setText(getResources().getString(R.string.connect_status_connecting, tmpl));
break;
}
}
@Override
public void onFinishInflate() {
super.onFinishInflate(); | ((FrameLayout.LayoutParams) getLayoutParams()).topMargin = DisplayUtils.getStatusBarHeight(getContext()); |
zhihu/mirror | app/src/main/java/com/zhihu/android/app/mirror/widget/MirrorNameView.java | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
| import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.DecelerateInterpolator;
import com.zhihu.android.app.mirror.util.DisplayUtils; | /*
* Mirror - Yet another Sketch Mirror App for Android.
* Copyright (C) 2016 Zhihu Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.zhihu.android.app.mirror.widget;
public class MirrorNameView extends AppCompatTextView {
private static final float ALPHA_TO = 0.87F;
private static final float SCALE_TO = 0.99F;
private static final long DURATION = 100L;
public MirrorNameView(Context context) {
super(context);
}
public MirrorNameView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MirrorNameView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate(); | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
// Path: app/src/main/java/com/zhihu/android/app/mirror/widget/MirrorNameView.java
import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.DecelerateInterpolator;
import com.zhihu.android.app.mirror.util.DisplayUtils;
/*
* Mirror - Yet another Sketch Mirror App for Android.
* Copyright (C) 2016 Zhihu Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.zhihu.android.app.mirror.widget;
public class MirrorNameView extends AppCompatTextView {
private static final float ALPHA_TO = 0.87F;
private static final float SCALE_TO = 0.99F;
private static final long DURATION = 100L;
public MirrorNameView(Context context) {
super(context);
}
public MirrorNameView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MirrorNameView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate(); | setMinWidth(DisplayUtils.getScreenWidth(getContext())); |
zhihu/mirror | app/src/main/java/com/zhihu/android/app/mirror/widget/DownsamplingView.java | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
| import android.content.Context;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.DecelerateInterpolator;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.view.SimpleDraweeView;
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.DisplayUtils; | /*
* Mirror - Yet another Sketch Mirror App for Android.
* Copyright (C) 2016 Zhihu Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.zhihu.android.app.mirror.widget;
public class DownsamplingView extends SimpleDraweeView {
private static final float W_H_RATIO = 1.0F;
private static final int FADE_DURATION = 300;
private static final float ALPHA_TO = 0.87F;
private static final float SCALE_TO = 0.99F;
private static final long DURATION = 100L;
private int mDownsamplingViewWidth;
private int mDownsamplingViewHeight;
public DownsamplingView(Context context) {
super(context);
}
public DownsamplingView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public DownsamplingView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public int getDownsamplingViewWidth() {
return mDownsamplingViewWidth;
}
public int getDownsamplingViewHeight() {
return mDownsamplingViewHeight;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
int gridSpanCount = getResources().getInteger(R.integer.grid_span_count); | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
// Path: app/src/main/java/com/zhihu/android/app/mirror/widget/DownsamplingView.java
import android.content.Context;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.DecelerateInterpolator;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.view.SimpleDraweeView;
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.DisplayUtils;
/*
* Mirror - Yet another Sketch Mirror App for Android.
* Copyright (C) 2016 Zhihu Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.zhihu.android.app.mirror.widget;
public class DownsamplingView extends SimpleDraweeView {
private static final float W_H_RATIO = 1.0F;
private static final int FADE_DURATION = 300;
private static final float ALPHA_TO = 0.87F;
private static final float SCALE_TO = 0.99F;
private static final long DURATION = 100L;
private int mDownsamplingViewWidth;
private int mDownsamplingViewHeight;
public DownsamplingView(Context context) {
super(context);
}
public DownsamplingView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public DownsamplingView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public int getDownsamplingViewWidth() {
return mDownsamplingViewWidth;
}
public int getDownsamplingViewHeight() {
return mDownsamplingViewHeight;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
int gridSpanCount = getResources().getInteger(R.integer.grid_span_count); | float width = DisplayUtils.getScreenWidth(getContext()) / gridSpanCount; |
zhihu/mirror | app/src/main/java/com/zhihu/android/app/mirror/widget/PointView.java | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
| import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.DisplayUtils; | /*
* Mirror - Yet another Sketch Mirror App for Android.
* Copyright (C) 2016 Zhihu Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.zhihu.android.app.mirror.widget;
public class PointView extends View {
private Paint mPaint;
private int mAlpha;
private int mRadius;
private float mCurrentAlpha;
private float mDeltaFraction;
private long mPreDrawTime;
private boolean mIsRunning;
private boolean mIsReverse;
public PointView(Context context) {
super(context);
init(null);
}
public PointView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
public PointView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(attrs);
}
private void init(AttributeSet attrs) {
mAlpha = 255; | // Path: app/src/main/java/com/zhihu/android/app/mirror/util/DisplayUtils.java
// public class DisplayUtils {
// public static float getScreenDensity(Context context) {
// return context.getResources().getDisplayMetrics().density;
// }
//
// public static int getScreenWidth(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.x;
// }
//
// public static int getScreenHeight(Context context) {
// WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Display display = manager.getDefaultDisplay();
// Point point = new Point();
// display.getSize(point);
// return point.y;
// }
//
// public static int getStatusBarHeight(Context context) {
// int statusBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return statusBarHeight;
// }
//
// public static int getNavigationBarHeight(Context context) {
// int navigationBarHeight = 0;
//
// int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
// if (resourceId > 0) {
// navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
// }
//
// return navigationBarHeight;
// }
//
// public static int dp2px(Context context, float dp) {
// return (int) (getScreenDensity(context) * dp + 0.5F);
// }
//
// public static int sp2px(Context context, float sp) {
// return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp + 0.5F);
// }
//
// public static void requestImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// }
//
// public static void clearImmersiveStickyMode(Activity activity) {
// activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// }
// }
// Path: app/src/main/java/com/zhihu/android/app/mirror/widget/PointView.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import com.zhihu.android.app.mirror.R;
import com.zhihu.android.app.mirror.util.DisplayUtils;
/*
* Mirror - Yet another Sketch Mirror App for Android.
* Copyright (C) 2016 Zhihu Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.zhihu.android.app.mirror.widget;
public class PointView extends View {
private Paint mPaint;
private int mAlpha;
private int mRadius;
private float mCurrentAlpha;
private float mDeltaFraction;
private long mPreDrawTime;
private boolean mIsRunning;
private boolean mIsReverse;
public PointView(Context context) {
super(context);
init(null);
}
public PointView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
public PointView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(attrs);
}
private void init(AttributeSet attrs) {
mAlpha = 255; | mRadius = DisplayUtils.dp2px(getContext(), 8.0F); |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/wizards/project/ProjectSupport.java | // Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/ui/nature/Nature.java
// public class Nature implements IProjectNature {
//
// /**
// * ID of this project nature
// */
// public static final String NATURE_ID = "org.cfeclipse.cfmledit.ui.nature";
//
// private IProject project;
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#configure()
// */
// public void configure() throws CoreException {
// IProjectDescription desc = project.getDescription();
// ICommand[] commands = desc.getBuildSpec();
//
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) {
// return;
// }
// }
//
// ICommand[] newCommands = new ICommand[commands.length + 1];
// System.arraycopy(commands, 0, newCommands, 0, commands.length);
// ICommand command = desc.newCommand();
// command.setBuilderName(ComponentBuilder.BUILDER_ID);
// newCommands[newCommands.length - 1] = command;
// desc.setBuildSpec(newCommands);
// project.setDescription(desc, null);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#deconfigure()
// */
// public void deconfigure() throws CoreException {
// IProjectDescription description = getProject().getDescription();
// ICommand[] commands = description.getBuildSpec();
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) {
// ICommand[] newCommands = new ICommand[commands.length - 1];
// System.arraycopy(commands, 0, newCommands, 0, i);
// System.arraycopy(commands, i + 1, newCommands, i,
// commands.length - i - 1);
// description.setBuildSpec(newCommands);
// project.setDescription(description, null);
// return;
// }
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#getProject()
// */
// public IProject getProject() {
// return project;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
// */
// public void setProject(IProject project) {
// this.project = project;
// }
//
// }
| import java.net.URI;
import org.cfeclipse.cfmledit.ui.nature.Nature;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; | package org.cfeclipse.cfmledit.wizards.project;
public class ProjectSupport {
public static IProject createProject(String projectName, URI location){
Assert.isNotNull(projectName);
Assert.isTrue(projectName.trim().length() > 0);
IProject project = createBaseProject(projectName, location);
try {
addNature(project);
} catch (CoreException e) {
e.printStackTrace();
project = null;
}
return project;
}
private static void addNature(IProject project) throws CoreException {
| // Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/ui/nature/Nature.java
// public class Nature implements IProjectNature {
//
// /**
// * ID of this project nature
// */
// public static final String NATURE_ID = "org.cfeclipse.cfmledit.ui.nature";
//
// private IProject project;
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#configure()
// */
// public void configure() throws CoreException {
// IProjectDescription desc = project.getDescription();
// ICommand[] commands = desc.getBuildSpec();
//
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) {
// return;
// }
// }
//
// ICommand[] newCommands = new ICommand[commands.length + 1];
// System.arraycopy(commands, 0, newCommands, 0, commands.length);
// ICommand command = desc.newCommand();
// command.setBuilderName(ComponentBuilder.BUILDER_ID);
// newCommands[newCommands.length - 1] = command;
// desc.setBuildSpec(newCommands);
// project.setDescription(desc, null);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#deconfigure()
// */
// public void deconfigure() throws CoreException {
// IProjectDescription description = getProject().getDescription();
// ICommand[] commands = description.getBuildSpec();
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) {
// ICommand[] newCommands = new ICommand[commands.length - 1];
// System.arraycopy(commands, 0, newCommands, 0, i);
// System.arraycopy(commands, i + 1, newCommands, i,
// commands.length - i - 1);
// description.setBuildSpec(newCommands);
// project.setDescription(description, null);
// return;
// }
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#getProject()
// */
// public IProject getProject() {
// return project;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
// */
// public void setProject(IProject project) {
// this.project = project;
// }
//
// }
// Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/wizards/project/ProjectSupport.java
import java.net.URI;
import org.cfeclipse.cfmledit.ui.nature.Nature;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
package org.cfeclipse.cfmledit.wizards.project;
public class ProjectSupport {
public static IProject createProject(String projectName, URI location){
Assert.isNotNull(projectName);
Assert.isTrue(projectName.trim().length() > 0);
IProject project = createBaseProject(projectName, location);
try {
addNature(project);
} catch (CoreException e) {
e.printStackTrace();
project = null;
}
return project;
}
private static void addNature(IProject project) throws CoreException {
| if(!project.hasNature(Nature.NATURE_ID)){ |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/ui/nature/Nature.java | // Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/ui/builder/ComponentBuilder.java
// public class ComponentBuilder extends IncrementalProjectBuilder {
//
// class SampleDeltaVisitor implements IResourceDeltaVisitor {
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
// */
// public boolean visit(IResourceDelta delta) throws CoreException {
// IResource resource = delta.getResource();
// switch (delta.getKind()) {
// case IResourceDelta.ADDED:
// // handle added resource
// checkXML(resource);
// break;
// case IResourceDelta.REMOVED:
// // handle removed resource
// break;
// case IResourceDelta.CHANGED:
// // handle changed resource
// checkXML(resource);
// break;
// }
// //return true to continue visiting children.
// return true;
// }
// }
//
// class SampleResourceVisitor implements IResourceVisitor {
// public boolean visit(IResource resource) {
// checkXML(resource);
// //return true to continue visiting children.
// return true;
// }
// }
//
// class XMLErrorHandler extends DefaultHandler {
//
// private IFile file;
//
// public XMLErrorHandler(IFile file) {
// this.file = file;
// }
//
// private void addMarker(SAXParseException e, int severity) {
// ComponentBuilder.this.addMarker(file, e.getMessage(), e
// .getLineNumber(), severity);
// }
//
// public void error(SAXParseException exception) throws SAXException {
// addMarker(exception, IMarker.SEVERITY_ERROR);
// }
//
// public void fatalError(SAXParseException exception) throws SAXException {
// addMarker(exception, IMarker.SEVERITY_ERROR);
// }
//
// public void warning(SAXParseException exception) throws SAXException {
// addMarker(exception, IMarker.SEVERITY_WARNING);
// }
// }
//
// public static final String BUILDER_ID = "org.cfeclipse.cfmledit.builders.component";
//
// private static final String MARKER_TYPE = "org.cfeclipse.cfmledit.ui.wizards.project.xmlProblem";
//
// private SAXParserFactory parserFactory;
//
// private void addMarker(IFile file, String message, int lineNumber,
// int severity) {
// try {
// IMarker marker = file.createMarker(MARKER_TYPE);
// marker.setAttribute(IMarker.MESSAGE, message);
// marker.setAttribute(IMarker.SEVERITY, severity);
// if (lineNumber == -1) {
// lineNumber = 1;
// }
// marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
// } catch (CoreException e) {
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.internal.events.InternalBuilder#build(int,
// * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
// */
// protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
// throws CoreException {
// if (kind == FULL_BUILD) {
// fullBuild(monitor);
// } else {
// IResourceDelta delta = getDelta(getProject());
// if (delta == null) {
// fullBuild(monitor);
// } else {
// incrementalBuild(delta, monitor);
// }
// }
// return null;
// }
//
// void checkXML(IResource resource) {
// if (resource instanceof IFile && resource.getName().endsWith(".xml")) {
// IFile file = (IFile) resource;
// deleteMarkers(file);
// XMLErrorHandler reporter = new XMLErrorHandler(file);
// try {
// getParser().parse(file.getContents(), reporter);
// } catch (Exception e1) {
// }
// }
// }
//
// private void deleteMarkers(IFile file) {
// try {
// file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO);
// } catch (CoreException ce) {
// }
// }
//
// protected void fullBuild(final IProgressMonitor monitor)
// throws CoreException {
// try {
// getProject().accept(new SampleResourceVisitor());
// } catch (CoreException e) {
// }
// }
//
// private SAXParser getParser() throws ParserConfigurationException,
// SAXException {
// if (parserFactory == null) {
// parserFactory = SAXParserFactory.newInstance();
// }
// return parserFactory.newSAXParser();
// }
//
// protected void incrementalBuild(IResourceDelta delta,
// IProgressMonitor monitor) throws CoreException {
// // the visitor does the work.
// delta.accept(new SampleDeltaVisitor());
// }
// }
| import org.cfeclipse.cfmledit.ui.builder.ComponentBuilder;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException; | package org.cfeclipse.cfmledit.ui.nature;
public class Nature implements IProjectNature {
/**
* ID of this project nature
*/
public static final String NATURE_ID = "org.cfeclipse.cfmledit.ui.nature";
private IProject project;
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i) { | // Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/ui/builder/ComponentBuilder.java
// public class ComponentBuilder extends IncrementalProjectBuilder {
//
// class SampleDeltaVisitor implements IResourceDeltaVisitor {
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
// */
// public boolean visit(IResourceDelta delta) throws CoreException {
// IResource resource = delta.getResource();
// switch (delta.getKind()) {
// case IResourceDelta.ADDED:
// // handle added resource
// checkXML(resource);
// break;
// case IResourceDelta.REMOVED:
// // handle removed resource
// break;
// case IResourceDelta.CHANGED:
// // handle changed resource
// checkXML(resource);
// break;
// }
// //return true to continue visiting children.
// return true;
// }
// }
//
// class SampleResourceVisitor implements IResourceVisitor {
// public boolean visit(IResource resource) {
// checkXML(resource);
// //return true to continue visiting children.
// return true;
// }
// }
//
// class XMLErrorHandler extends DefaultHandler {
//
// private IFile file;
//
// public XMLErrorHandler(IFile file) {
// this.file = file;
// }
//
// private void addMarker(SAXParseException e, int severity) {
// ComponentBuilder.this.addMarker(file, e.getMessage(), e
// .getLineNumber(), severity);
// }
//
// public void error(SAXParseException exception) throws SAXException {
// addMarker(exception, IMarker.SEVERITY_ERROR);
// }
//
// public void fatalError(SAXParseException exception) throws SAXException {
// addMarker(exception, IMarker.SEVERITY_ERROR);
// }
//
// public void warning(SAXParseException exception) throws SAXException {
// addMarker(exception, IMarker.SEVERITY_WARNING);
// }
// }
//
// public static final String BUILDER_ID = "org.cfeclipse.cfmledit.builders.component";
//
// private static final String MARKER_TYPE = "org.cfeclipse.cfmledit.ui.wizards.project.xmlProblem";
//
// private SAXParserFactory parserFactory;
//
// private void addMarker(IFile file, String message, int lineNumber,
// int severity) {
// try {
// IMarker marker = file.createMarker(MARKER_TYPE);
// marker.setAttribute(IMarker.MESSAGE, message);
// marker.setAttribute(IMarker.SEVERITY, severity);
// if (lineNumber == -1) {
// lineNumber = 1;
// }
// marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
// } catch (CoreException e) {
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.internal.events.InternalBuilder#build(int,
// * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
// */
// protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
// throws CoreException {
// if (kind == FULL_BUILD) {
// fullBuild(monitor);
// } else {
// IResourceDelta delta = getDelta(getProject());
// if (delta == null) {
// fullBuild(monitor);
// } else {
// incrementalBuild(delta, monitor);
// }
// }
// return null;
// }
//
// void checkXML(IResource resource) {
// if (resource instanceof IFile && resource.getName().endsWith(".xml")) {
// IFile file = (IFile) resource;
// deleteMarkers(file);
// XMLErrorHandler reporter = new XMLErrorHandler(file);
// try {
// getParser().parse(file.getContents(), reporter);
// } catch (Exception e1) {
// }
// }
// }
//
// private void deleteMarkers(IFile file) {
// try {
// file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO);
// } catch (CoreException ce) {
// }
// }
//
// protected void fullBuild(final IProgressMonitor monitor)
// throws CoreException {
// try {
// getProject().accept(new SampleResourceVisitor());
// } catch (CoreException e) {
// }
// }
//
// private SAXParser getParser() throws ParserConfigurationException,
// SAXException {
// if (parserFactory == null) {
// parserFactory = SAXParserFactory.newInstance();
// }
// return parserFactory.newSAXParser();
// }
//
// protected void incrementalBuild(IResourceDelta delta,
// IProgressMonitor monitor) throws CoreException {
// // the visitor does the work.
// delta.accept(new SampleDeltaVisitor());
// }
// }
// Path: org.cfeclipse.cfmledit.wizards.project/src/org/cfeclipse/cfmledit/ui/nature/Nature.java
import org.cfeclipse.cfmledit.ui.builder.ComponentBuilder;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
package org.cfeclipse.cfmledit.ui.nature;
public class Nature implements IProjectNature {
/**
* ID of this project nature
*/
public static final String NATURE_ID = "org.cfeclipse.cfmledit.ui.nature";
private IProject project;
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i) { | if (commands[i].getBuilderName().equals(ComponentBuilder.BUILDER_ID)) { |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.tests/src/org/cfeclipse/cfmledit/tests/dictionary/DictionaryTest.java | // Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Dictionary.java
// public class Dictionary {
//
// //Myself
// public static Dictionary instance = null;
// //Lightweight listing of server versions
// public static ArrayList<Version> versions = new ArrayList<Version>();
//
// protected Dictionary() throws Exception{
// parseDictionaryConfig(); //No need to lazy load, it's a small XML file and in theory there only will be one dictionary per plugin
// }
//
// public static Dictionary getInstance() throws Exception {
//
// if(instance == null){
// instance = new Dictionary();
// }
// return instance;
// }
//
// private void parseDictionaryConfig() throws Exception {
// // Get the file and set the names in the dictionaryconfig.xml
// Bundle bundle = DictionaryActivator.getBundle();
// URL eclipsePath = FileLocator.find(bundle, new Path("dictionary/dictionaryconfig.xml"),null);
// URL filePath = FileLocator.toFileURL(eclipsePath);
//
// SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(filePath);
// Element cfmlversions = (Element)doc.getRootElement().getChildren().get(0);
//
// if(!cfmlversions.getAttributeValue("id").equalsIgnoreCase("CF_DICTIONARY")){
// throw new Exception("CFML Dictionary information not found");
// }
// loadVersions(cfmlversions);
// }
//
// private void loadVersions(Element cfmlversions) throws IOException,
// JDOMException {
// List<Element> versions = cfmlversions.getChildren();
// for (Element vers : versions) {
// Version version = new Version(vers.getAttributeValue("key"), vers.getAttributeValue("label"));
// List<Element> grammars = vers.getChildren();
// for (Element gramr : grammars) {
// Grammar gram = new Grammar(gramr.getAttributeValue("location"));
// version.addGrammar(gram);
// }
// this.versions.add(version);
// }
// }
//
// public ArrayList<Version> getVersions() throws Exception {
// return versions;
// }
//
//
//
//
// }
//
// Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Version.java
// public class Version {
// private String label = "";
// private String key = "";
// private ArrayList<Grammar> grammars = new ArrayList<Grammar>();
// public Version(String key, String label) {
// this.key = key;
// this.label = label;
// }
//
// public void addGrammar(Grammar gram) {
// grammars.add(gram);
// }
//
//
//
// }
| import static org.junit.Assert.*;
import java.util.ArrayList;
import org.cfeclipse.cfmledit.dictionary.Dictionary;
import org.cfeclipse.cfmledit.dictionary.Version;
import org.junit.Test; | package org.cfeclipse.cfmledit.tests.dictionary;
public class DictionaryTest {
public void startup(){
}
@Test
public void TestIsSingleton() {
try{ | // Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Dictionary.java
// public class Dictionary {
//
// //Myself
// public static Dictionary instance = null;
// //Lightweight listing of server versions
// public static ArrayList<Version> versions = new ArrayList<Version>();
//
// protected Dictionary() throws Exception{
// parseDictionaryConfig(); //No need to lazy load, it's a small XML file and in theory there only will be one dictionary per plugin
// }
//
// public static Dictionary getInstance() throws Exception {
//
// if(instance == null){
// instance = new Dictionary();
// }
// return instance;
// }
//
// private void parseDictionaryConfig() throws Exception {
// // Get the file and set the names in the dictionaryconfig.xml
// Bundle bundle = DictionaryActivator.getBundle();
// URL eclipsePath = FileLocator.find(bundle, new Path("dictionary/dictionaryconfig.xml"),null);
// URL filePath = FileLocator.toFileURL(eclipsePath);
//
// SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(filePath);
// Element cfmlversions = (Element)doc.getRootElement().getChildren().get(0);
//
// if(!cfmlversions.getAttributeValue("id").equalsIgnoreCase("CF_DICTIONARY")){
// throw new Exception("CFML Dictionary information not found");
// }
// loadVersions(cfmlversions);
// }
//
// private void loadVersions(Element cfmlversions) throws IOException,
// JDOMException {
// List<Element> versions = cfmlversions.getChildren();
// for (Element vers : versions) {
// Version version = new Version(vers.getAttributeValue("key"), vers.getAttributeValue("label"));
// List<Element> grammars = vers.getChildren();
// for (Element gramr : grammars) {
// Grammar gram = new Grammar(gramr.getAttributeValue("location"));
// version.addGrammar(gram);
// }
// this.versions.add(version);
// }
// }
//
// public ArrayList<Version> getVersions() throws Exception {
// return versions;
// }
//
//
//
//
// }
//
// Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Version.java
// public class Version {
// private String label = "";
// private String key = "";
// private ArrayList<Grammar> grammars = new ArrayList<Grammar>();
// public Version(String key, String label) {
// this.key = key;
// this.label = label;
// }
//
// public void addGrammar(Grammar gram) {
// grammars.add(gram);
// }
//
//
//
// }
// Path: org.cfeclipse.cfmledit.tests/src/org/cfeclipse/cfmledit/tests/dictionary/DictionaryTest.java
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.cfeclipse.cfmledit.dictionary.Dictionary;
import org.cfeclipse.cfmledit.dictionary.Version;
import org.junit.Test;
package org.cfeclipse.cfmledit.tests.dictionary;
public class DictionaryTest {
public void startup(){
}
@Test
public void TestIsSingleton() {
try{ | Dictionary dic1 = Dictionary.getInstance(); |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.tests/src/org/cfeclipse/cfmledit/tests/dictionary/DictionaryTest.java | // Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Dictionary.java
// public class Dictionary {
//
// //Myself
// public static Dictionary instance = null;
// //Lightweight listing of server versions
// public static ArrayList<Version> versions = new ArrayList<Version>();
//
// protected Dictionary() throws Exception{
// parseDictionaryConfig(); //No need to lazy load, it's a small XML file and in theory there only will be one dictionary per plugin
// }
//
// public static Dictionary getInstance() throws Exception {
//
// if(instance == null){
// instance = new Dictionary();
// }
// return instance;
// }
//
// private void parseDictionaryConfig() throws Exception {
// // Get the file and set the names in the dictionaryconfig.xml
// Bundle bundle = DictionaryActivator.getBundle();
// URL eclipsePath = FileLocator.find(bundle, new Path("dictionary/dictionaryconfig.xml"),null);
// URL filePath = FileLocator.toFileURL(eclipsePath);
//
// SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(filePath);
// Element cfmlversions = (Element)doc.getRootElement().getChildren().get(0);
//
// if(!cfmlversions.getAttributeValue("id").equalsIgnoreCase("CF_DICTIONARY")){
// throw new Exception("CFML Dictionary information not found");
// }
// loadVersions(cfmlversions);
// }
//
// private void loadVersions(Element cfmlversions) throws IOException,
// JDOMException {
// List<Element> versions = cfmlversions.getChildren();
// for (Element vers : versions) {
// Version version = new Version(vers.getAttributeValue("key"), vers.getAttributeValue("label"));
// List<Element> grammars = vers.getChildren();
// for (Element gramr : grammars) {
// Grammar gram = new Grammar(gramr.getAttributeValue("location"));
// version.addGrammar(gram);
// }
// this.versions.add(version);
// }
// }
//
// public ArrayList<Version> getVersions() throws Exception {
// return versions;
// }
//
//
//
//
// }
//
// Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Version.java
// public class Version {
// private String label = "";
// private String key = "";
// private ArrayList<Grammar> grammars = new ArrayList<Grammar>();
// public Version(String key, String label) {
// this.key = key;
// this.label = label;
// }
//
// public void addGrammar(Grammar gram) {
// grammars.add(gram);
// }
//
//
//
// }
| import static org.junit.Assert.*;
import java.util.ArrayList;
import org.cfeclipse.cfmledit.dictionary.Dictionary;
import org.cfeclipse.cfmledit.dictionary.Version;
import org.junit.Test; | package org.cfeclipse.cfmledit.tests.dictionary;
public class DictionaryTest {
public void startup(){
}
@Test
public void TestIsSingleton() {
try{
Dictionary dic1 = Dictionary.getInstance();
Dictionary dic2 = Dictionary.getInstance();
assertEquals(dic1, dic2);
}
catch(Exception e){
e.printStackTrace();
}
}
@Test
public void TestLoadDictionary() throws Exception{
Dictionary dict = Dictionary.getInstance(); | // Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Dictionary.java
// public class Dictionary {
//
// //Myself
// public static Dictionary instance = null;
// //Lightweight listing of server versions
// public static ArrayList<Version> versions = new ArrayList<Version>();
//
// protected Dictionary() throws Exception{
// parseDictionaryConfig(); //No need to lazy load, it's a small XML file and in theory there only will be one dictionary per plugin
// }
//
// public static Dictionary getInstance() throws Exception {
//
// if(instance == null){
// instance = new Dictionary();
// }
// return instance;
// }
//
// private void parseDictionaryConfig() throws Exception {
// // Get the file and set the names in the dictionaryconfig.xml
// Bundle bundle = DictionaryActivator.getBundle();
// URL eclipsePath = FileLocator.find(bundle, new Path("dictionary/dictionaryconfig.xml"),null);
// URL filePath = FileLocator.toFileURL(eclipsePath);
//
// SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(filePath);
// Element cfmlversions = (Element)doc.getRootElement().getChildren().get(0);
//
// if(!cfmlversions.getAttributeValue("id").equalsIgnoreCase("CF_DICTIONARY")){
// throw new Exception("CFML Dictionary information not found");
// }
// loadVersions(cfmlversions);
// }
//
// private void loadVersions(Element cfmlversions) throws IOException,
// JDOMException {
// List<Element> versions = cfmlversions.getChildren();
// for (Element vers : versions) {
// Version version = new Version(vers.getAttributeValue("key"), vers.getAttributeValue("label"));
// List<Element> grammars = vers.getChildren();
// for (Element gramr : grammars) {
// Grammar gram = new Grammar(gramr.getAttributeValue("location"));
// version.addGrammar(gram);
// }
// this.versions.add(version);
// }
// }
//
// public ArrayList<Version> getVersions() throws Exception {
// return versions;
// }
//
//
//
//
// }
//
// Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Version.java
// public class Version {
// private String label = "";
// private String key = "";
// private ArrayList<Grammar> grammars = new ArrayList<Grammar>();
// public Version(String key, String label) {
// this.key = key;
// this.label = label;
// }
//
// public void addGrammar(Grammar gram) {
// grammars.add(gram);
// }
//
//
//
// }
// Path: org.cfeclipse.cfmledit.tests/src/org/cfeclipse/cfmledit/tests/dictionary/DictionaryTest.java
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.cfeclipse.cfmledit.dictionary.Dictionary;
import org.cfeclipse.cfmledit.dictionary.Version;
import org.junit.Test;
package org.cfeclipse.cfmledit.tests.dictionary;
public class DictionaryTest {
public void startup(){
}
@Test
public void TestIsSingleton() {
try{
Dictionary dic1 = Dictionary.getInstance();
Dictionary dic2 = Dictionary.getInstance();
assertEquals(dic1, dic2);
}
catch(Exception e){
e.printStackTrace();
}
}
@Test
public void TestLoadDictionary() throws Exception{
Dictionary dict = Dictionary.getInstance(); | ArrayList<Version> versions = dict.getVersions(); |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/document/CFMLDocumentProvider.java | // Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/partitioner/CFMPartitionScanner.java
// public class CFMPartitionScanner extends RuleBasedPartitionScanner {
//
// //The partitions in a CFM document
//
// //Comments
// public final static String CF_COMMENT = "__cf_comment";
// public final static String CF_SCRIPT_COMMENT_BLOCK = "__cf_script_comment_block";
// public final static String CF_SCRIPT_COMMENT = "__cf_script_comment";
// public final static String JAVADOC_COMMENT = "__cf_javadoc_comment";
// public final static String HTM_COMMENT = "__htm_comment";
//
// /*
// public final static String DOCTYPE = "__doctype";
// public final static String CF_SCRIPT = "__cf_script";
// public final static String CF_START_TAG = "__cf_start_tag";
// public final static String CF_START_TAG_BEGIN = "__cf_start_tag_begin";
// public final static String CF_START_TAG_END = "__cf_start_tag_end";
// public final static String CF_TAG_ATTRIBS = "__cf_tag_attribs";
// public final static String CF_SET_STATEMENT = "__cf_set_statment";
// public final static String CF_RETURN_STATEMENT = "__cf_return_statement";
// public final static String CF_BOOLEAN_STATEMENT = "__cf_boolean_statement";
// public final static String CF_END_TAG = "__cf_end_tag";
// public final static String HTM_START_TAG = "__htm_start_tag";
// public final static String HTM_END_TAG = "__htm_end_tag";
// public final static String HTM_START_TAG_BEGIN = "__htm_start_tag_begin";
// public final static String HTM_START_TAG_END = "__htm_start_tag_end";
// public final static String HTM_TAG_ATTRIBS = "__htm_tag_attribs";
// public final static String CF_EXPRESSION = "__cf_expression";
// public final static String J_SCRIPT = "__jscript";
// public final static String CSS = "__css";
// public final static String SQL = "__sql";
// public final static String TAGLIB_TAG = "__taglib_tag";
// public final static String UNK_TAG = "__unk_tag";
// //form and table
// public final static String FORM_END_TAG = "__form_end_tag";
// public final static String FORM_START_TAG = "__form_start_tag";
// public final static String FORM_START_TAG_BEGIN = "__form_start_tag_begin";
// public final static String FORM_TAG_ATTRIBS = "__form_tag_attribs";
// public final static String FORM_START_TAG_END = "__form_start_tag_end";
// public final static String TABLE_END_TAG = "__table_end_tag";
// public final static String TABLE_START_TAG = "__table_start_tag";
// public final static String TABLE_START_TAG_BEGIN = "__table_start_tag_begin";
// public final static String TABLE_TAG_ATTRIBS = "__table_tag_attribs";
// public final static String TABLE_START_TAG_END = "__table_start_tag_end";
// */
//
// public CFMPartitionScanner() {
// IToken cfComment = new Token(CF_COMMENT);
// IToken htmComment = new Token(HTM_COMMENT);
//
// IPredicateRule[] rules = new IPredicateRule[2];
// rules[0] = new MultiLineRule("<!---", "--->", cfComment);
// rules[1] = new MultiLineRule("<!--", "-->", htmComment);
//
// setPredicateRules(rules);
//
// }
//
//
// }
| import org.cfeclipse.cfmledit.editor.partitioner.CFMPartitionScanner;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.ui.editors.text.FileDocumentProvider; | package org.cfeclipse.cfmledit.editor.document;
public class CFMLDocumentProvider extends FileDocumentProvider {
protected IDocument createDocument(Object element) throws CoreException {
IDocument document = super.createDocument(element);
if (document != null){
//Attach the partitioner for .cfm files. looks for and comments tags mainly
IDocumentPartitioner cmfPartitioner =
new FastPartitioner( | // Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/partitioner/CFMPartitionScanner.java
// public class CFMPartitionScanner extends RuleBasedPartitionScanner {
//
// //The partitions in a CFM document
//
// //Comments
// public final static String CF_COMMENT = "__cf_comment";
// public final static String CF_SCRIPT_COMMENT_BLOCK = "__cf_script_comment_block";
// public final static String CF_SCRIPT_COMMENT = "__cf_script_comment";
// public final static String JAVADOC_COMMENT = "__cf_javadoc_comment";
// public final static String HTM_COMMENT = "__htm_comment";
//
// /*
// public final static String DOCTYPE = "__doctype";
// public final static String CF_SCRIPT = "__cf_script";
// public final static String CF_START_TAG = "__cf_start_tag";
// public final static String CF_START_TAG_BEGIN = "__cf_start_tag_begin";
// public final static String CF_START_TAG_END = "__cf_start_tag_end";
// public final static String CF_TAG_ATTRIBS = "__cf_tag_attribs";
// public final static String CF_SET_STATEMENT = "__cf_set_statment";
// public final static String CF_RETURN_STATEMENT = "__cf_return_statement";
// public final static String CF_BOOLEAN_STATEMENT = "__cf_boolean_statement";
// public final static String CF_END_TAG = "__cf_end_tag";
// public final static String HTM_START_TAG = "__htm_start_tag";
// public final static String HTM_END_TAG = "__htm_end_tag";
// public final static String HTM_START_TAG_BEGIN = "__htm_start_tag_begin";
// public final static String HTM_START_TAG_END = "__htm_start_tag_end";
// public final static String HTM_TAG_ATTRIBS = "__htm_tag_attribs";
// public final static String CF_EXPRESSION = "__cf_expression";
// public final static String J_SCRIPT = "__jscript";
// public final static String CSS = "__css";
// public final static String SQL = "__sql";
// public final static String TAGLIB_TAG = "__taglib_tag";
// public final static String UNK_TAG = "__unk_tag";
// //form and table
// public final static String FORM_END_TAG = "__form_end_tag";
// public final static String FORM_START_TAG = "__form_start_tag";
// public final static String FORM_START_TAG_BEGIN = "__form_start_tag_begin";
// public final static String FORM_TAG_ATTRIBS = "__form_tag_attribs";
// public final static String FORM_START_TAG_END = "__form_start_tag_end";
// public final static String TABLE_END_TAG = "__table_end_tag";
// public final static String TABLE_START_TAG = "__table_start_tag";
// public final static String TABLE_START_TAG_BEGIN = "__table_start_tag_begin";
// public final static String TABLE_TAG_ATTRIBS = "__table_tag_attribs";
// public final static String TABLE_START_TAG_END = "__table_start_tag_end";
// */
//
// public CFMPartitionScanner() {
// IToken cfComment = new Token(CF_COMMENT);
// IToken htmComment = new Token(HTM_COMMENT);
//
// IPredicateRule[] rules = new IPredicateRule[2];
// rules[0] = new MultiLineRule("<!---", "--->", cfComment);
// rules[1] = new MultiLineRule("<!--", "-->", htmComment);
//
// setPredicateRules(rules);
//
// }
//
//
// }
// Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/document/CFMLDocumentProvider.java
import org.cfeclipse.cfmledit.editor.partitioner.CFMPartitionScanner;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.ui.editors.text.FileDocumentProvider;
package org.cfeclipse.cfmledit.editor.document;
public class CFMLDocumentProvider extends FileDocumentProvider {
protected IDocument createDocument(Object element) throws CoreException {
IDocument document = super.createDocument(element);
if (document != null){
//Attach the partitioner for .cfm files. looks for and comments tags mainly
IDocumentPartitioner cmfPartitioner =
new FastPartitioner( | new CFMPartitionScanner(), |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.tests/src/org/cfeclipse/cfmledit/tests/dictionary/VersionTest.java | // Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Dictionary.java
// public class Dictionary {
//
// //Myself
// public static Dictionary instance = null;
// //Lightweight listing of server versions
// public static ArrayList<Version> versions = new ArrayList<Version>();
//
// protected Dictionary() throws Exception{
// parseDictionaryConfig(); //No need to lazy load, it's a small XML file and in theory there only will be one dictionary per plugin
// }
//
// public static Dictionary getInstance() throws Exception {
//
// if(instance == null){
// instance = new Dictionary();
// }
// return instance;
// }
//
// private void parseDictionaryConfig() throws Exception {
// // Get the file and set the names in the dictionaryconfig.xml
// Bundle bundle = DictionaryActivator.getBundle();
// URL eclipsePath = FileLocator.find(bundle, new Path("dictionary/dictionaryconfig.xml"),null);
// URL filePath = FileLocator.toFileURL(eclipsePath);
//
// SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(filePath);
// Element cfmlversions = (Element)doc.getRootElement().getChildren().get(0);
//
// if(!cfmlversions.getAttributeValue("id").equalsIgnoreCase("CF_DICTIONARY")){
// throw new Exception("CFML Dictionary information not found");
// }
// loadVersions(cfmlversions);
// }
//
// private void loadVersions(Element cfmlversions) throws IOException,
// JDOMException {
// List<Element> versions = cfmlversions.getChildren();
// for (Element vers : versions) {
// Version version = new Version(vers.getAttributeValue("key"), vers.getAttributeValue("label"));
// List<Element> grammars = vers.getChildren();
// for (Element gramr : grammars) {
// Grammar gram = new Grammar(gramr.getAttributeValue("location"));
// version.addGrammar(gram);
// }
// this.versions.add(version);
// }
// }
//
// public ArrayList<Version> getVersions() throws Exception {
// return versions;
// }
//
//
//
//
// }
//
// Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Version.java
// public class Version {
// private String label = "";
// private String key = "";
// private ArrayList<Grammar> grammars = new ArrayList<Grammar>();
// public Version(String key, String label) {
// this.key = key;
// this.label = label;
// }
//
// public void addGrammar(Grammar gram) {
// grammars.add(gram);
// }
//
//
//
// }
| import static org.junit.Assert.*;
import java.util.ArrayList;
import org.cfeclipse.cfmledit.dictionary.Dictionary;
import org.cfeclipse.cfmledit.dictionary.Version;
import org.junit.Test; | package org.cfeclipse.cfmledit.tests.dictionary;
public class VersionTest {
@Test
public void testGetVersionFromDictionary() throws Exception { | // Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Dictionary.java
// public class Dictionary {
//
// //Myself
// public static Dictionary instance = null;
// //Lightweight listing of server versions
// public static ArrayList<Version> versions = new ArrayList<Version>();
//
// protected Dictionary() throws Exception{
// parseDictionaryConfig(); //No need to lazy load, it's a small XML file and in theory there only will be one dictionary per plugin
// }
//
// public static Dictionary getInstance() throws Exception {
//
// if(instance == null){
// instance = new Dictionary();
// }
// return instance;
// }
//
// private void parseDictionaryConfig() throws Exception {
// // Get the file and set the names in the dictionaryconfig.xml
// Bundle bundle = DictionaryActivator.getBundle();
// URL eclipsePath = FileLocator.find(bundle, new Path("dictionary/dictionaryconfig.xml"),null);
// URL filePath = FileLocator.toFileURL(eclipsePath);
//
// SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(filePath);
// Element cfmlversions = (Element)doc.getRootElement().getChildren().get(0);
//
// if(!cfmlversions.getAttributeValue("id").equalsIgnoreCase("CF_DICTIONARY")){
// throw new Exception("CFML Dictionary information not found");
// }
// loadVersions(cfmlversions);
// }
//
// private void loadVersions(Element cfmlversions) throws IOException,
// JDOMException {
// List<Element> versions = cfmlversions.getChildren();
// for (Element vers : versions) {
// Version version = new Version(vers.getAttributeValue("key"), vers.getAttributeValue("label"));
// List<Element> grammars = vers.getChildren();
// for (Element gramr : grammars) {
// Grammar gram = new Grammar(gramr.getAttributeValue("location"));
// version.addGrammar(gram);
// }
// this.versions.add(version);
// }
// }
//
// public ArrayList<Version> getVersions() throws Exception {
// return versions;
// }
//
//
//
//
// }
//
// Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Version.java
// public class Version {
// private String label = "";
// private String key = "";
// private ArrayList<Grammar> grammars = new ArrayList<Grammar>();
// public Version(String key, String label) {
// this.key = key;
// this.label = label;
// }
//
// public void addGrammar(Grammar gram) {
// grammars.add(gram);
// }
//
//
//
// }
// Path: org.cfeclipse.cfmledit.tests/src/org/cfeclipse/cfmledit/tests/dictionary/VersionTest.java
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.cfeclipse.cfmledit.dictionary.Dictionary;
import org.cfeclipse.cfmledit.dictionary.Version;
import org.junit.Test;
package org.cfeclipse.cfmledit.tests.dictionary;
public class VersionTest {
@Test
public void testGetVersionFromDictionary() throws Exception { | Dictionary dict = Dictionary.getInstance(); |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.tests/src/org/cfeclipse/cfmledit/tests/dictionary/VersionTest.java | // Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Dictionary.java
// public class Dictionary {
//
// //Myself
// public static Dictionary instance = null;
// //Lightweight listing of server versions
// public static ArrayList<Version> versions = new ArrayList<Version>();
//
// protected Dictionary() throws Exception{
// parseDictionaryConfig(); //No need to lazy load, it's a small XML file and in theory there only will be one dictionary per plugin
// }
//
// public static Dictionary getInstance() throws Exception {
//
// if(instance == null){
// instance = new Dictionary();
// }
// return instance;
// }
//
// private void parseDictionaryConfig() throws Exception {
// // Get the file and set the names in the dictionaryconfig.xml
// Bundle bundle = DictionaryActivator.getBundle();
// URL eclipsePath = FileLocator.find(bundle, new Path("dictionary/dictionaryconfig.xml"),null);
// URL filePath = FileLocator.toFileURL(eclipsePath);
//
// SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(filePath);
// Element cfmlversions = (Element)doc.getRootElement().getChildren().get(0);
//
// if(!cfmlversions.getAttributeValue("id").equalsIgnoreCase("CF_DICTIONARY")){
// throw new Exception("CFML Dictionary information not found");
// }
// loadVersions(cfmlversions);
// }
//
// private void loadVersions(Element cfmlversions) throws IOException,
// JDOMException {
// List<Element> versions = cfmlversions.getChildren();
// for (Element vers : versions) {
// Version version = new Version(vers.getAttributeValue("key"), vers.getAttributeValue("label"));
// List<Element> grammars = vers.getChildren();
// for (Element gramr : grammars) {
// Grammar gram = new Grammar(gramr.getAttributeValue("location"));
// version.addGrammar(gram);
// }
// this.versions.add(version);
// }
// }
//
// public ArrayList<Version> getVersions() throws Exception {
// return versions;
// }
//
//
//
//
// }
//
// Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Version.java
// public class Version {
// private String label = "";
// private String key = "";
// private ArrayList<Grammar> grammars = new ArrayList<Grammar>();
// public Version(String key, String label) {
// this.key = key;
// this.label = label;
// }
//
// public void addGrammar(Grammar gram) {
// grammars.add(gram);
// }
//
//
//
// }
| import static org.junit.Assert.*;
import java.util.ArrayList;
import org.cfeclipse.cfmledit.dictionary.Dictionary;
import org.cfeclipse.cfmledit.dictionary.Version;
import org.junit.Test; | package org.cfeclipse.cfmledit.tests.dictionary;
public class VersionTest {
@Test
public void testGetVersionFromDictionary() throws Exception {
Dictionary dict = Dictionary.getInstance(); | // Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Dictionary.java
// public class Dictionary {
//
// //Myself
// public static Dictionary instance = null;
// //Lightweight listing of server versions
// public static ArrayList<Version> versions = new ArrayList<Version>();
//
// protected Dictionary() throws Exception{
// parseDictionaryConfig(); //No need to lazy load, it's a small XML file and in theory there only will be one dictionary per plugin
// }
//
// public static Dictionary getInstance() throws Exception {
//
// if(instance == null){
// instance = new Dictionary();
// }
// return instance;
// }
//
// private void parseDictionaryConfig() throws Exception {
// // Get the file and set the names in the dictionaryconfig.xml
// Bundle bundle = DictionaryActivator.getBundle();
// URL eclipsePath = FileLocator.find(bundle, new Path("dictionary/dictionaryconfig.xml"),null);
// URL filePath = FileLocator.toFileURL(eclipsePath);
//
// SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(filePath);
// Element cfmlversions = (Element)doc.getRootElement().getChildren().get(0);
//
// if(!cfmlversions.getAttributeValue("id").equalsIgnoreCase("CF_DICTIONARY")){
// throw new Exception("CFML Dictionary information not found");
// }
// loadVersions(cfmlversions);
// }
//
// private void loadVersions(Element cfmlversions) throws IOException,
// JDOMException {
// List<Element> versions = cfmlversions.getChildren();
// for (Element vers : versions) {
// Version version = new Version(vers.getAttributeValue("key"), vers.getAttributeValue("label"));
// List<Element> grammars = vers.getChildren();
// for (Element gramr : grammars) {
// Grammar gram = new Grammar(gramr.getAttributeValue("location"));
// version.addGrammar(gram);
// }
// this.versions.add(version);
// }
// }
//
// public ArrayList<Version> getVersions() throws Exception {
// return versions;
// }
//
//
//
//
// }
//
// Path: org.cfeclipse.cfmledit.dictionaries/src/org/cfeclipse/cfmledit/dictionary/Version.java
// public class Version {
// private String label = "";
// private String key = "";
// private ArrayList<Grammar> grammars = new ArrayList<Grammar>();
// public Version(String key, String label) {
// this.key = key;
// this.label = label;
// }
//
// public void addGrammar(Grammar gram) {
// grammars.add(gram);
// }
//
//
//
// }
// Path: org.cfeclipse.cfmledit.tests/src/org/cfeclipse/cfmledit/tests/dictionary/VersionTest.java
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.cfeclipse.cfmledit.dictionary.Dictionary;
import org.cfeclipse.cfmledit.dictionary.Version;
import org.junit.Test;
package org.cfeclipse.cfmledit.tests.dictionary;
public class VersionTest {
@Test
public void testGetVersionFromDictionary() throws Exception {
Dictionary dict = Dictionary.getInstance(); | ArrayList<Version> versions = dict.getVersions(); |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/editors/CFMConfiguration.java | // Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/partitioner/CFMPartitionScanner.java
// public class CFMPartitionScanner extends RuleBasedPartitionScanner {
//
// //The partitions in a CFM document
//
// //Comments
// public final static String CF_COMMENT = "__cf_comment";
// public final static String CF_SCRIPT_COMMENT_BLOCK = "__cf_script_comment_block";
// public final static String CF_SCRIPT_COMMENT = "__cf_script_comment";
// public final static String JAVADOC_COMMENT = "__cf_javadoc_comment";
// public final static String HTM_COMMENT = "__htm_comment";
//
// /*
// public final static String DOCTYPE = "__doctype";
// public final static String CF_SCRIPT = "__cf_script";
// public final static String CF_START_TAG = "__cf_start_tag";
// public final static String CF_START_TAG_BEGIN = "__cf_start_tag_begin";
// public final static String CF_START_TAG_END = "__cf_start_tag_end";
// public final static String CF_TAG_ATTRIBS = "__cf_tag_attribs";
// public final static String CF_SET_STATEMENT = "__cf_set_statment";
// public final static String CF_RETURN_STATEMENT = "__cf_return_statement";
// public final static String CF_BOOLEAN_STATEMENT = "__cf_boolean_statement";
// public final static String CF_END_TAG = "__cf_end_tag";
// public final static String HTM_START_TAG = "__htm_start_tag";
// public final static String HTM_END_TAG = "__htm_end_tag";
// public final static String HTM_START_TAG_BEGIN = "__htm_start_tag_begin";
// public final static String HTM_START_TAG_END = "__htm_start_tag_end";
// public final static String HTM_TAG_ATTRIBS = "__htm_tag_attribs";
// public final static String CF_EXPRESSION = "__cf_expression";
// public final static String J_SCRIPT = "__jscript";
// public final static String CSS = "__css";
// public final static String SQL = "__sql";
// public final static String TAGLIB_TAG = "__taglib_tag";
// public final static String UNK_TAG = "__unk_tag";
// //form and table
// public final static String FORM_END_TAG = "__form_end_tag";
// public final static String FORM_START_TAG = "__form_start_tag";
// public final static String FORM_START_TAG_BEGIN = "__form_start_tag_begin";
// public final static String FORM_TAG_ATTRIBS = "__form_tag_attribs";
// public final static String FORM_START_TAG_END = "__form_start_tag_end";
// public final static String TABLE_END_TAG = "__table_end_tag";
// public final static String TABLE_START_TAG = "__table_start_tag";
// public final static String TABLE_START_TAG_BEGIN = "__table_start_tag_begin";
// public final static String TABLE_TAG_ATTRIBS = "__table_tag_attribs";
// public final static String TABLE_START_TAG_END = "__table_start_tag_end";
// */
//
// public CFMPartitionScanner() {
// IToken cfComment = new Token(CF_COMMENT);
// IToken htmComment = new Token(HTM_COMMENT);
//
// IPredicateRule[] rules = new IPredicateRule[2];
// rules[0] = new MultiLineRule("<!---", "--->", cfComment);
// rules[1] = new MultiLineRule("<!--", "-->", htmComment);
//
// setPredicateRules(rules);
//
// }
//
//
// }
| import org.cfeclipse.cfmledit.editor.partitioner.CFMPartitionScanner;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration; | package org.cfeclipse.cfmledit.editor.editors;
public class CFMConfiguration extends SourceViewerConfiguration {
private ColorManager colorManager;
private CFMScanner scanner;
public CFMConfiguration(ColorManager colorManager){
this.colorManager = colorManager;
}
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] {
IDocument.DEFAULT_CONTENT_TYPE, | // Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/partitioner/CFMPartitionScanner.java
// public class CFMPartitionScanner extends RuleBasedPartitionScanner {
//
// //The partitions in a CFM document
//
// //Comments
// public final static String CF_COMMENT = "__cf_comment";
// public final static String CF_SCRIPT_COMMENT_BLOCK = "__cf_script_comment_block";
// public final static String CF_SCRIPT_COMMENT = "__cf_script_comment";
// public final static String JAVADOC_COMMENT = "__cf_javadoc_comment";
// public final static String HTM_COMMENT = "__htm_comment";
//
// /*
// public final static String DOCTYPE = "__doctype";
// public final static String CF_SCRIPT = "__cf_script";
// public final static String CF_START_TAG = "__cf_start_tag";
// public final static String CF_START_TAG_BEGIN = "__cf_start_tag_begin";
// public final static String CF_START_TAG_END = "__cf_start_tag_end";
// public final static String CF_TAG_ATTRIBS = "__cf_tag_attribs";
// public final static String CF_SET_STATEMENT = "__cf_set_statment";
// public final static String CF_RETURN_STATEMENT = "__cf_return_statement";
// public final static String CF_BOOLEAN_STATEMENT = "__cf_boolean_statement";
// public final static String CF_END_TAG = "__cf_end_tag";
// public final static String HTM_START_TAG = "__htm_start_tag";
// public final static String HTM_END_TAG = "__htm_end_tag";
// public final static String HTM_START_TAG_BEGIN = "__htm_start_tag_begin";
// public final static String HTM_START_TAG_END = "__htm_start_tag_end";
// public final static String HTM_TAG_ATTRIBS = "__htm_tag_attribs";
// public final static String CF_EXPRESSION = "__cf_expression";
// public final static String J_SCRIPT = "__jscript";
// public final static String CSS = "__css";
// public final static String SQL = "__sql";
// public final static String TAGLIB_TAG = "__taglib_tag";
// public final static String UNK_TAG = "__unk_tag";
// //form and table
// public final static String FORM_END_TAG = "__form_end_tag";
// public final static String FORM_START_TAG = "__form_start_tag";
// public final static String FORM_START_TAG_BEGIN = "__form_start_tag_begin";
// public final static String FORM_TAG_ATTRIBS = "__form_tag_attribs";
// public final static String FORM_START_TAG_END = "__form_start_tag_end";
// public final static String TABLE_END_TAG = "__table_end_tag";
// public final static String TABLE_START_TAG = "__table_start_tag";
// public final static String TABLE_START_TAG_BEGIN = "__table_start_tag_begin";
// public final static String TABLE_TAG_ATTRIBS = "__table_tag_attribs";
// public final static String TABLE_START_TAG_END = "__table_start_tag_end";
// */
//
// public CFMPartitionScanner() {
// IToken cfComment = new Token(CF_COMMENT);
// IToken htmComment = new Token(HTM_COMMENT);
//
// IPredicateRule[] rules = new IPredicateRule[2];
// rules[0] = new MultiLineRule("<!---", "--->", cfComment);
// rules[1] = new MultiLineRule("<!--", "-->", htmComment);
//
// setPredicateRules(rules);
//
// }
//
//
// }
// Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/editors/CFMConfiguration.java
import org.cfeclipse.cfmledit.editor.partitioner.CFMPartitionScanner;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
package org.cfeclipse.cfmledit.editor.editors;
public class CFMConfiguration extends SourceViewerConfiguration {
private ColorManager colorManager;
private CFMScanner scanner;
public CFMConfiguration(ColorManager colorManager){
this.colorManager = colorManager;
}
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] {
IDocument.DEFAULT_CONTENT_TYPE, | CFMPartitionScanner.CF_COMMENT |
cybersonic/CFMLEdit | org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/editors/CFMLEditor.java | // Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/document/CFMLDocumentProvider.java
// public class CFMLDocumentProvider extends FileDocumentProvider {
//
// protected IDocument createDocument(Object element) throws CoreException {
// IDocument document = super.createDocument(element);
// if (document != null){
// //Attach the partitioner for .cfm files. looks for and comments tags mainly
// IDocumentPartitioner cmfPartitioner =
// new FastPartitioner(
// new CFMPartitionScanner(),
// new String[]{
// CFMPartitionScanner.CF_COMMENT
// }
// );
//
// cmfPartitioner.connect(document);
// document.setDocumentPartitioner(cmfPartitioner);
// }
// return document;
// }
//
//
// }
| import org.cfeclipse.cfmledit.editor.document.CFMLDocumentProvider;
import org.eclipse.ui.editors.text.TextEditor; | package org.cfeclipse.cfmledit.editor.editors;
public class CFMLEditor extends TextEditor {
private ColorManager colorManager;
public CFMLEditor() {
super();
colorManager = new ColorManager();
setSourceViewerConfiguration(new CFMConfiguration(colorManager)); | // Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/document/CFMLDocumentProvider.java
// public class CFMLDocumentProvider extends FileDocumentProvider {
//
// protected IDocument createDocument(Object element) throws CoreException {
// IDocument document = super.createDocument(element);
// if (document != null){
// //Attach the partitioner for .cfm files. looks for and comments tags mainly
// IDocumentPartitioner cmfPartitioner =
// new FastPartitioner(
// new CFMPartitionScanner(),
// new String[]{
// CFMPartitionScanner.CF_COMMENT
// }
// );
//
// cmfPartitioner.connect(document);
// document.setDocumentPartitioner(cmfPartitioner);
// }
// return document;
// }
//
//
// }
// Path: org.cfeclipse.cfmledit.editor/src/org/cfeclipse/cfmledit/editor/editors/CFMLEditor.java
import org.cfeclipse.cfmledit.editor.document.CFMLDocumentProvider;
import org.eclipse.ui.editors.text.TextEditor;
package org.cfeclipse.cfmledit.editor.editors;
public class CFMLEditor extends TextEditor {
private ColorManager colorManager;
public CFMLEditor() {
super();
colorManager = new ColorManager();
setSourceViewerConfiguration(new CFMConfiguration(colorManager)); | setDocumentProvider(new CFMLDocumentProvider()); |
kebernet/shortyz | app/src/main/java/com/totsp/crossword/HTMLActivity.java | // Path: app/src/main/java/com/totsp/crossword/versions/AndroidVersionUtils.java
// public interface AndroidVersionUtils {
//
// void storeMetas(Uri uri, PuzzleMeta meta);
//
// void setContext(Context ctx);
//
// boolean downloadFile(URL url, File destination,
// Map<String, String> headers, boolean notification, String title);
//
// void finishOnHomeButton(AppCompatActivity a);
//
// void holographic(AppCompatActivity playActivity);
//
// void onActionBarWithText(MenuItem a);
//
// void onActionBarWithText(SubMenu reveal);
//
// void restoreNightMode(ShortyzActivity shortyzActivity);
//
// class Factory {
// private static AndroidVersionUtils INSTANCE;
//
// public static AndroidVersionUtils getInstance() {
// if(INSTANCE != null){
// return INSTANCE;
// }
// System.out.println("Creating utils for version: "
// + android.os.Build.VERSION.SDK_INT);
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// System.out.println("Using Oreo");
// return INSTANCE = new OreoUtil();
// }
// else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// System.out.println("Using Lollipop");
// return INSTANCE = new LollipopUtil();
// }
// else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// System.out.println("Using Honeycomb");
// return INSTANCE = new HoneycombUtil();
// } else {
// System.out.println("Using Gingerbread");
// return INSTANCE = new GingerbreadUtil();
// }
// }
// }
//
// View onActionBarCustom(AppCompatActivity a, int id);
//
// void hideWindowTitle(AppCompatActivity a);
//
// void hideActionBar(AppCompatActivity a);
//
// void onActionBarWithoutText(MenuItem a);
//
// void hideTitleOnPortrait(AppCompatActivity a);
//
// void toggleNightMode(ShortyzActivity activity);
//
// boolean isNightModeAvailable();
//
// // This has a dependency on JobScheduler which is only available in SDK version 21.
// //
// // TODO: It might be possible to replicate this functionality on older versions using
// // AlarmManager.
// boolean isBackgroundDownloadAvaliable();
//
// // Checks whether a background download may have updated the available puzzles, requiring a
// // UI refresh.
// boolean checkBackgroundDownload(SharedPreferences prefs, boolean hasWritePermissions);
//
// void clearBackgroundDownload(SharedPreferences prefs);
//
// void createNotificationChannel(Context context);
// }
//
// Path: app/src/main/java/com/totsp/crossword/view/recycler/ShowHideOnScroll.java
// public class ShowHideOnScroll extends ScrollDetector implements Animation.AnimationListener {
// private final View view;
// private final int showAnimationId;
// private final int hideAnimationId;
//
// public ShowHideOnScroll(View view) {
// this(view, R.anim.float_show, R.anim.float_hide);
// }
//
// public ShowHideOnScroll(View view, int animShow, int animHide) {
// super(view.getContext());
// this.view = view;
// this.showAnimationId = animShow;
// this.hideAnimationId = animHide;
// }
//
// public void onScrollDown() {
// if(this.view.getVisibility() != View.VISIBLE) {
// this.view.setVisibility(View.VISIBLE);
// this.animate(this.showAnimationId);
// }
//
// }
//
// public void onScrollUp() {
// if(this.view.getVisibility() == View.VISIBLE) {
// this.view.setVisibility(View.GONE);
// this.animate(this.hideAnimationId);
// }
//
// }
//
// private void animate(int anim) {
// if(anim != 0) {
// Animation a = AnimationUtils.loadAnimation(this.view.getContext(), anim);
// a.setAnimationListener(this);
// this.view.startAnimation(a);
// this.setIgnore(true);
// }
//
// }
//
// public void onAnimationStart(Animation animation) {
// }
//
// public void onAnimationEnd(Animation animation) {
// this.setIgnore(false);
// }
//
// public void onAnimationRepeat(Animation animation) {
// }
// }
| import android.net.Uri;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import androidx.appcompat.app.ActionBar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.totsp.crossword.shortyz.R;
import com.totsp.crossword.versions.AndroidVersionUtils;
import com.totsp.crossword.view.recycler.ShowHideOnScroll;
| package com.totsp.crossword;
public class HTMLActivity extends ShortyzActivity {
protected AndroidVersionUtils utils = AndroidVersionUtils.Factory.getInstance();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
utils.holographic(this);
utils.finishOnHomeButton(this);
this.setContentView(R.layout.html_view);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
WebView webview = (WebView) this.findViewById(R.id.webkit);
Uri u = this.getIntent()
.getData();
webview.loadUrl(u.toString());
FloatingActionButton download = (FloatingActionButton) this.findViewById(R.id.button_floating_action);
if(download != null) {
download.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
download.setImageBitmap(createBitmap("icons1.ttf", "k"));
| // Path: app/src/main/java/com/totsp/crossword/versions/AndroidVersionUtils.java
// public interface AndroidVersionUtils {
//
// void storeMetas(Uri uri, PuzzleMeta meta);
//
// void setContext(Context ctx);
//
// boolean downloadFile(URL url, File destination,
// Map<String, String> headers, boolean notification, String title);
//
// void finishOnHomeButton(AppCompatActivity a);
//
// void holographic(AppCompatActivity playActivity);
//
// void onActionBarWithText(MenuItem a);
//
// void onActionBarWithText(SubMenu reveal);
//
// void restoreNightMode(ShortyzActivity shortyzActivity);
//
// class Factory {
// private static AndroidVersionUtils INSTANCE;
//
// public static AndroidVersionUtils getInstance() {
// if(INSTANCE != null){
// return INSTANCE;
// }
// System.out.println("Creating utils for version: "
// + android.os.Build.VERSION.SDK_INT);
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// System.out.println("Using Oreo");
// return INSTANCE = new OreoUtil();
// }
// else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// System.out.println("Using Lollipop");
// return INSTANCE = new LollipopUtil();
// }
// else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// System.out.println("Using Honeycomb");
// return INSTANCE = new HoneycombUtil();
// } else {
// System.out.println("Using Gingerbread");
// return INSTANCE = new GingerbreadUtil();
// }
// }
// }
//
// View onActionBarCustom(AppCompatActivity a, int id);
//
// void hideWindowTitle(AppCompatActivity a);
//
// void hideActionBar(AppCompatActivity a);
//
// void onActionBarWithoutText(MenuItem a);
//
// void hideTitleOnPortrait(AppCompatActivity a);
//
// void toggleNightMode(ShortyzActivity activity);
//
// boolean isNightModeAvailable();
//
// // This has a dependency on JobScheduler which is only available in SDK version 21.
// //
// // TODO: It might be possible to replicate this functionality on older versions using
// // AlarmManager.
// boolean isBackgroundDownloadAvaliable();
//
// // Checks whether a background download may have updated the available puzzles, requiring a
// // UI refresh.
// boolean checkBackgroundDownload(SharedPreferences prefs, boolean hasWritePermissions);
//
// void clearBackgroundDownload(SharedPreferences prefs);
//
// void createNotificationChannel(Context context);
// }
//
// Path: app/src/main/java/com/totsp/crossword/view/recycler/ShowHideOnScroll.java
// public class ShowHideOnScroll extends ScrollDetector implements Animation.AnimationListener {
// private final View view;
// private final int showAnimationId;
// private final int hideAnimationId;
//
// public ShowHideOnScroll(View view) {
// this(view, R.anim.float_show, R.anim.float_hide);
// }
//
// public ShowHideOnScroll(View view, int animShow, int animHide) {
// super(view.getContext());
// this.view = view;
// this.showAnimationId = animShow;
// this.hideAnimationId = animHide;
// }
//
// public void onScrollDown() {
// if(this.view.getVisibility() != View.VISIBLE) {
// this.view.setVisibility(View.VISIBLE);
// this.animate(this.showAnimationId);
// }
//
// }
//
// public void onScrollUp() {
// if(this.view.getVisibility() == View.VISIBLE) {
// this.view.setVisibility(View.GONE);
// this.animate(this.hideAnimationId);
// }
//
// }
//
// private void animate(int anim) {
// if(anim != 0) {
// Animation a = AnimationUtils.loadAnimation(this.view.getContext(), anim);
// a.setAnimationListener(this);
// this.view.startAnimation(a);
// this.setIgnore(true);
// }
//
// }
//
// public void onAnimationStart(Animation animation) {
// }
//
// public void onAnimationEnd(Animation animation) {
// this.setIgnore(false);
// }
//
// public void onAnimationRepeat(Animation animation) {
// }
// }
// Path: app/src/main/java/com/totsp/crossword/HTMLActivity.java
import android.net.Uri;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import androidx.appcompat.app.ActionBar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.totsp.crossword.shortyz.R;
import com.totsp.crossword.versions.AndroidVersionUtils;
import com.totsp.crossword.view.recycler.ShowHideOnScroll;
package com.totsp.crossword;
public class HTMLActivity extends ShortyzActivity {
protected AndroidVersionUtils utils = AndroidVersionUtils.Factory.getInstance();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
utils.holographic(this);
utils.finishOnHomeButton(this);
this.setContentView(R.layout.html_view);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
WebView webview = (WebView) this.findViewById(R.id.webkit);
Uri u = this.getIntent()
.getData();
webview.loadUrl(u.toString());
FloatingActionButton download = (FloatingActionButton) this.findViewById(R.id.button_floating_action);
if(download != null) {
download.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
download.setImageBitmap(createBitmap("icons1.ttf", "k"));
| webview.setOnTouchListener(new ShowHideOnScroll(download));
|
kebernet/shortyz | app/src/main/java/com/totsp/crossword/versions/LollipopUtil.java | // Path: app/src/main/java/com/totsp/crossword/service/BackgroundDownloadService.java
// @TargetApi(21)
// public class BackgroundDownloadService extends JobService {
// public static final String DOWNLOAD_PENDING_PREFERENCE = "backgroundDlPending";
//
// private static final Logger LOGGER =
// Logger.getLogger(BackgroundDownloadService.class.getCanonicalName());
//
// private static JobInfo getJobInfo(boolean requireUnmetered, boolean allowRoaming,
// boolean requireCharging) {
// JobInfo.Builder builder = new JobInfo.Builder(
// JobSchedulerId.BACKGROUND_DOWNLOAD.id(),
// new ComponentName("com.totsp.crossword.shortyz",
// BackgroundDownloadService.class.getName()));
//
// builder.setPeriodic(TimeUnit.HOURS.toMillis(1))
// .setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED)
// .setRequiresCharging(requireCharging)
// .setPersisted(true);
//
// if (!requireUnmetered) {
// if (allowRoaming) {
// builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
// } else {
// builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_NOT_ROAMING);
// }
// }
//
// return builder.build();
// }
//
// @Override
// public boolean onStartJob(JobParameters job) {
// LOGGER.info("Starting background download task");
// DownloadTask downloadTask = new DownloadTask(this);
// downloadTask.execute(job);
// return true;
// }
//
// @Override
// public boolean onStopJob(JobParameters job) {
// return false;
// }
//
// public static void updateJob(Context context) {
// SharedPreferences preferences =
// PreferenceManager.getDefaultSharedPreferences(context);
//
// boolean enable = preferences.getBoolean("backgroundDownload", false);
//
// if (enable) {
// scheduleJob(context);
// } else {
// cancelJob(context);
// }
// }
//
// private static void scheduleJob(Context context) {
// JobScheduler scheduler =
// (JobScheduler)context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
//
// SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
//
// JobInfo info = getJobInfo(
// preferences.getBoolean("backgroundDownloadRequireUnmetered", true),
// preferences.getBoolean("backgroundDownloadAllowRoaming", false),
// preferences.getBoolean("backgroundDownloadRequireCharging", false));
//
//
// LOGGER.info("Scheduling background download job: " + info);
//
// int result = scheduler.schedule(info);
//
// if (result == JobScheduler.RESULT_SUCCESS) {
// LOGGER.info("Successfully scheduled background downloads");
// } else {
// LOGGER.log(Level.WARNING, "Unable to schedule background downloads");
// }
// }
//
// private static void cancelJob(Context context) {
// LOGGER.info("Unscheduling background downloads");
// JobScheduler scheduler =
// (JobScheduler)context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
// scheduler.cancel(JobSchedulerId.BACKGROUND_DOWNLOAD.id());
// }
//
// private static class DownloadTask extends AsyncTask<JobParameters, Void, JobParameters> {
// private final JobService jobService;
//
// public DownloadTask(JobService jobService) {
// this.jobService = jobService;
// }
//
// @Override
// protected JobParameters doInBackground(JobParameters... params) {
// Context context = jobService.getApplicationContext();
//
// NotificationManager nm =
// (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
//
// if (ContextCompat.checkSelfPermission(context,
// Manifest.permission.WRITE_EXTERNAL_STORAGE) !=
// PackageManager.PERMISSION_GRANTED) {
// LOGGER.info("Skipping download, no write permission");
// return params[0];
// }
//
// LOGGER.info("Downloading most recent puzzles");
// if(Looper.myLooper() == null) {
// Looper.prepare();
// }
//
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// final Downloaders dls = new Downloaders(prefs, nm, context, false);
// dls.downloadLatestIfNewerThanDate(new Date(), null);
//
// // This is used to tell BrowseActivity that puzzles may have been updated while
// // paused.
// prefs.edit()
// .putBoolean(DOWNLOAD_PENDING_PREFERENCE, true)
// .apply();
//
// return params[0];
// }
//
// protected void onPostExecute(JobParameters params) {
// jobService.jobFinished(params, false);
// }
// }
// }
| import android.content.SharedPreferences;
import com.totsp.crossword.service.BackgroundDownloadService; | package com.totsp.crossword.versions;
public class LollipopUtil extends HoneycombUtil {
@Override
public boolean isBackgroundDownloadAvaliable() {
return true;
}
@Override
public boolean checkBackgroundDownload(SharedPreferences prefs, boolean hasWritePermissions) {
if (!hasWritePermissions) {
return false;
}
boolean isPending = | // Path: app/src/main/java/com/totsp/crossword/service/BackgroundDownloadService.java
// @TargetApi(21)
// public class BackgroundDownloadService extends JobService {
// public static final String DOWNLOAD_PENDING_PREFERENCE = "backgroundDlPending";
//
// private static final Logger LOGGER =
// Logger.getLogger(BackgroundDownloadService.class.getCanonicalName());
//
// private static JobInfo getJobInfo(boolean requireUnmetered, boolean allowRoaming,
// boolean requireCharging) {
// JobInfo.Builder builder = new JobInfo.Builder(
// JobSchedulerId.BACKGROUND_DOWNLOAD.id(),
// new ComponentName("com.totsp.crossword.shortyz",
// BackgroundDownloadService.class.getName()));
//
// builder.setPeriodic(TimeUnit.HOURS.toMillis(1))
// .setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED)
// .setRequiresCharging(requireCharging)
// .setPersisted(true);
//
// if (!requireUnmetered) {
// if (allowRoaming) {
// builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
// } else {
// builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_NOT_ROAMING);
// }
// }
//
// return builder.build();
// }
//
// @Override
// public boolean onStartJob(JobParameters job) {
// LOGGER.info("Starting background download task");
// DownloadTask downloadTask = new DownloadTask(this);
// downloadTask.execute(job);
// return true;
// }
//
// @Override
// public boolean onStopJob(JobParameters job) {
// return false;
// }
//
// public static void updateJob(Context context) {
// SharedPreferences preferences =
// PreferenceManager.getDefaultSharedPreferences(context);
//
// boolean enable = preferences.getBoolean("backgroundDownload", false);
//
// if (enable) {
// scheduleJob(context);
// } else {
// cancelJob(context);
// }
// }
//
// private static void scheduleJob(Context context) {
// JobScheduler scheduler =
// (JobScheduler)context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
//
// SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
//
// JobInfo info = getJobInfo(
// preferences.getBoolean("backgroundDownloadRequireUnmetered", true),
// preferences.getBoolean("backgroundDownloadAllowRoaming", false),
// preferences.getBoolean("backgroundDownloadRequireCharging", false));
//
//
// LOGGER.info("Scheduling background download job: " + info);
//
// int result = scheduler.schedule(info);
//
// if (result == JobScheduler.RESULT_SUCCESS) {
// LOGGER.info("Successfully scheduled background downloads");
// } else {
// LOGGER.log(Level.WARNING, "Unable to schedule background downloads");
// }
// }
//
// private static void cancelJob(Context context) {
// LOGGER.info("Unscheduling background downloads");
// JobScheduler scheduler =
// (JobScheduler)context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
// scheduler.cancel(JobSchedulerId.BACKGROUND_DOWNLOAD.id());
// }
//
// private static class DownloadTask extends AsyncTask<JobParameters, Void, JobParameters> {
// private final JobService jobService;
//
// public DownloadTask(JobService jobService) {
// this.jobService = jobService;
// }
//
// @Override
// protected JobParameters doInBackground(JobParameters... params) {
// Context context = jobService.getApplicationContext();
//
// NotificationManager nm =
// (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
//
// if (ContextCompat.checkSelfPermission(context,
// Manifest.permission.WRITE_EXTERNAL_STORAGE) !=
// PackageManager.PERMISSION_GRANTED) {
// LOGGER.info("Skipping download, no write permission");
// return params[0];
// }
//
// LOGGER.info("Downloading most recent puzzles");
// if(Looper.myLooper() == null) {
// Looper.prepare();
// }
//
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// final Downloaders dls = new Downloaders(prefs, nm, context, false);
// dls.downloadLatestIfNewerThanDate(new Date(), null);
//
// // This is used to tell BrowseActivity that puzzles may have been updated while
// // paused.
// prefs.edit()
// .putBoolean(DOWNLOAD_PENDING_PREFERENCE, true)
// .apply();
//
// return params[0];
// }
//
// protected void onPostExecute(JobParameters params) {
// jobService.jobFinished(params, false);
// }
// }
// }
// Path: app/src/main/java/com/totsp/crossword/versions/LollipopUtil.java
import android.content.SharedPreferences;
import com.totsp.crossword.service.BackgroundDownloadService;
package com.totsp.crossword.versions;
public class LollipopUtil extends HoneycombUtil {
@Override
public boolean isBackgroundDownloadAvaliable() {
return true;
}
@Override
public boolean checkBackgroundDownload(SharedPreferences prefs, boolean hasWritePermissions) {
if (!hasWritePermissions) {
return false;
}
boolean isPending = | prefs.getBoolean(BackgroundDownloadService.DOWNLOAD_PENDING_PREFERENCE, false); |
kebernet/shortyz | puzlib/src/main/java/com/totsp/crossword/puz/Puzzle.java | // Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Position implements Serializable {
// public int across;
// public int down;
//
// protected Position(){
//
// }
//
// public Position(int across, int down) {
// this.down = down;
// this.across = across;
// }
//
// @Override
// public boolean equals(Object o) {
// if ((o == null) || (o.getClass() != this.getClass())) {
// return false;
// }
//
// Position p = (Position) o;
//
// return ((p.down == this.down) && (p.across == this.across));
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(new int[] {across, down});
// }
//
// @Override
// public String toString() {
// return "[" + this.across + " x " + this.down + "]";
// }
// }
| import com.totsp.crossword.puz.Playboard.Position;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date; | package com.totsp.crossword.puz;
public class Puzzle implements Serializable{
private String author;
private String copyright;
private String notes;
private String title;
private String[] acrossClues;
private Integer[] acrossCluesLookup;
private String[] downClues;
private Integer[] downCluesLookup;
private int numberOfClues;
private Date pubdate = new Date();
private String source;
private String sourceUrl = "";
private Box[][] boxes;
private Box[] boxesList;
private String[] rawClues;
private boolean updatable;
private int height;
private int width;
private long playedTime;
private boolean scrambled;
public short solutionChecksum;
private String version;
private boolean hasGEXT; | // Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Position implements Serializable {
// public int across;
// public int down;
//
// protected Position(){
//
// }
//
// public Position(int across, int down) {
// this.down = down;
// this.across = across;
// }
//
// @Override
// public boolean equals(Object o) {
// if ((o == null) || (o.getClass() != this.getClass())) {
// return false;
// }
//
// Position p = (Position) o;
//
// return ((p.down == this.down) && (p.across == this.across));
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(new int[] {across, down});
// }
//
// @Override
// public String toString() {
// return "[" + this.across + " x " + this.down + "]";
// }
// }
// Path: puzlib/src/main/java/com/totsp/crossword/puz/Puzzle.java
import com.totsp.crossword.puz.Playboard.Position;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
package com.totsp.crossword.puz;
public class Puzzle implements Serializable{
private String author;
private String copyright;
private String notes;
private String title;
private String[] acrossClues;
private Integer[] acrossCluesLookup;
private String[] downClues;
private Integer[] downCluesLookup;
private int numberOfClues;
private Date pubdate = new Date();
private String source;
private String sourceUrl = "";
private Box[][] boxes;
private Box[] boxesList;
private String[] rawClues;
private boolean updatable;
private int height;
private int width;
private long playedTime;
private boolean scrambled;
public short solutionChecksum;
private String version;
private boolean hasGEXT; | private Position position; |
kebernet/shortyz | puzlib/src/main/java/com/totsp/crossword/puz/MovementStrategy.java | // Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Position implements Serializable {
// public int across;
// public int down;
//
// protected Position(){
//
// }
//
// public Position(int across, int down) {
// this.down = down;
// this.across = across;
// }
//
// @Override
// public boolean equals(Object o) {
// if ((o == null) || (o.getClass() != this.getClass())) {
// return false;
// }
//
// Position p = (Position) o;
//
// return ((p.down == this.down) && (p.across == this.across));
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(new int[] {across, down});
// }
//
// @Override
// public String toString() {
// return "[" + this.across + " x " + this.down + "]";
// }
// }
//
// Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Word implements Serializable {
// public Position start;
// public boolean across;
// public int length;
//
// public boolean checkInWord(int across, int down) {
// int ranging = this.across ? across : down;
// boolean offRanging = this.across ? (down == start.down) : (across == start.across);
//
// int startPos = this.across ? start.across : start.down;
//
// return (offRanging && (startPos <= ranging) && ((startPos + length) > ranging));
// }
//
// @Override
// public boolean equals(Object o) {
// if (o.getClass() != Word.class) {
// return false;
// }
//
// Word check = (Word) o;
//
// return check.start.equals(this.start) && (check.across == this.across) && (check.length == this.length);
// }
//
// @Override
// public int hashCode() {
// int hash = 5;
// hash = (29 * hash) + ((this.start != null) ? this.start.hashCode() : 0);
// hash = (29 * hash) + (this.across ? 1 : 0);
// hash = (29 * hash) + this.length;
//
// return hash;
// }
// }
| import com.totsp.crossword.puz.Playboard.Position;
import com.totsp.crossword.puz.Playboard.Word;
import java.io.Serializable;
import java.util.Arrays; | package com.totsp.crossword.puz;
public interface MovementStrategy extends Serializable {
class Common {
/**
* @return if @param Word (w) is the last word in its direction in the @param board
*/ | // Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Position implements Serializable {
// public int across;
// public int down;
//
// protected Position(){
//
// }
//
// public Position(int across, int down) {
// this.down = down;
// this.across = across;
// }
//
// @Override
// public boolean equals(Object o) {
// if ((o == null) || (o.getClass() != this.getClass())) {
// return false;
// }
//
// Position p = (Position) o;
//
// return ((p.down == this.down) && (p.across == this.across));
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(new int[] {across, down});
// }
//
// @Override
// public String toString() {
// return "[" + this.across + " x " + this.down + "]";
// }
// }
//
// Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Word implements Serializable {
// public Position start;
// public boolean across;
// public int length;
//
// public boolean checkInWord(int across, int down) {
// int ranging = this.across ? across : down;
// boolean offRanging = this.across ? (down == start.down) : (across == start.across);
//
// int startPos = this.across ? start.across : start.down;
//
// return (offRanging && (startPos <= ranging) && ((startPos + length) > ranging));
// }
//
// @Override
// public boolean equals(Object o) {
// if (o.getClass() != Word.class) {
// return false;
// }
//
// Word check = (Word) o;
//
// return check.start.equals(this.start) && (check.across == this.across) && (check.length == this.length);
// }
//
// @Override
// public int hashCode() {
// int hash = 5;
// hash = (29 * hash) + ((this.start != null) ? this.start.hashCode() : 0);
// hash = (29 * hash) + (this.across ? 1 : 0);
// hash = (29 * hash) + this.length;
//
// return hash;
// }
// }
// Path: puzlib/src/main/java/com/totsp/crossword/puz/MovementStrategy.java
import com.totsp.crossword.puz.Playboard.Position;
import com.totsp.crossword.puz.Playboard.Word;
import java.io.Serializable;
import java.util.Arrays;
package com.totsp.crossword.puz;
public interface MovementStrategy extends Serializable {
class Common {
/**
* @return if @param Word (w) is the last word in its direction in the @param board
*/ | static boolean isLastWordInDirection(Playboard board, Word w) { |
kebernet/shortyz | puzlib/src/main/java/com/totsp/crossword/puz/MovementStrategy.java | // Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Position implements Serializable {
// public int across;
// public int down;
//
// protected Position(){
//
// }
//
// public Position(int across, int down) {
// this.down = down;
// this.across = across;
// }
//
// @Override
// public boolean equals(Object o) {
// if ((o == null) || (o.getClass() != this.getClass())) {
// return false;
// }
//
// Position p = (Position) o;
//
// return ((p.down == this.down) && (p.across == this.across));
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(new int[] {across, down});
// }
//
// @Override
// public String toString() {
// return "[" + this.across + " x " + this.down + "]";
// }
// }
//
// Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Word implements Serializable {
// public Position start;
// public boolean across;
// public int length;
//
// public boolean checkInWord(int across, int down) {
// int ranging = this.across ? across : down;
// boolean offRanging = this.across ? (down == start.down) : (across == start.across);
//
// int startPos = this.across ? start.across : start.down;
//
// return (offRanging && (startPos <= ranging) && ((startPos + length) > ranging));
// }
//
// @Override
// public boolean equals(Object o) {
// if (o.getClass() != Word.class) {
// return false;
// }
//
// Word check = (Word) o;
//
// return check.start.equals(this.start) && (check.across == this.across) && (check.length == this.length);
// }
//
// @Override
// public int hashCode() {
// int hash = 5;
// hash = (29 * hash) + ((this.start != null) ? this.start.hashCode() : 0);
// hash = (29 * hash) + (this.across ? 1 : 0);
// hash = (29 * hash) + this.length;
//
// return hash;
// }
// }
| import com.totsp.crossword.puz.Playboard.Position;
import com.totsp.crossword.puz.Playboard.Word;
import java.io.Serializable;
import java.util.Arrays; | package com.totsp.crossword.puz;
public interface MovementStrategy extends Serializable {
class Common {
/**
* @return if @param Word (w) is the last word in its direction in the @param board
*/
static boolean isLastWordInDirection(Playboard board, Word w) {
return isLastWordInDirection(board.getBoxes(), w);
}
/**
* @return if @param Word (w) is the last word in its direction in @param boxes
*/
static boolean isLastWordInDirection(Box[][] boxes, Word w) {
if (w.across) {
return (w.start.across + w.length >= boxes.length);
}
return (w.start.down + w.length >= boxes[w.start.across].length);
}
/**
* @return if @param Position (p) is the last position in @param Word (w)
*/ | // Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Position implements Serializable {
// public int across;
// public int down;
//
// protected Position(){
//
// }
//
// public Position(int across, int down) {
// this.down = down;
// this.across = across;
// }
//
// @Override
// public boolean equals(Object o) {
// if ((o == null) || (o.getClass() != this.getClass())) {
// return false;
// }
//
// Position p = (Position) o;
//
// return ((p.down == this.down) && (p.across == this.across));
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(new int[] {across, down});
// }
//
// @Override
// public String toString() {
// return "[" + this.across + " x " + this.down + "]";
// }
// }
//
// Path: puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
// public static class Word implements Serializable {
// public Position start;
// public boolean across;
// public int length;
//
// public boolean checkInWord(int across, int down) {
// int ranging = this.across ? across : down;
// boolean offRanging = this.across ? (down == start.down) : (across == start.across);
//
// int startPos = this.across ? start.across : start.down;
//
// return (offRanging && (startPos <= ranging) && ((startPos + length) > ranging));
// }
//
// @Override
// public boolean equals(Object o) {
// if (o.getClass() != Word.class) {
// return false;
// }
//
// Word check = (Word) o;
//
// return check.start.equals(this.start) && (check.across == this.across) && (check.length == this.length);
// }
//
// @Override
// public int hashCode() {
// int hash = 5;
// hash = (29 * hash) + ((this.start != null) ? this.start.hashCode() : 0);
// hash = (29 * hash) + (this.across ? 1 : 0);
// hash = (29 * hash) + this.length;
//
// return hash;
// }
// }
// Path: puzlib/src/main/java/com/totsp/crossword/puz/MovementStrategy.java
import com.totsp.crossword.puz.Playboard.Position;
import com.totsp.crossword.puz.Playboard.Word;
import java.io.Serializable;
import java.util.Arrays;
package com.totsp.crossword.puz;
public interface MovementStrategy extends Serializable {
class Common {
/**
* @return if @param Word (w) is the last word in its direction in the @param board
*/
static boolean isLastWordInDirection(Playboard board, Word w) {
return isLastWordInDirection(board.getBoxes(), w);
}
/**
* @return if @param Word (w) is the last word in its direction in @param boxes
*/
static boolean isLastWordInDirection(Box[][] boxes, Word w) {
if (w.across) {
return (w.start.across + w.length >= boxes.length);
}
return (w.start.down + w.length >= boxes[w.start.across].length);
}
/**
* @return if @param Position (p) is the last position in @param Word (w)
*/ | static boolean isWordEnd(Position p, Word w) { |
didi/VirtualAPK | CoreLibrary/src/main/java/com/didi/virtualapk/utils/ZipVerifyUtil.java | // Path: CoreLibrary/src/main/java/com/didi/virtualapk/internal/Constants.java
// public class Constants {
// public static final String KEY_IS_PLUGIN = "isPlugin";
// public static final String KEY_TARGET_PACKAGE = "target.package";
// public static final String KEY_TARGET_ACTIVITY = "target.activity";
//
// public static final String OPTIMIZE_DIR = "dex";
// public static final String NATIVE_DIR = "valibs";
//
// public static final boolean COMBINE_RESOURCES = true;
// public static final boolean COMBINE_CLASSLOADER = true;
// public static final boolean DEBUG = true;
//
// public static final String TAG = "VA";
// public static final String TAG_PREFIX = TAG + ".";
//
// }
| import android.content.Context;
import android.util.Base64;
import android.util.Log;
import com.didi.virtualapk.internal.Constants;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; | /*
* Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
*
* 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 com.didi.virtualapk.utils;
/**
* Created by renyugang on 16/5/12.
*/
/**
* verify signature of zip file<br>
* usage: boolean valid = ZipVerifyUtil.verifyZip(context, zipPath)
*/
public class ZipVerifyUtil {
public static boolean verifyZip(Context context, String zipPath) {
return verifyZip(context, zipPath, "test.cer");
}
public static boolean verifyZip(Context context, String zipPath, String cerName) {
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
InputStream in = context.getAssets().open(cerName);
Certificate certificate = certificateFactory.generateCertificate(in);
in.close();
return verifyZip(zipPath, certificate);
} catch (IOException | CertificateException e) { | // Path: CoreLibrary/src/main/java/com/didi/virtualapk/internal/Constants.java
// public class Constants {
// public static final String KEY_IS_PLUGIN = "isPlugin";
// public static final String KEY_TARGET_PACKAGE = "target.package";
// public static final String KEY_TARGET_ACTIVITY = "target.activity";
//
// public static final String OPTIMIZE_DIR = "dex";
// public static final String NATIVE_DIR = "valibs";
//
// public static final boolean COMBINE_RESOURCES = true;
// public static final boolean COMBINE_CLASSLOADER = true;
// public static final boolean DEBUG = true;
//
// public static final String TAG = "VA";
// public static final String TAG_PREFIX = TAG + ".";
//
// }
// Path: CoreLibrary/src/main/java/com/didi/virtualapk/utils/ZipVerifyUtil.java
import android.content.Context;
import android.util.Base64;
import android.util.Log;
import com.didi.virtualapk.internal.Constants;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/*
* Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
*
* 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 com.didi.virtualapk.utils;
/**
* Created by renyugang on 16/5/12.
*/
/**
* verify signature of zip file<br>
* usage: boolean valid = ZipVerifyUtil.verifyZip(context, zipPath)
*/
public class ZipVerifyUtil {
public static boolean verifyZip(Context context, String zipPath) {
return verifyZip(context, zipPath, "test.cer");
}
public static boolean verifyZip(Context context, String zipPath, String cerName) {
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
InputStream in = context.getAssets().open(cerName);
Certificate certificate = certificateFactory.generateCertificate(in);
in.close();
return verifyZip(zipPath, certificate);
} catch (IOException | CertificateException e) { | Log.w(Constants.TAG, e); |
didi/VirtualAPK | CoreLibrary/src/main/java/com/didi/virtualapk/internal/StubActivityInfo.java | // Path: AndroidStub/src/main/java/android/content/res/Resources.java
// public final class Theme {
//
// public void applyStyle(int resId, boolean force) {
// throw new RuntimeException("Stub!");
// }
//
// public TypedArray obtainStyledAttributes(int[] attrs) {
// throw new RuntimeException("Stub!");
// }
//
// public void setTo(Theme other) {
// throw new RuntimeException("Stub!");
// }
//
// }
| import android.content.pm.ActivityInfo;
import android.content.res.TypedArray;
import android.util.Log;
import android.content.res.Resources.Theme;
import java.util.HashMap; | /*
* Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
*
* 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 com.didi.virtualapk.internal;
/**
* Created by renyugang on 16/8/15.
*/
class StubActivityInfo {
public static final int MAX_COUNT_STANDARD = 1;
public static final int MAX_COUNT_SINGLETOP = 8;
public static final int MAX_COUNT_SINGLETASK = 8;
public static final int MAX_COUNT_SINGLEINSTANCE = 8;
public static final String corePackage = "com.didi.virtualapk.core";
public static final String STUB_ACTIVITY_STANDARD = "%s.A$%d";
public static final String STUB_ACTIVITY_SINGLETOP = "%s.B$%d";
public static final String STUB_ACTIVITY_SINGLETASK = "%s.C$%d";
public static final String STUB_ACTIVITY_SINGLEINSTANCE = "%s.D$%d";
public final int usedStandardStubActivity = 1;
public int usedSingleTopStubActivity = 0;
public int usedSingleTaskStubActivity = 0;
public int usedSingleInstanceStubActivity = 0;
private HashMap<String, String> mCachedStubActivity = new HashMap<>();
| // Path: AndroidStub/src/main/java/android/content/res/Resources.java
// public final class Theme {
//
// public void applyStyle(int resId, boolean force) {
// throw new RuntimeException("Stub!");
// }
//
// public TypedArray obtainStyledAttributes(int[] attrs) {
// throw new RuntimeException("Stub!");
// }
//
// public void setTo(Theme other) {
// throw new RuntimeException("Stub!");
// }
//
// }
// Path: CoreLibrary/src/main/java/com/didi/virtualapk/internal/StubActivityInfo.java
import android.content.pm.ActivityInfo;
import android.content.res.TypedArray;
import android.util.Log;
import android.content.res.Resources.Theme;
import java.util.HashMap;
/*
* Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
*
* 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 com.didi.virtualapk.internal;
/**
* Created by renyugang on 16/8/15.
*/
class StubActivityInfo {
public static final int MAX_COUNT_STANDARD = 1;
public static final int MAX_COUNT_SINGLETOP = 8;
public static final int MAX_COUNT_SINGLETASK = 8;
public static final int MAX_COUNT_SINGLEINSTANCE = 8;
public static final String corePackage = "com.didi.virtualapk.core";
public static final String STUB_ACTIVITY_STANDARD = "%s.A$%d";
public static final String STUB_ACTIVITY_SINGLETOP = "%s.B$%d";
public static final String STUB_ACTIVITY_SINGLETASK = "%s.C$%d";
public static final String STUB_ACTIVITY_SINGLEINSTANCE = "%s.D$%d";
public final int usedStandardStubActivity = 1;
public int usedSingleTopStubActivity = 0;
public int usedSingleTaskStubActivity = 0;
public int usedSingleInstanceStubActivity = 0;
private HashMap<String, String> mCachedStubActivity = new HashMap<>();
| public String getStubActivity(String className, int launchMode, Theme theme) { |
didi/VirtualAPK | CoreLibrary/src/main/java/com/didi/virtualapk/internal/PluginContext.java | // Path: AndroidStub/src/main/java/android/content/ContentResolver.java
// public abstract class ContentResolver {
//
// public ContentResolver(Context context) {
// throw new RuntimeException("Stub!");
// }
//
// public final @Nullable
// Bundle call(@NonNull Uri uri, @NonNull String method,
// @Nullable String arg, @Nullable Bundle extras) {
// throw new RuntimeException("Stub!");
// }
//
// protected abstract IContentProvider acquireProvider(Context c, String name);
//
// protected IContentProvider acquireExistingProvider(Context c, String name) {
// throw new RuntimeException("Stub!");
// }
//
// public abstract boolean releaseProvider(IContentProvider icp);
//
// protected abstract IContentProvider acquireUnstableProvider(Context c, String name);
//
// public abstract boolean releaseUnstableProvider(IContentProvider icp);
//
// public abstract void unstableProviderDied(IContentProvider icp);
//
// public void appNotRespondingViaProvider(IContentProvider icp) {
// throw new RuntimeException("Stub!");
// }
// }
//
// Path: AndroidStub/src/main/java/android/content/res/Resources.java
// public class Resources {
//
// public Resources(AssetManager assets, DisplayMetrics metrics, Configuration config) {
// throw new RuntimeException("Stub!");
// }
//
// public final AssetManager getAssets() {
// throw new RuntimeException("Stub!");
// }
//
// public int getColor(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public Configuration getConfiguration() {
// throw new RuntimeException("Stub!");
// }
//
// public DisplayMetrics getDisplayMetrics() {
// throw new RuntimeException("Stub!");
// }
//
// public Drawable getDrawable(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public String getString(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public CharSequence getText(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public XmlResourceParser getXml(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public ResourcesImpl getImpl() {
// throw new RuntimeException("Stub!");
// }
//
// public final Theme newTheme() {
// throw new RuntimeException("Stub!");
// }
//
// public void updateConfiguration(Configuration config, DisplayMetrics metrics) {
// throw new RuntimeException("Stub!");
// }
//
// public final class Theme {
//
// public void applyStyle(int resId, boolean force) {
// throw new RuntimeException("Stub!");
// }
//
// public TypedArray obtainStyledAttributes(int[] attrs) {
// throw new RuntimeException("Stub!");
// }
//
// public void setTo(Theme other) {
// throw new RuntimeException("Stub!");
// }
//
// }
//
// public static class NotFoundException extends RuntimeException {
//
// }
//
// }
| import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources; | /*
* Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
*
* 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 com.didi.virtualapk.internal;
/**
* Created by renyugang on 16/8/12.
*/
class PluginContext extends ContextWrapper {
private final LoadedPlugin mPlugin;
public PluginContext(LoadedPlugin plugin) {
super(plugin.getPluginManager().getHostContext());
this.mPlugin = plugin;
}
public PluginContext(LoadedPlugin plugin, Context base) {
super(base);
this.mPlugin = plugin;
}
@Override
public Context getApplicationContext() {
return this.mPlugin.getApplication();
}
// @Override
// public ApplicationInfo getApplicationInfo() {
// return this.mPlugin.getApplicationInfo();
// }
private Context getHostContext() {
return getBaseContext();
}
@Override | // Path: AndroidStub/src/main/java/android/content/ContentResolver.java
// public abstract class ContentResolver {
//
// public ContentResolver(Context context) {
// throw new RuntimeException("Stub!");
// }
//
// public final @Nullable
// Bundle call(@NonNull Uri uri, @NonNull String method,
// @Nullable String arg, @Nullable Bundle extras) {
// throw new RuntimeException("Stub!");
// }
//
// protected abstract IContentProvider acquireProvider(Context c, String name);
//
// protected IContentProvider acquireExistingProvider(Context c, String name) {
// throw new RuntimeException("Stub!");
// }
//
// public abstract boolean releaseProvider(IContentProvider icp);
//
// protected abstract IContentProvider acquireUnstableProvider(Context c, String name);
//
// public abstract boolean releaseUnstableProvider(IContentProvider icp);
//
// public abstract void unstableProviderDied(IContentProvider icp);
//
// public void appNotRespondingViaProvider(IContentProvider icp) {
// throw new RuntimeException("Stub!");
// }
// }
//
// Path: AndroidStub/src/main/java/android/content/res/Resources.java
// public class Resources {
//
// public Resources(AssetManager assets, DisplayMetrics metrics, Configuration config) {
// throw new RuntimeException("Stub!");
// }
//
// public final AssetManager getAssets() {
// throw new RuntimeException("Stub!");
// }
//
// public int getColor(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public Configuration getConfiguration() {
// throw new RuntimeException("Stub!");
// }
//
// public DisplayMetrics getDisplayMetrics() {
// throw new RuntimeException("Stub!");
// }
//
// public Drawable getDrawable(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public String getString(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public CharSequence getText(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public XmlResourceParser getXml(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public ResourcesImpl getImpl() {
// throw new RuntimeException("Stub!");
// }
//
// public final Theme newTheme() {
// throw new RuntimeException("Stub!");
// }
//
// public void updateConfiguration(Configuration config, DisplayMetrics metrics) {
// throw new RuntimeException("Stub!");
// }
//
// public final class Theme {
//
// public void applyStyle(int resId, boolean force) {
// throw new RuntimeException("Stub!");
// }
//
// public TypedArray obtainStyledAttributes(int[] attrs) {
// throw new RuntimeException("Stub!");
// }
//
// public void setTo(Theme other) {
// throw new RuntimeException("Stub!");
// }
//
// }
//
// public static class NotFoundException extends RuntimeException {
//
// }
//
// }
// Path: CoreLibrary/src/main/java/com/didi/virtualapk/internal/PluginContext.java
import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
/*
* Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
*
* 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 com.didi.virtualapk.internal;
/**
* Created by renyugang on 16/8/12.
*/
class PluginContext extends ContextWrapper {
private final LoadedPlugin mPlugin;
public PluginContext(LoadedPlugin plugin) {
super(plugin.getPluginManager().getHostContext());
this.mPlugin = plugin;
}
public PluginContext(LoadedPlugin plugin, Context base) {
super(base);
this.mPlugin = plugin;
}
@Override
public Context getApplicationContext() {
return this.mPlugin.getApplication();
}
// @Override
// public ApplicationInfo getApplicationInfo() {
// return this.mPlugin.getApplicationInfo();
// }
private Context getHostContext() {
return getBaseContext();
}
@Override | public ContentResolver getContentResolver() { |
didi/VirtualAPK | CoreLibrary/src/main/java/com/didi/virtualapk/internal/PluginContext.java | // Path: AndroidStub/src/main/java/android/content/ContentResolver.java
// public abstract class ContentResolver {
//
// public ContentResolver(Context context) {
// throw new RuntimeException("Stub!");
// }
//
// public final @Nullable
// Bundle call(@NonNull Uri uri, @NonNull String method,
// @Nullable String arg, @Nullable Bundle extras) {
// throw new RuntimeException("Stub!");
// }
//
// protected abstract IContentProvider acquireProvider(Context c, String name);
//
// protected IContentProvider acquireExistingProvider(Context c, String name) {
// throw new RuntimeException("Stub!");
// }
//
// public abstract boolean releaseProvider(IContentProvider icp);
//
// protected abstract IContentProvider acquireUnstableProvider(Context c, String name);
//
// public abstract boolean releaseUnstableProvider(IContentProvider icp);
//
// public abstract void unstableProviderDied(IContentProvider icp);
//
// public void appNotRespondingViaProvider(IContentProvider icp) {
// throw new RuntimeException("Stub!");
// }
// }
//
// Path: AndroidStub/src/main/java/android/content/res/Resources.java
// public class Resources {
//
// public Resources(AssetManager assets, DisplayMetrics metrics, Configuration config) {
// throw new RuntimeException("Stub!");
// }
//
// public final AssetManager getAssets() {
// throw new RuntimeException("Stub!");
// }
//
// public int getColor(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public Configuration getConfiguration() {
// throw new RuntimeException("Stub!");
// }
//
// public DisplayMetrics getDisplayMetrics() {
// throw new RuntimeException("Stub!");
// }
//
// public Drawable getDrawable(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public String getString(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public CharSequence getText(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public XmlResourceParser getXml(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public ResourcesImpl getImpl() {
// throw new RuntimeException("Stub!");
// }
//
// public final Theme newTheme() {
// throw new RuntimeException("Stub!");
// }
//
// public void updateConfiguration(Configuration config, DisplayMetrics metrics) {
// throw new RuntimeException("Stub!");
// }
//
// public final class Theme {
//
// public void applyStyle(int resId, boolean force) {
// throw new RuntimeException("Stub!");
// }
//
// public TypedArray obtainStyledAttributes(int[] attrs) {
// throw new RuntimeException("Stub!");
// }
//
// public void setTo(Theme other) {
// throw new RuntimeException("Stub!");
// }
//
// }
//
// public static class NotFoundException extends RuntimeException {
//
// }
//
// }
| import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources; | // }
// @Override
// public String getPackageResourcePath() {
// return this.mPlugin.getPackageResourcePath();
// }
// @Override
// public String getPackageCodePath() {
// return this.mPlugin.getCodePath();
// }
@Override
public PackageManager getPackageManager() {
return this.mPlugin.getPackageManager();
}
@Override
public Object getSystemService(String name) {
// intercept CLIPBOARD_SERVICE,NOTIFICATION_SERVICE
if (name.equals(Context.CLIPBOARD_SERVICE)) {
return getHostContext().getSystemService(name);
} else if (name.equals(Context.NOTIFICATION_SERVICE)) {
return getHostContext().getSystemService(name);
}
return super.getSystemService(name);
}
@Override | // Path: AndroidStub/src/main/java/android/content/ContentResolver.java
// public abstract class ContentResolver {
//
// public ContentResolver(Context context) {
// throw new RuntimeException("Stub!");
// }
//
// public final @Nullable
// Bundle call(@NonNull Uri uri, @NonNull String method,
// @Nullable String arg, @Nullable Bundle extras) {
// throw new RuntimeException("Stub!");
// }
//
// protected abstract IContentProvider acquireProvider(Context c, String name);
//
// protected IContentProvider acquireExistingProvider(Context c, String name) {
// throw new RuntimeException("Stub!");
// }
//
// public abstract boolean releaseProvider(IContentProvider icp);
//
// protected abstract IContentProvider acquireUnstableProvider(Context c, String name);
//
// public abstract boolean releaseUnstableProvider(IContentProvider icp);
//
// public abstract void unstableProviderDied(IContentProvider icp);
//
// public void appNotRespondingViaProvider(IContentProvider icp) {
// throw new RuntimeException("Stub!");
// }
// }
//
// Path: AndroidStub/src/main/java/android/content/res/Resources.java
// public class Resources {
//
// public Resources(AssetManager assets, DisplayMetrics metrics, Configuration config) {
// throw new RuntimeException("Stub!");
// }
//
// public final AssetManager getAssets() {
// throw new RuntimeException("Stub!");
// }
//
// public int getColor(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public Configuration getConfiguration() {
// throw new RuntimeException("Stub!");
// }
//
// public DisplayMetrics getDisplayMetrics() {
// throw new RuntimeException("Stub!");
// }
//
// public Drawable getDrawable(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public String getString(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public CharSequence getText(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public XmlResourceParser getXml(int id) throws NotFoundException {
// throw new RuntimeException("Stub!");
// }
//
// public ResourcesImpl getImpl() {
// throw new RuntimeException("Stub!");
// }
//
// public final Theme newTheme() {
// throw new RuntimeException("Stub!");
// }
//
// public void updateConfiguration(Configuration config, DisplayMetrics metrics) {
// throw new RuntimeException("Stub!");
// }
//
// public final class Theme {
//
// public void applyStyle(int resId, boolean force) {
// throw new RuntimeException("Stub!");
// }
//
// public TypedArray obtainStyledAttributes(int[] attrs) {
// throw new RuntimeException("Stub!");
// }
//
// public void setTo(Theme other) {
// throw new RuntimeException("Stub!");
// }
//
// }
//
// public static class NotFoundException extends RuntimeException {
//
// }
//
// }
// Path: CoreLibrary/src/main/java/com/didi/virtualapk/internal/PluginContext.java
import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
// }
// @Override
// public String getPackageResourcePath() {
// return this.mPlugin.getPackageResourcePath();
// }
// @Override
// public String getPackageCodePath() {
// return this.mPlugin.getCodePath();
// }
@Override
public PackageManager getPackageManager() {
return this.mPlugin.getPackageManager();
}
@Override
public Object getSystemService(String name) {
// intercept CLIPBOARD_SERVICE,NOTIFICATION_SERVICE
if (name.equals(Context.CLIPBOARD_SERVICE)) {
return getHostContext().getSystemService(name);
} else if (name.equals(Context.NOTIFICATION_SERVICE)) {
return getHostContext().getSystemService(name);
}
return super.getSystemService(name);
}
@Override | public Resources getResources() { |
didi/VirtualAPK | virtualapk-gradle-plugin/src/main/java/com/didi/virtualapk/databinding/annotationprocessor/ProcessDataBinding.java | // Path: virtualapk-gradle-plugin/src/main/java/com/didi/virtualapk/utils/Log.java
// public final class Log {
//
// private Log() {
//
// }
//
// public static int i(String tag, String msg) {
// System.out.println("[INFO][" + tag + "] " + msg);
// return 0;
// }
//
// public static int e(String tag, String msg) {
// System.err.println("[ERROR][" + tag + "] " + msg);
// return 0;
// }
// }
| import com.didi.virtualapk.utils.Log;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
import javax.tools.StandardLocation; | return false;
}
private void readDataBinderMapper() {
BufferedReader reader = null;
BufferedWriter writer = null;
try {
reader = new BufferedReader(fileObject.openReader(false));
String className = DATA_BINDER_MAPPER_CLASS_NAME + "_" + modulePackage.replace('.', '_');
JavaFileObject javaFileObject = processingEnv.getFiler().createSourceFile(DATA_BINDER_MAPPER_PACKAGE + "." + className);
writer = new BufferedWriter(javaFileObject.openWriter());
writer.write("// Generated by VirtualApk gradle plugin.");
writer.newLine();
String line;
while ((line = reader.readLine()) != null) {
if (line.contains(DATA_BINDER_MAPPER_CLASS_NAME)) {
if (line.contains("class")) {
line = line.replace(DATA_BINDER_MAPPER_CLASS_NAME, className + " extends " + DATA_BINDER_MAPPER_CLASS_NAME);
} else {
line = line.replace(DATA_BINDER_MAPPER_CLASS_NAME, className);
}
}
writer.write(line);
writer.newLine();
}
| // Path: virtualapk-gradle-plugin/src/main/java/com/didi/virtualapk/utils/Log.java
// public final class Log {
//
// private Log() {
//
// }
//
// public static int i(String tag, String msg) {
// System.out.println("[INFO][" + tag + "] " + msg);
// return 0;
// }
//
// public static int e(String tag, String msg) {
// System.err.println("[ERROR][" + tag + "] " + msg);
// return 0;
// }
// }
// Path: virtualapk-gradle-plugin/src/main/java/com/didi/virtualapk/databinding/annotationprocessor/ProcessDataBinding.java
import com.didi.virtualapk.utils.Log;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
import javax.tools.StandardLocation;
return false;
}
private void readDataBinderMapper() {
BufferedReader reader = null;
BufferedWriter writer = null;
try {
reader = new BufferedReader(fileObject.openReader(false));
String className = DATA_BINDER_MAPPER_CLASS_NAME + "_" + modulePackage.replace('.', '_');
JavaFileObject javaFileObject = processingEnv.getFiler().createSourceFile(DATA_BINDER_MAPPER_PACKAGE + "." + className);
writer = new BufferedWriter(javaFileObject.openWriter());
writer.write("// Generated by VirtualApk gradle plugin.");
writer.newLine();
String line;
while ((line = reader.readLine()) != null) {
if (line.contains(DATA_BINDER_MAPPER_CLASS_NAME)) {
if (line.contains("class")) {
line = line.replace(DATA_BINDER_MAPPER_CLASS_NAME, className + " extends " + DATA_BINDER_MAPPER_CLASS_NAME);
} else {
line = line.replace(DATA_BINDER_MAPPER_CLASS_NAME, className);
}
}
writer.write(line);
writer.newLine();
}
| Log.i("ProcessDataBinding", "Generated java source file: " + DATA_BINDER_MAPPER_PACKAGE + "." + className); |
didi/VirtualAPK | CoreLibrary/src/main/java/com/didi/virtualapk/utils/RunUtil.java | // Path: CoreLibrary/src/main/java/com/didi/virtualapk/internal/Constants.java
// public class Constants {
// public static final String KEY_IS_PLUGIN = "isPlugin";
// public static final String KEY_TARGET_PACKAGE = "target.package";
// public static final String KEY_TARGET_ACTIVITY = "target.activity";
//
// public static final String OPTIMIZE_DIR = "dex";
// public static final String NATIVE_DIR = "valibs";
//
// public static final boolean COMBINE_RESOURCES = true;
// public static final boolean COMBINE_CLASSLOADER = true;
// public static final boolean DEBUG = true;
//
// public static final String TAG = "VA";
// public static final String TAG_PREFIX = TAG + ".";
//
// }
| import java.util.concurrent.Executor;
import android.app.ActivityManager;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.util.Log;
import android.util.Pair;
import com.didi.virtualapk.internal.Constants;
import java.util.List;
import java.util.concurrent.CountDownLatch; | /*
* Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
*
* 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 com.didi.virtualapk.utils;
/**
* Created by renyugang on 16/11/10.
*/
public class RunUtil {
private static final int MESSAGE_RUN_ON_UITHREAD = 0x1;
private static Handler sHandler;
/**
* execute a runnable on ui thread, then return immediately. see also {@link #runOnUiThread(Runnable, boolean)}
* @param runnable the runnable prepared to run
*/
public static void runOnUiThread(Runnable runnable) {
runOnUiThread(runnable, false);
}
/**
* execute a runnable on ui thread
* @param runnable the runnable prepared to run
* @param waitUtilDone if set true, the caller thread will wait until the specific runnable finished.
*/
public static void runOnUiThread(Runnable runnable, boolean waitUtilDone) {
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
runnable.run();
return;
}
CountDownLatch countDownLatch = null;
if (waitUtilDone) {
countDownLatch = new CountDownLatch(1);
}
Pair<Runnable, CountDownLatch> pair = new Pair<>(runnable, countDownLatch);
getHandler().obtainMessage(MESSAGE_RUN_ON_UITHREAD, pair).sendToTarget();
if (waitUtilDone) {
try {
countDownLatch.await();
} catch (InterruptedException e) { | // Path: CoreLibrary/src/main/java/com/didi/virtualapk/internal/Constants.java
// public class Constants {
// public static final String KEY_IS_PLUGIN = "isPlugin";
// public static final String KEY_TARGET_PACKAGE = "target.package";
// public static final String KEY_TARGET_ACTIVITY = "target.activity";
//
// public static final String OPTIMIZE_DIR = "dex";
// public static final String NATIVE_DIR = "valibs";
//
// public static final boolean COMBINE_RESOURCES = true;
// public static final boolean COMBINE_CLASSLOADER = true;
// public static final boolean DEBUG = true;
//
// public static final String TAG = "VA";
// public static final String TAG_PREFIX = TAG + ".";
//
// }
// Path: CoreLibrary/src/main/java/com/didi/virtualapk/utils/RunUtil.java
import java.util.concurrent.Executor;
import android.app.ActivityManager;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.util.Log;
import android.util.Pair;
import com.didi.virtualapk.internal.Constants;
import java.util.List;
import java.util.concurrent.CountDownLatch;
/*
* Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
*
* 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 com.didi.virtualapk.utils;
/**
* Created by renyugang on 16/11/10.
*/
public class RunUtil {
private static final int MESSAGE_RUN_ON_UITHREAD = 0x1;
private static Handler sHandler;
/**
* execute a runnable on ui thread, then return immediately. see also {@link #runOnUiThread(Runnable, boolean)}
* @param runnable the runnable prepared to run
*/
public static void runOnUiThread(Runnable runnable) {
runOnUiThread(runnable, false);
}
/**
* execute a runnable on ui thread
* @param runnable the runnable prepared to run
* @param waitUtilDone if set true, the caller thread will wait until the specific runnable finished.
*/
public static void runOnUiThread(Runnable runnable, boolean waitUtilDone) {
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
runnable.run();
return;
}
CountDownLatch countDownLatch = null;
if (waitUtilDone) {
countDownLatch = new CountDownLatch(1);
}
Pair<Runnable, CountDownLatch> pair = new Pair<>(runnable, countDownLatch);
getHandler().obtainMessage(MESSAGE_RUN_ON_UITHREAD, pair).sendToTarget();
if (waitUtilDone) {
try {
countDownLatch.await();
} catch (InterruptedException e) { | Log.w(Constants.TAG, e); |
RestNEXT/restnext | restnext-core/src/main/java/org/restnext/core/http/RequestImpl.java | // Path: restnext-util/src/main/java/org/restnext/util/UriUtils.java
// public static String normalize(String uri) {
// return Optional.ofNullable(uri)
// .map(UriUtils::addFirstSlash)
// .map(UriUtils::removeLastSlash)
// .orElse(uri);
// }
| import static io.netty.handler.codec.DateFormatter.parseHttpDate;
import static io.netty.handler.codec.http.HttpHeaderNames.ACCEPT;
import static io.netty.handler.codec.http.HttpHeaderNames.DATE;
import static io.netty.handler.codec.http.HttpHeaderNames.HOST;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_MATCH;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_MODIFIED_SINCE;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_NONE_MATCH;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_UNMODIFIED_SINCE;
import static org.restnext.util.UriUtils.normalize;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpHeaderValues;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpUtil;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.handler.codec.http.multipart.Attribute;
import io.netty.handler.codec.http.multipart.DefaultHttpDataFactory;
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
import io.netty.handler.codec.http.multipart.InterfaceHttpData;
import io.netty.util.AsciiString;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*
* Copyright (C) 2016 Thiago Gutenberg Carvalho da Costa
*
* 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.restnext.core.http;
/**
* Created by thiago on 24/08/16.
*/
public final class RequestImpl implements Request {
private static final Logger LOGGER = LoggerFactory.getLogger(RequestImpl.class);
private final Version version;
private final Method method;
private final URI baseUri;
private final URI uri;
private final boolean keepAlive;
private final MultivaluedMap<String, String> headers;
private final MultivaluedMap<String, String> parameters;
private final Charset charset;
private byte[] content;
/**
* Create a new instance.
*
* @param context netty channel handler context
* @param request netty full http request
*/
public RequestImpl(final ChannelHandlerContext context, final FullHttpRequest request) {
Objects.requireNonNull(request, "request");
Objects.requireNonNull(context, "context");
this.charset = HttpUtil.getCharset(request, StandardCharsets.UTF_8);
this.version = HttpVersion.HTTP_1_0.equals(request.protocolVersion())
? Version.HTTP_1_0
: Version.HTTP_1_1;
this.method = Method.valueOf(request.method().name()); | // Path: restnext-util/src/main/java/org/restnext/util/UriUtils.java
// public static String normalize(String uri) {
// return Optional.ofNullable(uri)
// .map(UriUtils::addFirstSlash)
// .map(UriUtils::removeLastSlash)
// .orElse(uri);
// }
// Path: restnext-core/src/main/java/org/restnext/core/http/RequestImpl.java
import static io.netty.handler.codec.DateFormatter.parseHttpDate;
import static io.netty.handler.codec.http.HttpHeaderNames.ACCEPT;
import static io.netty.handler.codec.http.HttpHeaderNames.DATE;
import static io.netty.handler.codec.http.HttpHeaderNames.HOST;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_MATCH;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_MODIFIED_SINCE;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_NONE_MATCH;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_UNMODIFIED_SINCE;
import static org.restnext.util.UriUtils.normalize;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpHeaderValues;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpUtil;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.handler.codec.http.multipart.Attribute;
import io.netty.handler.codec.http.multipart.DefaultHttpDataFactory;
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
import io.netty.handler.codec.http.multipart.InterfaceHttpData;
import io.netty.util.AsciiString;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright (C) 2016 Thiago Gutenberg Carvalho da Costa
*
* 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.restnext.core.http;
/**
* Created by thiago on 24/08/16.
*/
public final class RequestImpl implements Request {
private static final Logger LOGGER = LoggerFactory.getLogger(RequestImpl.class);
private final Version version;
private final Method method;
private final URI baseUri;
private final URI uri;
private final boolean keepAlive;
private final MultivaluedMap<String, String> headers;
private final MultivaluedMap<String, String> parameters;
private final Charset charset;
private byte[] content;
/**
* Create a new instance.
*
* @param context netty channel handler context
* @param request netty full http request
*/
public RequestImpl(final ChannelHandlerContext context, final FullHttpRequest request) {
Objects.requireNonNull(request, "request");
Objects.requireNonNull(context, "context");
this.charset = HttpUtil.getCharset(request, StandardCharsets.UTF_8);
this.version = HttpVersion.HTTP_1_0.equals(request.protocolVersion())
? Version.HTTP_1_0
: Version.HTTP_1_1;
this.method = Method.valueOf(request.method().name()); | this.uri = URI.create(normalize(request.uri())); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/model/Model.java | // Path: core/client/src/main/java/de/danner_web/studip_client/data/LogItem.java
// public class LogItem {
//
// private Date date;
//
// private String pluginName;
//
// private String content;
//
// public LogItem(Date time, String pluginName, String content) {
// this.date = time;
// this.pluginName = pluginName;
// this.content = content;
// }
//
// /**
// * @return the date
// */
// public Date getDate() {
// return date;
// }
//
// /**
// * @param date
// * the date to set
// */
// public void setDate(Date date) {
// this.date = date;
// }
//
// /**
// * @return the pluginName
// */
// public String getPluginName() {
// return pluginName;
// }
//
// /**
// * @param pluginName
// * the pluginName to set
// */
// public void setPluginName(String pluginName) {
// this.pluginName = pluginName;
// }
//
// /**
// * @return the content
// */
// public String getContent() {
// return content;
// }
//
// /**
// * @param content
// * the content to set
// */
// public void setContent(String content) {
// this.content = content;
// }
//
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginMessage.java
// public abstract class PluginMessage {
//
// private List<ClickListener> listeners = new ArrayList<ClickListener>();
//
// private ClickListener showDetailView = new ClickListener() {
//
// @Override
// public void onClick(PluginMessage message) {
// new PluginMessageDetailsView(message);
// }
// };
//
// public PluginMessage(ClickListener listener) {
// if (listener != null) {
// listeners.add(listener);
// }
// }
//
// public void setShowDetailView(boolean b) {
// if (b) {
// if(!this.listeners.contains(showDetailView)){
// this.listeners.add(showDetailView);
// }
// } else {
// if(this.listeners.contains(showDetailView)){
// this.listeners.remove(showDetailView);
// }
// }
// }
//
// public abstract String getText();
//
// public abstract String getHeader();
//
// public void addMessageListener(ClickListener listener) {
// if (listener != null) {
// this.listeners.add(listener);
// }
// }
//
// public List<ClickListener> getMessageListener() {
// return listeners;
// }
//
// public abstract int hashCode();
//
// public abstract boolean equals(Object obj);
//
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Observable;
import java.util.ResourceBundle;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.danner_web.studip_client.data.LogItem;
import de.danner_web.studip_client.data.PluginMessage; | package de.danner_web.studip_client.model;
public class Model extends Observable {
/**
* Logger dieser Klasse.
*/
private static Logger logger = LogManager.getLogger(Model.class);
private static final int MAX_LOG_MESSAGES = 100;
/**
* Speichert das zur Lokalisierung der Clientanwendung verwendete
* <code>Locale</code>.
*/
private Locale currentLocale;
private PluginModel pluginModel;
private SettingsModel settings;
| // Path: core/client/src/main/java/de/danner_web/studip_client/data/LogItem.java
// public class LogItem {
//
// private Date date;
//
// private String pluginName;
//
// private String content;
//
// public LogItem(Date time, String pluginName, String content) {
// this.date = time;
// this.pluginName = pluginName;
// this.content = content;
// }
//
// /**
// * @return the date
// */
// public Date getDate() {
// return date;
// }
//
// /**
// * @param date
// * the date to set
// */
// public void setDate(Date date) {
// this.date = date;
// }
//
// /**
// * @return the pluginName
// */
// public String getPluginName() {
// return pluginName;
// }
//
// /**
// * @param pluginName
// * the pluginName to set
// */
// public void setPluginName(String pluginName) {
// this.pluginName = pluginName;
// }
//
// /**
// * @return the content
// */
// public String getContent() {
// return content;
// }
//
// /**
// * @param content
// * the content to set
// */
// public void setContent(String content) {
// this.content = content;
// }
//
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginMessage.java
// public abstract class PluginMessage {
//
// private List<ClickListener> listeners = new ArrayList<ClickListener>();
//
// private ClickListener showDetailView = new ClickListener() {
//
// @Override
// public void onClick(PluginMessage message) {
// new PluginMessageDetailsView(message);
// }
// };
//
// public PluginMessage(ClickListener listener) {
// if (listener != null) {
// listeners.add(listener);
// }
// }
//
// public void setShowDetailView(boolean b) {
// if (b) {
// if(!this.listeners.contains(showDetailView)){
// this.listeners.add(showDetailView);
// }
// } else {
// if(this.listeners.contains(showDetailView)){
// this.listeners.remove(showDetailView);
// }
// }
// }
//
// public abstract String getText();
//
// public abstract String getHeader();
//
// public void addMessageListener(ClickListener listener) {
// if (listener != null) {
// this.listeners.add(listener);
// }
// }
//
// public List<ClickListener> getMessageListener() {
// return listeners;
// }
//
// public abstract int hashCode();
//
// public abstract boolean equals(Object obj);
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/model/Model.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Observable;
import java.util.ResourceBundle;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.danner_web.studip_client.data.LogItem;
import de.danner_web.studip_client.data.PluginMessage;
package de.danner_web.studip_client.model;
public class Model extends Observable {
/**
* Logger dieser Klasse.
*/
private static Logger logger = LogManager.getLogger(Model.class);
private static final int MAX_LOG_MESSAGES = 100;
/**
* Speichert das zur Lokalisierung der Clientanwendung verwendete
* <code>Locale</code>.
*/
private Locale currentLocale;
private PluginModel pluginModel;
private SettingsModel settings;
| private List<LogItem> loggingList; |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/model/Model.java | // Path: core/client/src/main/java/de/danner_web/studip_client/data/LogItem.java
// public class LogItem {
//
// private Date date;
//
// private String pluginName;
//
// private String content;
//
// public LogItem(Date time, String pluginName, String content) {
// this.date = time;
// this.pluginName = pluginName;
// this.content = content;
// }
//
// /**
// * @return the date
// */
// public Date getDate() {
// return date;
// }
//
// /**
// * @param date
// * the date to set
// */
// public void setDate(Date date) {
// this.date = date;
// }
//
// /**
// * @return the pluginName
// */
// public String getPluginName() {
// return pluginName;
// }
//
// /**
// * @param pluginName
// * the pluginName to set
// */
// public void setPluginName(String pluginName) {
// this.pluginName = pluginName;
// }
//
// /**
// * @return the content
// */
// public String getContent() {
// return content;
// }
//
// /**
// * @param content
// * the content to set
// */
// public void setContent(String content) {
// this.content = content;
// }
//
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginMessage.java
// public abstract class PluginMessage {
//
// private List<ClickListener> listeners = new ArrayList<ClickListener>();
//
// private ClickListener showDetailView = new ClickListener() {
//
// @Override
// public void onClick(PluginMessage message) {
// new PluginMessageDetailsView(message);
// }
// };
//
// public PluginMessage(ClickListener listener) {
// if (listener != null) {
// listeners.add(listener);
// }
// }
//
// public void setShowDetailView(boolean b) {
// if (b) {
// if(!this.listeners.contains(showDetailView)){
// this.listeners.add(showDetailView);
// }
// } else {
// if(this.listeners.contains(showDetailView)){
// this.listeners.remove(showDetailView);
// }
// }
// }
//
// public abstract String getText();
//
// public abstract String getHeader();
//
// public void addMessageListener(ClickListener listener) {
// if (listener != null) {
// this.listeners.add(listener);
// }
// }
//
// public List<ClickListener> getMessageListener() {
// return listeners;
// }
//
// public abstract int hashCode();
//
// public abstract boolean equals(Object obj);
//
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Observable;
import java.util.ResourceBundle;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.danner_web.studip_client.data.LogItem;
import de.danner_web.studip_client.data.PluginMessage; |
public void appendHistory(String name, String content) {
logger.entry(name);
if (name == null) {
throw logger.throwing(new IllegalArgumentException(
"Pluginname and content should not be null"));
}
Date date = new Date(System.currentTimeMillis());
if (loggingList.size() >= MAX_LOG_MESSAGES) {
loggingList.remove(0);
}
LogItem item = new LogItem(date, name, content);
loggingList.add(item);
setChanged();
notifyObservers(item);
logger.exit();
}
/**
*
* @param header
* Überschrift des Popups
* @param text
* Nachricht
*/ | // Path: core/client/src/main/java/de/danner_web/studip_client/data/LogItem.java
// public class LogItem {
//
// private Date date;
//
// private String pluginName;
//
// private String content;
//
// public LogItem(Date time, String pluginName, String content) {
// this.date = time;
// this.pluginName = pluginName;
// this.content = content;
// }
//
// /**
// * @return the date
// */
// public Date getDate() {
// return date;
// }
//
// /**
// * @param date
// * the date to set
// */
// public void setDate(Date date) {
// this.date = date;
// }
//
// /**
// * @return the pluginName
// */
// public String getPluginName() {
// return pluginName;
// }
//
// /**
// * @param pluginName
// * the pluginName to set
// */
// public void setPluginName(String pluginName) {
// this.pluginName = pluginName;
// }
//
// /**
// * @return the content
// */
// public String getContent() {
// return content;
// }
//
// /**
// * @param content
// * the content to set
// */
// public void setContent(String content) {
// this.content = content;
// }
//
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginMessage.java
// public abstract class PluginMessage {
//
// private List<ClickListener> listeners = new ArrayList<ClickListener>();
//
// private ClickListener showDetailView = new ClickListener() {
//
// @Override
// public void onClick(PluginMessage message) {
// new PluginMessageDetailsView(message);
// }
// };
//
// public PluginMessage(ClickListener listener) {
// if (listener != null) {
// listeners.add(listener);
// }
// }
//
// public void setShowDetailView(boolean b) {
// if (b) {
// if(!this.listeners.contains(showDetailView)){
// this.listeners.add(showDetailView);
// }
// } else {
// if(this.listeners.contains(showDetailView)){
// this.listeners.remove(showDetailView);
// }
// }
// }
//
// public abstract String getText();
//
// public abstract String getHeader();
//
// public void addMessageListener(ClickListener listener) {
// if (listener != null) {
// this.listeners.add(listener);
// }
// }
//
// public List<ClickListener> getMessageListener() {
// return listeners;
// }
//
// public abstract int hashCode();
//
// public abstract boolean equals(Object obj);
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/model/Model.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Observable;
import java.util.ResourceBundle;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.danner_web.studip_client.data.LogItem;
import de.danner_web.studip_client.data.PluginMessage;
public void appendHistory(String name, String content) {
logger.entry(name);
if (name == null) {
throw logger.throwing(new IllegalArgumentException(
"Pluginname and content should not be null"));
}
Date date = new Date(System.currentTimeMillis());
if (loggingList.size() >= MAX_LOG_MESSAGES) {
loggingList.remove(0);
}
LogItem item = new LogItem(date, name, content);
loggingList.add(item);
setChanged();
notifyObservers(item);
logger.exit();
}
/**
*
* @param header
* Überschrift des Popups
* @param text
* Nachricht
*/ | public void appendPopup(PluginMessage message) { |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/ActionButton.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/ResourceLoader.java
// public class ResourceLoader {
//
// /**
// * This method generates an URL to the resource specified by the input path
// *
// * @param path
// * @return URL to the resource
// */
// public static URL getURL(String path) {
// return ResourceLoader.class.getClassLoader().getResource(path);
// }
//
// /**
// * This method generates a SVGIcon from the svg with the given path
// *
// * @param path
// * to a svg graphic
// * @return SVGIcon of the path
// */
// public static SVGIcon getSVGIcon(String path) {
// // Read SVG Image from jar File
// InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
// // Load SVG Image Stream to SVG Cache
// URI uri = SVGCache.getSVGUniverse().loadSVG(reader, path);
// SVGIcon svgicon = new SVGIcon();
// svgicon.setAntiAlias(true);
// svgicon.setScaleToFit(true);
// svgicon.setSvgURI(uri);
//
// return svgicon;
// }
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JButton;
import com.kitfox.svg.SVGCache;
import com.kitfox.svg.SVGElement;
import com.kitfox.svg.SVGElementException;
import com.kitfox.svg.animation.AnimationElement;
import com.kitfox.svg.app.beans.SVGIcon;
import de.danner_web.studip_client.utils.ResourceLoader;
import de.danner_web.studip_client.utils.Template; | package de.danner_web.studip_client.view.components.buttons;
public class ActionButton extends JButton {
private static final long serialVersionUID = 660817787015769043L;
// private Image imgDefault, imgHover, imgInactive;
private SVGIcon icon;
private static final int HEIGHT = 28;
private static final int WIDTH = HEIGHT;
private boolean active = false;
public enum ActionType {
DELETE, ADD, SETTINGS, ACTIVATE
}
public ActionButton(ActionType type) {
super();
this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setFocusPainted(false);
// Load icon for type
switch (type) {
case DELETE: | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/ResourceLoader.java
// public class ResourceLoader {
//
// /**
// * This method generates an URL to the resource specified by the input path
// *
// * @param path
// * @return URL to the resource
// */
// public static URL getURL(String path) {
// return ResourceLoader.class.getClassLoader().getResource(path);
// }
//
// /**
// * This method generates a SVGIcon from the svg with the given path
// *
// * @param path
// * to a svg graphic
// * @return SVGIcon of the path
// */
// public static SVGIcon getSVGIcon(String path) {
// // Read SVG Image from jar File
// InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
// // Load SVG Image Stream to SVG Cache
// URI uri = SVGCache.getSVGUniverse().loadSVG(reader, path);
// SVGIcon svgicon = new SVGIcon();
// svgicon.setAntiAlias(true);
// svgicon.setScaleToFit(true);
// svgicon.setSvgURI(uri);
//
// return svgicon;
// }
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/ActionButton.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JButton;
import com.kitfox.svg.SVGCache;
import com.kitfox.svg.SVGElement;
import com.kitfox.svg.SVGElementException;
import com.kitfox.svg.animation.AnimationElement;
import com.kitfox.svg.app.beans.SVGIcon;
import de.danner_web.studip_client.utils.ResourceLoader;
import de.danner_web.studip_client.utils.Template;
package de.danner_web.studip_client.view.components.buttons;
public class ActionButton extends JButton {
private static final long serialVersionUID = 660817787015769043L;
// private Image imgDefault, imgHover, imgInactive;
private SVGIcon icon;
private static final int HEIGHT = 28;
private static final int WIDTH = HEIGHT;
private boolean active = false;
public enum ActionType {
DELETE, ADD, SETTINGS, ACTIVATE
}
public ActionButton(ActionType type) {
super();
this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setFocusPainted(false);
// Load icon for type
switch (type) {
case DELETE: | icon = ResourceLoader.getSVGIcon(Template.PLUGIN_DELETE); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/ActionButton.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/ResourceLoader.java
// public class ResourceLoader {
//
// /**
// * This method generates an URL to the resource specified by the input path
// *
// * @param path
// * @return URL to the resource
// */
// public static URL getURL(String path) {
// return ResourceLoader.class.getClassLoader().getResource(path);
// }
//
// /**
// * This method generates a SVGIcon from the svg with the given path
// *
// * @param path
// * to a svg graphic
// * @return SVGIcon of the path
// */
// public static SVGIcon getSVGIcon(String path) {
// // Read SVG Image from jar File
// InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
// // Load SVG Image Stream to SVG Cache
// URI uri = SVGCache.getSVGUniverse().loadSVG(reader, path);
// SVGIcon svgicon = new SVGIcon();
// svgicon.setAntiAlias(true);
// svgicon.setScaleToFit(true);
// svgicon.setSvgURI(uri);
//
// return svgicon;
// }
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JButton;
import com.kitfox.svg.SVGCache;
import com.kitfox.svg.SVGElement;
import com.kitfox.svg.SVGElementException;
import com.kitfox.svg.animation.AnimationElement;
import com.kitfox.svg.app.beans.SVGIcon;
import de.danner_web.studip_client.utils.ResourceLoader;
import de.danner_web.studip_client.utils.Template; | package de.danner_web.studip_client.view.components.buttons;
public class ActionButton extends JButton {
private static final long serialVersionUID = 660817787015769043L;
// private Image imgDefault, imgHover, imgInactive;
private SVGIcon icon;
private static final int HEIGHT = 28;
private static final int WIDTH = HEIGHT;
private boolean active = false;
public enum ActionType {
DELETE, ADD, SETTINGS, ACTIVATE
}
public ActionButton(ActionType type) {
super();
this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setFocusPainted(false);
// Load icon for type
switch (type) {
case DELETE: | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/ResourceLoader.java
// public class ResourceLoader {
//
// /**
// * This method generates an URL to the resource specified by the input path
// *
// * @param path
// * @return URL to the resource
// */
// public static URL getURL(String path) {
// return ResourceLoader.class.getClassLoader().getResource(path);
// }
//
// /**
// * This method generates a SVGIcon from the svg with the given path
// *
// * @param path
// * to a svg graphic
// * @return SVGIcon of the path
// */
// public static SVGIcon getSVGIcon(String path) {
// // Read SVG Image from jar File
// InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
// // Load SVG Image Stream to SVG Cache
// URI uri = SVGCache.getSVGUniverse().loadSVG(reader, path);
// SVGIcon svgicon = new SVGIcon();
// svgicon.setAntiAlias(true);
// svgicon.setScaleToFit(true);
// svgicon.setSvgURI(uri);
//
// return svgicon;
// }
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/ActionButton.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JButton;
import com.kitfox.svg.SVGCache;
import com.kitfox.svg.SVGElement;
import com.kitfox.svg.SVGElementException;
import com.kitfox.svg.animation.AnimationElement;
import com.kitfox.svg.app.beans.SVGIcon;
import de.danner_web.studip_client.utils.ResourceLoader;
import de.danner_web.studip_client.utils.Template;
package de.danner_web.studip_client.view.components.buttons;
public class ActionButton extends JButton {
private static final long serialVersionUID = 660817787015769043L;
// private Image imgDefault, imgHover, imgInactive;
private SVGIcon icon;
private static final int HEIGHT = 28;
private static final int WIDTH = HEIGHT;
private boolean active = false;
public enum ActionType {
DELETE, ADD, SETTINGS, ACTIVATE
}
public ActionButton(ActionType type) {
super();
this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setFocusPainted(false);
// Load icon for type
switch (type) {
case DELETE: | icon = ResourceLoader.getSVGIcon(Template.PLUGIN_DELETE); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/BackButton.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/ResourceLoader.java
// public class ResourceLoader {
//
// /**
// * This method generates an URL to the resource specified by the input path
// *
// * @param path
// * @return URL to the resource
// */
// public static URL getURL(String path) {
// return ResourceLoader.class.getClassLoader().getResource(path);
// }
//
// /**
// * This method generates a SVGIcon from the svg with the given path
// *
// * @param path
// * to a svg graphic
// * @return SVGIcon of the path
// */
// public static SVGIcon getSVGIcon(String path) {
// // Read SVG Image from jar File
// InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
// // Load SVG Image Stream to SVG Cache
// URI uri = SVGCache.getSVGUniverse().loadSVG(reader, path);
// SVGIcon svgicon = new SVGIcon();
// svgicon.setAntiAlias(true);
// svgicon.setScaleToFit(true);
// svgicon.setSvgURI(uri);
//
// return svgicon;
// }
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import de.danner_web.studip_client.utils.ResourceLoader;
import de.danner_web.studip_client.utils.Template; | package de.danner_web.studip_client.view.components.buttons;
public class BackButton extends JButton {
/**
*
*/
private static final long serialVersionUID = -6151848541312977281L;
private Image arrow_back, arrow_back_hover;
public BackButton() {
super();
this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setFocusPainted(false);
try { | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/ResourceLoader.java
// public class ResourceLoader {
//
// /**
// * This method generates an URL to the resource specified by the input path
// *
// * @param path
// * @return URL to the resource
// */
// public static URL getURL(String path) {
// return ResourceLoader.class.getClassLoader().getResource(path);
// }
//
// /**
// * This method generates a SVGIcon from the svg with the given path
// *
// * @param path
// * to a svg graphic
// * @return SVGIcon of the path
// */
// public static SVGIcon getSVGIcon(String path) {
// // Read SVG Image from jar File
// InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
// // Load SVG Image Stream to SVG Cache
// URI uri = SVGCache.getSVGUniverse().loadSVG(reader, path);
// SVGIcon svgicon = new SVGIcon();
// svgicon.setAntiAlias(true);
// svgicon.setScaleToFit(true);
// svgicon.setSvgURI(uri);
//
// return svgicon;
// }
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/BackButton.java
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import de.danner_web.studip_client.utils.ResourceLoader;
import de.danner_web.studip_client.utils.Template;
package de.danner_web.studip_client.view.components.buttons;
public class BackButton extends JButton {
/**
*
*/
private static final long serialVersionUID = -6151848541312977281L;
private Image arrow_back, arrow_back_hover;
public BackButton() {
super();
this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setFocusPainted(false);
try { | arrow_back = ImageIO.read(ResourceLoader.getURL(Template.BACK_BUTTON)); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/BackButton.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/ResourceLoader.java
// public class ResourceLoader {
//
// /**
// * This method generates an URL to the resource specified by the input path
// *
// * @param path
// * @return URL to the resource
// */
// public static URL getURL(String path) {
// return ResourceLoader.class.getClassLoader().getResource(path);
// }
//
// /**
// * This method generates a SVGIcon from the svg with the given path
// *
// * @param path
// * to a svg graphic
// * @return SVGIcon of the path
// */
// public static SVGIcon getSVGIcon(String path) {
// // Read SVG Image from jar File
// InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
// // Load SVG Image Stream to SVG Cache
// URI uri = SVGCache.getSVGUniverse().loadSVG(reader, path);
// SVGIcon svgicon = new SVGIcon();
// svgicon.setAntiAlias(true);
// svgicon.setScaleToFit(true);
// svgicon.setSvgURI(uri);
//
// return svgicon;
// }
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import de.danner_web.studip_client.utils.ResourceLoader;
import de.danner_web.studip_client.utils.Template; | package de.danner_web.studip_client.view.components.buttons;
public class BackButton extends JButton {
/**
*
*/
private static final long serialVersionUID = -6151848541312977281L;
private Image arrow_back, arrow_back_hover;
public BackButton() {
super();
this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setFocusPainted(false);
try { | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/ResourceLoader.java
// public class ResourceLoader {
//
// /**
// * This method generates an URL to the resource specified by the input path
// *
// * @param path
// * @return URL to the resource
// */
// public static URL getURL(String path) {
// return ResourceLoader.class.getClassLoader().getResource(path);
// }
//
// /**
// * This method generates a SVGIcon from the svg with the given path
// *
// * @param path
// * to a svg graphic
// * @return SVGIcon of the path
// */
// public static SVGIcon getSVGIcon(String path) {
// // Read SVG Image from jar File
// InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
// // Load SVG Image Stream to SVG Cache
// URI uri = SVGCache.getSVGUniverse().loadSVG(reader, path);
// SVGIcon svgicon = new SVGIcon();
// svgicon.setAntiAlias(true);
// svgicon.setScaleToFit(true);
// svgicon.setSvgURI(uri);
//
// return svgicon;
// }
// }
//
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/BackButton.java
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import de.danner_web.studip_client.utils.ResourceLoader;
import de.danner_web.studip_client.utils.Template;
package de.danner_web.studip_client.view.components.buttons;
public class BackButton extends JButton {
/**
*
*/
private static final long serialVersionUID = -6151848541312977281L;
private Image arrow_back, arrow_back_hover;
public BackButton() {
super();
this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setFocusPainted(false);
try { | arrow_back = ImageIO.read(ResourceLoader.getURL(Template.BACK_BUTTON)); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/ModernScrollPane.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import javax.swing.*;
import javax.swing.plaf.basic.BasicScrollBarUI;
import de.danner_web.studip_client.utils.Template;
import java.awt.*; | package de.danner_web.studip_client.view.components;
/**
* This is an implementation of a JScrollPane with a modern UI
*
* @author Philipp
*
*/
public class ModernScrollPane extends JScrollPane {
private static final long serialVersionUID = 8607734981506765935L;
private static final int SCROLL_BAR_ALPHA_ROLLOVER = 100;
private static final int SCROLL_BAR_ALPHA = 50;
private static final int THUMB_SIZE = 8;
private static final int SB_SIZE = 10; | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/ModernScrollPane.java
import javax.swing.*;
import javax.swing.plaf.basic.BasicScrollBarUI;
import de.danner_web.studip_client.utils.Template;
import java.awt.*;
package de.danner_web.studip_client.view.components;
/**
* This is an implementation of a JScrollPane with a modern UI
*
* @author Philipp
*
*/
public class ModernScrollPane extends JScrollPane {
private static final long serialVersionUID = 8607734981506765935L;
private static final int SCROLL_BAR_ALPHA_ROLLOVER = 100;
private static final int SCROLL_BAR_ALPHA = 50;
private static final int THUMB_SIZE = 8;
private static final int SB_SIZE = 10; | private static final Color THUMB_COLOR = Template.COLOR_DARK_GRAY; |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/model/Context.java | // Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginMessage.java
// public abstract class PluginMessage {
//
// private List<ClickListener> listeners = new ArrayList<ClickListener>();
//
// private ClickListener showDetailView = new ClickListener() {
//
// @Override
// public void onClick(PluginMessage message) {
// new PluginMessageDetailsView(message);
// }
// };
//
// public PluginMessage(ClickListener listener) {
// if (listener != null) {
// listeners.add(listener);
// }
// }
//
// public void setShowDetailView(boolean b) {
// if (b) {
// if(!this.listeners.contains(showDetailView)){
// this.listeners.add(showDetailView);
// }
// } else {
// if(this.listeners.contains(showDetailView)){
// this.listeners.remove(showDetailView);
// }
// }
// }
//
// public abstract String getText();
//
// public abstract String getHeader();
//
// public void addMessageListener(ClickListener listener) {
// if (listener != null) {
// this.listeners.add(listener);
// }
// }
//
// public List<ClickListener> getMessageListener() {
// return listeners;
// }
//
// public abstract int hashCode();
//
// public abstract boolean equals(Object obj);
//
// }
| import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.danner_web.studip_client.data.PluginMessage; | package de.danner_web.studip_client.model;
/**
* Diese Singleton Klasse bietet allgemeine Funtkionen, die ein Plugin aufrufen
* kann.
*
*
* @author dominik
*
*/
public class Context {
private Model model;
private String name;
/**
* Logger dieser Klasse.
*/
private static Logger logger = LogManager.getLogger();
/**
* Konstuktor des Context
*
* @param model
* für den Zugriff
*/
Context(Model model) {
this.model = model;
}
private void setName(String name){
this.name = name;
}
Context createContextForPlugin(String name) {
Context newContext = new Context(model);
newContext.setName(name);
return newContext;
}
/**
* Fügt einen Historyeintrag in der Verlaufsanzeigen hinzu.
*
* Dieser Eintrag wird gleichzeitig mit Log4j persistent weggespeichert.
*
* @param name
* Name des Plugins
* @param text
* Nachricht
*/
public void appendHistory(String text) {
model.appendHistory(name, text);
logger.info("History: " + name + ": " + text);
}
/**
* Fügt eine Popup Nachricht hinzu.
*
* Diese Nachricht wird gleichzeitig im Verlauf aufgenommen und mit Log4j
* persistent weggespeichert.
*
*
* @param name
* Name des Plugins
* @param header
* Überschrift der Nachricht
* @param text
* Nachricht
*/ | // Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginMessage.java
// public abstract class PluginMessage {
//
// private List<ClickListener> listeners = new ArrayList<ClickListener>();
//
// private ClickListener showDetailView = new ClickListener() {
//
// @Override
// public void onClick(PluginMessage message) {
// new PluginMessageDetailsView(message);
// }
// };
//
// public PluginMessage(ClickListener listener) {
// if (listener != null) {
// listeners.add(listener);
// }
// }
//
// public void setShowDetailView(boolean b) {
// if (b) {
// if(!this.listeners.contains(showDetailView)){
// this.listeners.add(showDetailView);
// }
// } else {
// if(this.listeners.contains(showDetailView)){
// this.listeners.remove(showDetailView);
// }
// }
// }
//
// public abstract String getText();
//
// public abstract String getHeader();
//
// public void addMessageListener(ClickListener listener) {
// if (listener != null) {
// this.listeners.add(listener);
// }
// }
//
// public List<ClickListener> getMessageListener() {
// return listeners;
// }
//
// public abstract int hashCode();
//
// public abstract boolean equals(Object obj);
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/model/Context.java
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.danner_web.studip_client.data.PluginMessage;
package de.danner_web.studip_client.model;
/**
* Diese Singleton Klasse bietet allgemeine Funtkionen, die ein Plugin aufrufen
* kann.
*
*
* @author dominik
*
*/
public class Context {
private Model model;
private String name;
/**
* Logger dieser Klasse.
*/
private static Logger logger = LogManager.getLogger();
/**
* Konstuktor des Context
*
* @param model
* für den Zugriff
*/
Context(Model model) {
this.model = model;
}
private void setName(String name){
this.name = name;
}
Context createContextForPlugin(String name) {
Context newContext = new Context(model);
newContext.setName(name);
return newContext;
}
/**
* Fügt einen Historyeintrag in der Verlaufsanzeigen hinzu.
*
* Dieser Eintrag wird gleichzeitig mit Log4j persistent weggespeichert.
*
* @param name
* Name des Plugins
* @param text
* Nachricht
*/
public void appendHistory(String text) {
model.appendHistory(name, text);
logger.info("History: " + name + ": " + text);
}
/**
* Fügt eine Popup Nachricht hinzu.
*
* Diese Nachricht wird gleichzeitig im Verlauf aufgenommen und mit Log4j
* persistent weggespeichert.
*
*
* @param name
* Name des Plugins
* @param header
* Überschrift der Nachricht
* @param text
* Nachricht
*/ | public void appendPopup(PluginMessage message) { |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/ModernSlider.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import javax.swing.BoundedRangeModel;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.JComponent;
import javax.swing.JSlider;
import javax.swing.plaf.basic.BasicSliderUI;
import de.danner_web.studip_client.utils.Template; | final int THUMB_SIZE = 13;
public CustomSliderUI(JSlider b) {
super(b);
}
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
}
@Override
protected Dimension getThumbSize() {
return new Dimension(THUMB_SIZE, THUMB_SIZE);
}
@Override
public void paintTrack(Graphics g) {
Color saved_color = g.getColor();
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int height = (thumbRect.height / 5 == 0) ? 1 : thumbRect.height / 5;
int width;
// Blue track
width = trackRect.width - (trackRect.width - thumbRect.x);
Point a = new Point(trackRect.x, trackRect.y + 1);
a.translate(0, (trackRect.height / 2) - (height / 2)); | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/ModernSlider.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import javax.swing.BoundedRangeModel;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.JComponent;
import javax.swing.JSlider;
import javax.swing.plaf.basic.BasicSliderUI;
import de.danner_web.studip_client.utils.Template;
final int THUMB_SIZE = 13;
public CustomSliderUI(JSlider b) {
super(b);
}
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
}
@Override
protected Dimension getThumbSize() {
return new Dimension(THUMB_SIZE, THUMB_SIZE);
}
@Override
public void paintTrack(Graphics g) {
Color saved_color = g.getColor();
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int height = (thumbRect.height / 5 == 0) ? 1 : thumbRect.height / 5;
int width;
// Blue track
width = trackRect.width - (trackRect.width - thumbRect.x);
Point a = new Point(trackRect.x, trackRect.y + 1);
a.translate(0, (trackRect.height / 2) - (height / 2)); | g.setColor(Template.COLOR_ACCENT); |
CollapsedDom/Stud.IP-Client | core/updater/src/main/java/de/danner_web/studip_client/model/UpdateModel.java | // Path: core/client/src/main/java/de/danner_web/studip_client/Starter.java
// public class Starter {
//
// /**
// * Logger dieser Klasse.
// */
// // private static Logger logger = LogManager.getLogger(Starter.class);
//
// public static String getClientVersion() {
// Properties prop = new Properties();
// try {
// InputStream resourceAsStream = Starter.class.getResourceAsStream("/version.properties");
// prop.load(resourceAsStream);
// } catch (IOException e) {
// e.printStackTrace();
// }
// return prop.getProperty("version");
// }
//
// public static void onUpdate(SettingsModel settings) {
// String oldVersion = settings.getVersion();
//
// File updaterNew = new File("updater_new.jar");
// if (updaterNew.exists()) {
// try {
// Files.copy(updaterNew.toPath(), new File("updater.jar").toPath(), StandardCopyOption.REPLACE_EXISTING);
// } catch (IOException e) {
// e.printStackTrace();
// }
// try {
// Files.delete(updaterNew.toPath());
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// if (VersionUtil.compareVersions(oldVersion, getClientVersion()) < 0) {
//
// /*
// * Add Update for new version here
// *
// * If you want to update the update.jar you can do this here!
// */
// // if (VersionUtil.compareVersions(oldVersion, "0.0.1") < 0) {
// // // EXAMPLE database changes from 0.0.1 on: add new Param to the
// // // Map of SettingsModel
// // }
// // if (VersionUtil.compareVersions(oldVersion, "0.1.0") < 0) {
// // // EXAMPLE database changes from 0.1.0 on: add new Param to the
// // // Map of SettingsModel
// // }
// // ...
// settings.setVersion(getClientVersion());
// }
// }
//
// /**
// * Entry Method for StudIP Client
// *
// * @param args
// * no args are needed.
// */
// public static void main(String[] args) {
//
// if (args.length == 1 && "-d".equals(args[0])) {
// System.out.println("Delete Preferences from this Application");
// Preferences rootPref = Preferences.userNodeForPackage(Starter.class);
// try {
// rootPref.removeNode();
// } catch (BackingStoreException e) {
// e.printStackTrace();
// System.exit(1);
// }
// System.exit(0);
// }
//
// if (args.length == 1 && "-v".equals(args[0])) {
// System.out.println(getClientVersion());
// System.exit(0);
// }
//
// // Workaround for Bug #JDK-7075600, does not work proper
// System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
//
// // Bootstrap
// Model model = new Model();
// SettingsModel settings = model.getSettingsModel();
//
// // Update install folder to provide portability
// settings.setInstallFolder(System.getProperty("user.dir"));
//
// // Check on every start if the Client got updated, if yes perform some
// // changes.
// Starter.onUpdate(model.getSettingsModel());
//
// model.getPluginModel().init();
// new ViewController(model);
// }
// }
| import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ProcessBuilder.Redirect;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Enumeration;
import java.util.Observable;
import java.util.Vector;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import java.util.zip.ZipEntry;
import de.danner_web.studip_client.Starter; | package de.danner_web.studip_client.model;
public class UpdateModel extends Observable {
private int progress = 1;
private String status = "";
/**
* This Path points to the Location where the Client is installed
*/
private Path clientLocation;
// Names for settings, also in registry/XML file
private static final String INSTALL_ID = "installID";
private static final String AUTOUPDATE = "autoUpdate";
private static final String VERSION = "client_version";
/**
* Info extracted from prefs
*/
private String version;
private String id;
private boolean autoUpdate;
private String clientApp = null;
/**
* Temporary Path to download update.jar and extract it
*/
private Path tmpDir, extractedPath;
public UpdateModel() {
extractPrefs();
clientLocation = (new File(System.getProperty("user.dir"))).toPath();
clientApp = clientLocation + File.separator + "StudIP_Client.jar";
}
private void extractPrefs() {
// Insert default values
this.autoUpdate = true;
this.version = "0";
this.id = "1";
// Load from prefs if possible
try { | // Path: core/client/src/main/java/de/danner_web/studip_client/Starter.java
// public class Starter {
//
// /**
// * Logger dieser Klasse.
// */
// // private static Logger logger = LogManager.getLogger(Starter.class);
//
// public static String getClientVersion() {
// Properties prop = new Properties();
// try {
// InputStream resourceAsStream = Starter.class.getResourceAsStream("/version.properties");
// prop.load(resourceAsStream);
// } catch (IOException e) {
// e.printStackTrace();
// }
// return prop.getProperty("version");
// }
//
// public static void onUpdate(SettingsModel settings) {
// String oldVersion = settings.getVersion();
//
// File updaterNew = new File("updater_new.jar");
// if (updaterNew.exists()) {
// try {
// Files.copy(updaterNew.toPath(), new File("updater.jar").toPath(), StandardCopyOption.REPLACE_EXISTING);
// } catch (IOException e) {
// e.printStackTrace();
// }
// try {
// Files.delete(updaterNew.toPath());
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// if (VersionUtil.compareVersions(oldVersion, getClientVersion()) < 0) {
//
// /*
// * Add Update for new version here
// *
// * If you want to update the update.jar you can do this here!
// */
// // if (VersionUtil.compareVersions(oldVersion, "0.0.1") < 0) {
// // // EXAMPLE database changes from 0.0.1 on: add new Param to the
// // // Map of SettingsModel
// // }
// // if (VersionUtil.compareVersions(oldVersion, "0.1.0") < 0) {
// // // EXAMPLE database changes from 0.1.0 on: add new Param to the
// // // Map of SettingsModel
// // }
// // ...
// settings.setVersion(getClientVersion());
// }
// }
//
// /**
// * Entry Method for StudIP Client
// *
// * @param args
// * no args are needed.
// */
// public static void main(String[] args) {
//
// if (args.length == 1 && "-d".equals(args[0])) {
// System.out.println("Delete Preferences from this Application");
// Preferences rootPref = Preferences.userNodeForPackage(Starter.class);
// try {
// rootPref.removeNode();
// } catch (BackingStoreException e) {
// e.printStackTrace();
// System.exit(1);
// }
// System.exit(0);
// }
//
// if (args.length == 1 && "-v".equals(args[0])) {
// System.out.println(getClientVersion());
// System.exit(0);
// }
//
// // Workaround for Bug #JDK-7075600, does not work proper
// System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
//
// // Bootstrap
// Model model = new Model();
// SettingsModel settings = model.getSettingsModel();
//
// // Update install folder to provide portability
// settings.setInstallFolder(System.getProperty("user.dir"));
//
// // Check on every start if the Client got updated, if yes perform some
// // changes.
// Starter.onUpdate(model.getSettingsModel());
//
// model.getPluginModel().init();
// new ViewController(model);
// }
// }
// Path: core/updater/src/main/java/de/danner_web/studip_client/model/UpdateModel.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ProcessBuilder.Redirect;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Enumeration;
import java.util.Observable;
import java.util.Vector;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import java.util.zip.ZipEntry;
import de.danner_web.studip_client.Starter;
package de.danner_web.studip_client.model;
public class UpdateModel extends Observable {
private int progress = 1;
private String status = "";
/**
* This Path points to the Location where the Client is installed
*/
private Path clientLocation;
// Names for settings, also in registry/XML file
private static final String INSTALL_ID = "installID";
private static final String AUTOUPDATE = "autoUpdate";
private static final String VERSION = "client_version";
/**
* Info extracted from prefs
*/
private String version;
private String id;
private boolean autoUpdate;
private String clientApp = null;
/**
* Temporary Path to download update.jar and extract it
*/
private Path tmpDir, extractedPath;
public UpdateModel() {
extractPrefs();
clientLocation = (new File(System.getProperty("user.dir"))).toPath();
clientApp = clientLocation + File.separator + "StudIP_Client.jar";
}
private void extractPrefs() {
// Insert default values
this.autoUpdate = true;
this.version = "0";
this.id = "1";
// Load from prefs if possible
try { | Preferences rootPref = Preferences.userNodeForPackage(Starter.class); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/PluginMessageActionButton.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicButtonUI;
import de.danner_web.studip_client.utils.Template; | package de.danner_web.studip_client.view.components.buttons;
public class PluginMessageActionButton extends JButton {
private static final long serialVersionUID = 3081968117025057228L;
public PluginMessageActionButton(String string) {
super(string);
setBorder(new LineBorder(Color.WHITE));
setForeground(Color.WHITE);
setUI(new BasicButtonUI());
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (this.model.isRollover()) {
this.setBackground(Color.WHITE); | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/PluginMessageActionButton.java
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicButtonUI;
import de.danner_web.studip_client.utils.Template;
package de.danner_web.studip_client.view.components.buttons;
public class PluginMessageActionButton extends JButton {
private static final long serialVersionUID = 3081968117025057228L;
public PluginMessageActionButton(String string) {
super(string);
setBorder(new LineBorder(Color.WHITE));
setForeground(Color.WHITE);
setUI(new BasicButtonUI());
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (this.model.isRollover()) {
this.setBackground(Color.WHITE); | this.setForeground(Template.COLOR_DARK); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/data/PluginMessage.java | // Path: core/client/src/main/java/de/danner_web/studip_client/view/components/PluginMessageDetailsView.java
// public class PluginMessageDetailsView extends JDialog {
//
// private static final long serialVersionUID = -1438615198174407287L;
//
// // Default size
// private static final int HEIGHT = 300;
// private static final int WIDTH = 500;
//
// private PluginMessage message;
//
// public PluginMessageDetailsView(final PluginMessage message) {
// // Hacks back the "x" button in Gnome3
// super(null, "", Dialog.ModalityType.MODELESS);
// this.message = message;
//
// // Set Icon
// try {
// BufferedImage image = ImageIO.read(ResourceLoader.getURL(Template.FAVICON));
// this.setIconImage(image);
// } catch (IOException e) {
// // Nichts tun
// }
//
// // Default size and center
// setPreferredSize(new Dimension(WIDTH, HEIGHT));
// setSize(new Dimension(WIDTH, HEIGHT));
// setLocationRelativeTo(null);
//
// // Content
// setTitle("Ankündigungsdetails");
// add(createHeader(), BorderLayout.NORTH);
// add(createBody(), BorderLayout.CENTER);
//
// // AcceptButton
// if (message instanceof AcceptPluginMessage) {
// ModernButton acceptButton = new ModernButton("Ok");
// acceptButton.addMouseListener(new MouseAdapter() {
// @Override
// public void mouseClicked(MouseEvent e) {
// ((AcceptPluginMessage) message).getAcceptListener().onClick(message);
// close();
// }
// });
// add(acceptButton, BorderLayout.SOUTH);
// }
//
// pack();
// setVisible(true);
// }
//
// /**
// * private method to create the header info as JPanel for the deatil view of
// * a news
// *
// * @return JPanel with topic, author and time on it
// */
// private JPanel createHeader() {
// JPanel header = new JPanel() {
// private static final long serialVersionUID = -7595565968707652304L;
//
// @Override
// public void paint(Graphics g) {
// super.paint(g);
// g.setColor(Template.COLOR_LIGHTER_GRAY);
// g.drawLine(0, getHeight() - 1, getWidth() - 1, getHeight() - 1);
// }
// };
// header.setBackground(Color.WHITE);
// header.setLayout(new BorderLayout());
// header.setBorder(new EmptyBorder(10, 10, 10, 10));
//
// JPanel left = new JPanel();
// left.setBackground(Color.WHITE);
// left.add(new JLabel(message.getHeader()));
//
// header.add(left, BorderLayout.LINE_START);
//
// return header;
// }
//
// /**
// * private method to create the body info as LightScrollPane for the deatil
// * view of a news
// *
// * @return LightScrollPane with body rendered html content
// */
// private JScrollPane createBody() {
// JEditorPane body = new JEditorPane();
// body.setContentType("text/html");
// body.setPreferredSize(new Dimension(WIDTH, HEIGHT));
// body.setMargin(new Insets(15, 15, 15, 15));
// body.setText(message.getText());
//
// // enable hyperlinks
// body.setEditable(false);
// body.setEnabled(true);
// body.addHyperlinkListener(new HyperlinkListener() {
// @Override
// public void hyperlinkUpdate(HyperlinkEvent hle) {
// if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
// Desktop desktop = Desktop.getDesktop();
// try {
// desktop.browse(hle.getURL().toURI());
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
// });
// return new ModernScrollPane(body);
// }
//
// private void close() {
// this.dispose();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import de.danner_web.studip_client.view.components.PluginMessageDetailsView; | package de.danner_web.studip_client.data;
public abstract class PluginMessage {
private List<ClickListener> listeners = new ArrayList<ClickListener>();
private ClickListener showDetailView = new ClickListener() {
@Override
public void onClick(PluginMessage message) { | // Path: core/client/src/main/java/de/danner_web/studip_client/view/components/PluginMessageDetailsView.java
// public class PluginMessageDetailsView extends JDialog {
//
// private static final long serialVersionUID = -1438615198174407287L;
//
// // Default size
// private static final int HEIGHT = 300;
// private static final int WIDTH = 500;
//
// private PluginMessage message;
//
// public PluginMessageDetailsView(final PluginMessage message) {
// // Hacks back the "x" button in Gnome3
// super(null, "", Dialog.ModalityType.MODELESS);
// this.message = message;
//
// // Set Icon
// try {
// BufferedImage image = ImageIO.read(ResourceLoader.getURL(Template.FAVICON));
// this.setIconImage(image);
// } catch (IOException e) {
// // Nichts tun
// }
//
// // Default size and center
// setPreferredSize(new Dimension(WIDTH, HEIGHT));
// setSize(new Dimension(WIDTH, HEIGHT));
// setLocationRelativeTo(null);
//
// // Content
// setTitle("Ankündigungsdetails");
// add(createHeader(), BorderLayout.NORTH);
// add(createBody(), BorderLayout.CENTER);
//
// // AcceptButton
// if (message instanceof AcceptPluginMessage) {
// ModernButton acceptButton = new ModernButton("Ok");
// acceptButton.addMouseListener(new MouseAdapter() {
// @Override
// public void mouseClicked(MouseEvent e) {
// ((AcceptPluginMessage) message).getAcceptListener().onClick(message);
// close();
// }
// });
// add(acceptButton, BorderLayout.SOUTH);
// }
//
// pack();
// setVisible(true);
// }
//
// /**
// * private method to create the header info as JPanel for the deatil view of
// * a news
// *
// * @return JPanel with topic, author and time on it
// */
// private JPanel createHeader() {
// JPanel header = new JPanel() {
// private static final long serialVersionUID = -7595565968707652304L;
//
// @Override
// public void paint(Graphics g) {
// super.paint(g);
// g.setColor(Template.COLOR_LIGHTER_GRAY);
// g.drawLine(0, getHeight() - 1, getWidth() - 1, getHeight() - 1);
// }
// };
// header.setBackground(Color.WHITE);
// header.setLayout(new BorderLayout());
// header.setBorder(new EmptyBorder(10, 10, 10, 10));
//
// JPanel left = new JPanel();
// left.setBackground(Color.WHITE);
// left.add(new JLabel(message.getHeader()));
//
// header.add(left, BorderLayout.LINE_START);
//
// return header;
// }
//
// /**
// * private method to create the body info as LightScrollPane for the deatil
// * view of a news
// *
// * @return LightScrollPane with body rendered html content
// */
// private JScrollPane createBody() {
// JEditorPane body = new JEditorPane();
// body.setContentType("text/html");
// body.setPreferredSize(new Dimension(WIDTH, HEIGHT));
// body.setMargin(new Insets(15, 15, 15, 15));
// body.setText(message.getText());
//
// // enable hyperlinks
// body.setEditable(false);
// body.setEnabled(true);
// body.addHyperlinkListener(new HyperlinkListener() {
// @Override
// public void hyperlinkUpdate(HyperlinkEvent hle) {
// if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
// Desktop desktop = Desktop.getDesktop();
// try {
// desktop.browse(hle.getURL().toURI());
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
// });
// return new ModernScrollPane(body);
// }
//
// private void close() {
// this.dispose();
// }
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginMessage.java
import java.util.ArrayList;
import java.util.List;
import de.danner_web.studip_client.view.components.PluginMessageDetailsView;
package de.danner_web.studip_client.data;
public abstract class PluginMessage {
private List<ClickListener> listeners = new ArrayList<ClickListener>();
private ClickListener showDetailView = new ClickListener() {
@Override
public void onClick(PluginMessage message) { | new PluginMessageDetailsView(message); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/ModernButton.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicButtonUI;
import de.danner_web.studip_client.utils.Template; | package de.danner_web.studip_client.view.components.buttons;
public class ModernButton extends JButton {
private static final long serialVersionUID = 3081968117025057228L;
public ModernButton(String string) {
super(string); | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/ModernButton.java
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicButtonUI;
import de.danner_web.studip_client.utils.Template;
package de.danner_web.studip_client.view.components.buttons;
public class ModernButton extends JButton {
private static final long serialVersionUID = 3081968117025057228L;
public ModernButton(String string) {
super(string); | setBorder(new CompoundBorder(new LineBorder(Template.COLOR_LIGHT_GRAY), new EmptyBorder(5, 5, 5, 5))); |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/utils/AutostartUtil.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/OSValidationUtil.java
// public class OSValidationUtil {
//
// private static String OS = null;
//
// private static String getOsName() {
// if (OS == null) {
// OS = System.getProperty("os.name");
// }
// return OS;
// }
//
// public static boolean isWindows() {
// return getOsName().startsWith("Windows");
// }
//
// public static boolean isMac() {
// // TODO Implement
// return false;
// }
//
// public static boolean isLinux() {
// return getOsName().startsWith("Linux");
// }
//
// }
| import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.danner_web.studip_client.utils.OSValidationUtil; | package de.danner_web.studip_client.utils;
public class AutostartUtil {
private static Logger logger = LogManager.getLogger(AutostartUtil.class);
// Windows specific
private static final String SHORTCUT_NAME = "StudIP Client.lnk";
private static final String EXE_NAME = "StudIP Client.exe";
// Linux specific
private static final String DESKTOP_FILE_NAME = "studip_client.desktop";
private static final String SH_SCRIPT_NAME = "studip_client.sh";
private static final String DESKTOP_PATH = ".config/autostart";
// Mac specific
public static boolean createAutoStartShortcut() {
String installFolder = System.getProperty("user.dir");
// Check OS | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/OSValidationUtil.java
// public class OSValidationUtil {
//
// private static String OS = null;
//
// private static String getOsName() {
// if (OS == null) {
// OS = System.getProperty("os.name");
// }
// return OS;
// }
//
// public static boolean isWindows() {
// return getOsName().startsWith("Windows");
// }
//
// public static boolean isMac() {
// // TODO Implement
// return false;
// }
//
// public static boolean isLinux() {
// return getOsName().startsWith("Linux");
// }
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/utils/AutostartUtil.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.danner_web.studip_client.utils.OSValidationUtil;
package de.danner_web.studip_client.utils;
public class AutostartUtil {
private static Logger logger = LogManager.getLogger(AutostartUtil.class);
// Windows specific
private static final String SHORTCUT_NAME = "StudIP Client.lnk";
private static final String EXE_NAME = "StudIP Client.exe";
// Linux specific
private static final String DESKTOP_FILE_NAME = "studip_client.desktop";
private static final String SH_SCRIPT_NAME = "studip_client.sh";
private static final String DESKTOP_PATH = ".config/autostart";
// Mac specific
public static boolean createAutoStartShortcut() {
String installFolder = System.getProperty("user.dir");
// Check OS | if (OSValidationUtil.isLinux()) { |
CollapsedDom/Stud.IP-Client | core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/ModernToggleButton.java | // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
| import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import javax.swing.JToggleButton;
import javax.swing.Timer;
import de.danner_web.studip_client.utils.Template; | int defaultStepSize = 2;
// If there is no difference either X -> stop
if (diffX == 0) {
tm.stop();
return;
}
int partsX = Math.abs(diffX) / defaultStepSize;
if (partsX > 0) {
stepX = diffX / partsX;
} else {
stepX = diffX;
}
buttonX += stepX;
repaint();
}
});
tm.start();
}
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Background
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(), getHeight());
| // Path: core/client/src/main/java/de/danner_web/studip_client/utils/Template.java
// public class Template {
//
// private static final String PREFIX = "icons/";
//
// // ActionButton images
// public static final String PLUGIN_DELETE = PREFIX + "plugin_delete.svg";
// public static final String PLUGIN_SETTINGS = PREFIX + "plugin_settings.svg";
// public static final String PLUGIN_ADD = PREFIX + "plugin_add.svg";
// public static final String PLUGIN_ACTIVATE = PREFIX + "plugin_activate.svg";
//
// public static final String PLUGIN_VERIFIED = PREFIX + "plugin_verified.svg";
// public static final String PLUGIN_NOT_VERIFIED = PREFIX + "plugin_not_verified.svg";
//
// // OnOffButton images
// public static final String ON_OFF_BUTTON_BG_EN = PREFIX + "onoff_bg_en.png";
// public static final String ON_OFF_BUTTON_BG_DE = PREFIX + "onoff_bg_de.png";
// public static final String ON_OFF_BUTTON_SLIDER = PREFIX + "onoff_slider.png";
//
// // DropdownButton
// public static final String DROP_DOWN_BUTTON = PREFIX + "dropdown_button.png";
//
// // BackButton images
// public static final String BACK_BUTTON = PREFIX + "arrow_back.png";
// public static final String BACK_BUTTON_HOVER = PREFIX + "arrow_back_hover.png";
//
// // Main menu icons
// public static final String MENU_ACTIVITY = PREFIX + "main_menu_activity.svg";
// public static final String MENU_SETTINGS = PREFIX + "main_menu_settings.svg";
// public static final String MENU_LOGGER = PREFIX + "main_menu_logging.svg";
// public static final String MENU_PLUGINS = PREFIX + "main_menu_plugin.svg";
// public static final String MENU_ABOUT = PREFIX + "main_menu_about.svg";
//
// // Favicon
// public static final String FAVICON = PREFIX + "favicon.png";
//
// public static final String AUTHORIZE = PREFIX + "authorize.png";
//
// // About logo
// public static final String LOGO = PREFIX + "logo.svg";
//
// // Colors
// public static final Color COLOR_DARK = Color.decode("#222222");
// public static final Color COLOR_DARK_GRAY = Color.decode("#353535");
// public static final Color COLOR_LIGHT_GRAY = Color.decode("#DDDDDD");
// public static final Color COLOR_LIGHTER_GRAY = Color.decode("#EEEEEE");
// public static final Color COLOR_GRAY = Color.decode("#AAAAAA");
// public static final Color COLOR_ACCENT = Color.decode("#0772A1");
// public static final Color COLOR_ACCENT_LIGHT = Color.decode("#a8bfdb");
//
// // Tree icons
// public static final String TREE_EXPANDED = PREFIX + "tree_expanded.svg";
// public static final String TREE_COLLAPSED = PREFIX + "tree_collapsed.svg";
// public static final String TREE_DOCUMENT = PREFIX + "tree_document.svg";
// public static final String TREE_DOCUMENT_INACTIVE = PREFIX + "tree_document_inactive.svg";
// public static final String TREE_FOLDER = PREFIX + "tree_folder.svg";
// public static final String TREE_FOLDER_INACTIVE = PREFIX + "tree_folder_inactive.svg";
// public static final String TREE_FOLDER_OPEN = PREFIX + "tree_folder_open.svg";
// public static final String TREE_FOLDER_OPEN_INACTIVE = PREFIX + "tree_folder_open_inactive.svg";
//
// }
// Path: core/client/src/main/java/de/danner_web/studip_client/view/components/buttons/ModernToggleButton.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import javax.swing.JToggleButton;
import javax.swing.Timer;
import de.danner_web.studip_client.utils.Template;
int defaultStepSize = 2;
// If there is no difference either X -> stop
if (diffX == 0) {
tm.stop();
return;
}
int partsX = Math.abs(diffX) / defaultStepSize;
if (partsX > 0) {
stepX = diffX / partsX;
} else {
stepX = diffX;
}
buttonX += stepX;
repaint();
}
});
tm.start();
}
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Background
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(), getHeight());
| g.setColor(getColor((float) buttonX / (float) TARGET_MAX, Template.COLOR_LIGHT_GRAY, Template.COLOR_ACCENT_LIGHT)); |
CollapsedDom/Stud.IP-Client | core/coreplugins/news/src/main/java/de/danner_web/studip_client/plugins/news/view/SettingsView.java | // Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginSettings.java
// public class PluginSettings {
//
// private Map<String, String> settings;
// private PluginInformation info;
//
// private Preferences rootPref = Preferences
// .userNodeForPackage(Starter.class);
// private static Logger logger = LogManager.getLogger(PluginSettings.class);
//
// public PluginSettings(PluginInformation info) {
// this.info = info;
// load();
// }
//
// public void clear() {
// settings.clear();
// save();
// }
//
// public boolean containsKey(Object arg0) {
// return settings.containsKey(arg0);
// }
//
// public boolean containsValue(Object arg0) {
// return settings.containsValue(arg0);
// }
//
// public String get(String arg0) {
// return settings.get(arg0);
// }
//
// public boolean isEmpty() {
// return settings.isEmpty();
// }
//
// public String put(String key, String value) {
// String old = settings.put(key, value);
// save();
// return old;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public void putAll(Map arg0) {
// settings.putAll(arg0);
// save();
// }
//
// public String remove(String key) {
// String old = settings.remove(key);
// save();
// return old;
// }
//
// public int size() {
// return settings.size();
// }
//
// private void save() {
// Preferences subPrefsForPlugin = rootPref.node("plugins").node(info.getName());
// subPrefsForPlugin = subPrefsForPlugin.node("settings");
//
// for (String key : settings.keySet()) {
// subPrefsForPlugin.put(key, settings.get(key));
// }
//
// logger.debug("PluginSettings of" + info.getName()
// + " successfully saved");
// }
//
// private void load() {
// Preferences subPrefsForPlugin = rootPref.node("plugins").node(info.getName());
// subPrefsForPlugin = subPrefsForPlugin.node("settings");
//
// settings = new HashMap<String, String>();
// try {
// String[] allKeys = subPrefsForPlugin.keys();
//
// for (String key : allKeys) {
// String value = subPrefsForPlugin.get(key, "");
// if (!value.equals("")) {
// settings.put(key, value);
// }
// }
// } catch (BackingStoreException e) {
// logger.warn("BackingStore is not available -> no plugin settings are loaded");
// }
//
// logger.debug("PluginSettings of" + info.getName()
// + " successfully loaded");
// }
// }
| import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
import de.danner_web.studip_client.data.PluginSettings; | package de.danner_web.studip_client.plugins.news.view;
/**
* THis class implements the settings view for the news plugin
*
* @author philipp
*
*/
public class SettingsView extends JPanel {
private static final long serialVersionUID = -7199119520911188760L;
| // Path: core/client/src/main/java/de/danner_web/studip_client/data/PluginSettings.java
// public class PluginSettings {
//
// private Map<String, String> settings;
// private PluginInformation info;
//
// private Preferences rootPref = Preferences
// .userNodeForPackage(Starter.class);
// private static Logger logger = LogManager.getLogger(PluginSettings.class);
//
// public PluginSettings(PluginInformation info) {
// this.info = info;
// load();
// }
//
// public void clear() {
// settings.clear();
// save();
// }
//
// public boolean containsKey(Object arg0) {
// return settings.containsKey(arg0);
// }
//
// public boolean containsValue(Object arg0) {
// return settings.containsValue(arg0);
// }
//
// public String get(String arg0) {
// return settings.get(arg0);
// }
//
// public boolean isEmpty() {
// return settings.isEmpty();
// }
//
// public String put(String key, String value) {
// String old = settings.put(key, value);
// save();
// return old;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public void putAll(Map arg0) {
// settings.putAll(arg0);
// save();
// }
//
// public String remove(String key) {
// String old = settings.remove(key);
// save();
// return old;
// }
//
// public int size() {
// return settings.size();
// }
//
// private void save() {
// Preferences subPrefsForPlugin = rootPref.node("plugins").node(info.getName());
// subPrefsForPlugin = subPrefsForPlugin.node("settings");
//
// for (String key : settings.keySet()) {
// subPrefsForPlugin.put(key, settings.get(key));
// }
//
// logger.debug("PluginSettings of" + info.getName()
// + " successfully saved");
// }
//
// private void load() {
// Preferences subPrefsForPlugin = rootPref.node("plugins").node(info.getName());
// subPrefsForPlugin = subPrefsForPlugin.node("settings");
//
// settings = new HashMap<String, String>();
// try {
// String[] allKeys = subPrefsForPlugin.keys();
//
// for (String key : allKeys) {
// String value = subPrefsForPlugin.get(key, "");
// if (!value.equals("")) {
// settings.put(key, value);
// }
// }
// } catch (BackingStoreException e) {
// logger.warn("BackingStore is not available -> no plugin settings are loaded");
// }
//
// logger.debug("PluginSettings of" + info.getName()
// + " successfully loaded");
// }
// }
// Path: core/coreplugins/news/src/main/java/de/danner_web/studip_client/plugins/news/view/SettingsView.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
import de.danner_web.studip_client.data.PluginSettings;
package de.danner_web.studip_client.plugins.news.view;
/**
* THis class implements the settings view for the news plugin
*
* @author philipp
*
*/
public class SettingsView extends JPanel {
private static final long serialVersionUID = -7199119520911188760L;
| private PluginSettings settings; |
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JsonLocationDao.java | // Path: app/src/main/java/de/codecentric/dao/LocationDao.java
// public interface LocationDao {
//
// List<Location> getLocations();
//
// Location getLocation(String shortName);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Location.java
// public class Location {
//
// private String shortName;
// private String description;
//
// @JsonCreator
// public Location(@JsonProperty("shortName") String shortName, @JsonProperty("description") String description) {
// this.shortName = shortName;
// this.description = description;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public String getDescription() {
// return description;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import de.codecentric.dao.LocationDao;
import de.codecentric.domain.Location; | package de.codecentric.dao.impl;
@Repository
public class JsonLocationDao implements LocationDao {
private static final Logger LOGGER = Logger.getLogger(JsonLocationDao.class);
@Autowired
private ObjectMapper jsonMapper;
| // Path: app/src/main/java/de/codecentric/dao/LocationDao.java
// public interface LocationDao {
//
// List<Location> getLocations();
//
// Location getLocation(String shortName);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Location.java
// public class Location {
//
// private String shortName;
// private String description;
//
// @JsonCreator
// public Location(@JsonProperty("shortName") String shortName, @JsonProperty("description") String description) {
// this.shortName = shortName;
// this.description = description;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public String getDescription() {
// return description;
// }
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JsonLocationDao.java
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import de.codecentric.dao.LocationDao;
import de.codecentric.domain.Location;
package de.codecentric.dao.impl;
@Repository
public class JsonLocationDao implements LocationDao {
private static final Logger LOGGER = Logger.getLogger(JsonLocationDao.class);
@Autowired
private ObjectMapper jsonMapper;
| private static List<Location> locations; |
codecentric/conference-app | app/src/test/java/de/codecentric/domain/TimeSlotDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
// @Repository
// public class JsonTimeslotDao implements TimeslotDao {
//
// private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
//
// @Autowired
// private ObjectMapper jsonMapper;
//
// private static List<Day> days;
//
// @Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
// private String filePath;
//
// public JsonTimeslotDao() {
// }
//
// public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
// this.filePath = filePath;
// this.jsonMapper = mapper;
// }
//
// public List<Timeslot> getTimeslots(String dayName) {
// loadDaysSafely();
// for (Day day : days) {
// if (day.getShortName().equals(dayName))
// return day.getTimeslots();
// }
// return new ArrayList<Timeslot>();
// }
//
// public List<Day> getConferenceDays() {
// loadDaysSafely();
// return days;
// }
//
// private synchronized void loadDaysSafely() {
// if (days == null)
// loadDays();
// }
//
// private void loadDays() {
//
// days = new ArrayList<Day>();
//
// try {
// InputStream jsonStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
// if (jsonStream != null) {
// days = jsonMapper.readValue(jsonStream, new TypeReference<List<Day>>() {
// });
// }
// } catch (JsonParseException e) {
// LOGGER.error("JsonParseException", e);
// } catch (IOException e) {
// LOGGER.error("IOException", e);
// }
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.dao.impl.JsonTimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.domain;
public class TimeSlotDaoTest {
@Test
public void wrongTimeslotNameShouldReturnEmptyList() {
| // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
// @Repository
// public class JsonTimeslotDao implements TimeslotDao {
//
// private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
//
// @Autowired
// private ObjectMapper jsonMapper;
//
// private static List<Day> days;
//
// @Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
// private String filePath;
//
// public JsonTimeslotDao() {
// }
//
// public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
// this.filePath = filePath;
// this.jsonMapper = mapper;
// }
//
// public List<Timeslot> getTimeslots(String dayName) {
// loadDaysSafely();
// for (Day day : days) {
// if (day.getShortName().equals(dayName))
// return day.getTimeslots();
// }
// return new ArrayList<Timeslot>();
// }
//
// public List<Day> getConferenceDays() {
// loadDaysSafely();
// return days;
// }
//
// private synchronized void loadDaysSafely() {
// if (days == null)
// loadDays();
// }
//
// private void loadDays() {
//
// days = new ArrayList<Day>();
//
// try {
// InputStream jsonStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
// if (jsonStream != null) {
// days = jsonMapper.readValue(jsonStream, new TypeReference<List<Day>>() {
// });
// }
// } catch (JsonParseException e) {
// LOGGER.error("JsonParseException", e);
// } catch (IOException e) {
// LOGGER.error("IOException", e);
// }
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/TimeSlotDaoTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.dao.impl.JsonTimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.domain;
public class TimeSlotDaoTest {
@Test
public void wrongTimeslotNameShouldReturnEmptyList() {
| final TimeslotDao dao = getDaoInstance();
|
codecentric/conference-app | app/src/test/java/de/codecentric/domain/TimeSlotDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
// @Repository
// public class JsonTimeslotDao implements TimeslotDao {
//
// private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
//
// @Autowired
// private ObjectMapper jsonMapper;
//
// private static List<Day> days;
//
// @Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
// private String filePath;
//
// public JsonTimeslotDao() {
// }
//
// public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
// this.filePath = filePath;
// this.jsonMapper = mapper;
// }
//
// public List<Timeslot> getTimeslots(String dayName) {
// loadDaysSafely();
// for (Day day : days) {
// if (day.getShortName().equals(dayName))
// return day.getTimeslots();
// }
// return new ArrayList<Timeslot>();
// }
//
// public List<Day> getConferenceDays() {
// loadDaysSafely();
// return days;
// }
//
// private synchronized void loadDaysSafely() {
// if (days == null)
// loadDays();
// }
//
// private void loadDays() {
//
// days = new ArrayList<Day>();
//
// try {
// InputStream jsonStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
// if (jsonStream != null) {
// days = jsonMapper.readValue(jsonStream, new TypeReference<List<Day>>() {
// });
// }
// } catch (JsonParseException e) {
// LOGGER.error("JsonParseException", e);
// } catch (IOException e) {
// LOGGER.error("IOException", e);
// }
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.dao.impl.JsonTimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.domain;
public class TimeSlotDaoTest {
@Test
public void wrongTimeslotNameShouldReturnEmptyList() {
final TimeslotDao dao = getDaoInstance();
| // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
// @Repository
// public class JsonTimeslotDao implements TimeslotDao {
//
// private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
//
// @Autowired
// private ObjectMapper jsonMapper;
//
// private static List<Day> days;
//
// @Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
// private String filePath;
//
// public JsonTimeslotDao() {
// }
//
// public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
// this.filePath = filePath;
// this.jsonMapper = mapper;
// }
//
// public List<Timeslot> getTimeslots(String dayName) {
// loadDaysSafely();
// for (Day day : days) {
// if (day.getShortName().equals(dayName))
// return day.getTimeslots();
// }
// return new ArrayList<Timeslot>();
// }
//
// public List<Day> getConferenceDays() {
// loadDaysSafely();
// return days;
// }
//
// private synchronized void loadDaysSafely() {
// if (days == null)
// loadDays();
// }
//
// private void loadDays() {
//
// days = new ArrayList<Day>();
//
// try {
// InputStream jsonStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
// if (jsonStream != null) {
// days = jsonMapper.readValue(jsonStream, new TypeReference<List<Day>>() {
// });
// }
// } catch (JsonParseException e) {
// LOGGER.error("JsonParseException", e);
// } catch (IOException e) {
// LOGGER.error("IOException", e);
// }
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/TimeSlotDaoTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.dao.impl.JsonTimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.domain;
public class TimeSlotDaoTest {
@Test
public void wrongTimeslotNameShouldReturnEmptyList() {
final TimeslotDao dao = getDaoInstance();
| final List<Timeslot> timeslots = dao.getTimeslots("Err");
|
codecentric/conference-app | app/src/test/java/de/codecentric/domain/TimeSlotDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
// @Repository
// public class JsonTimeslotDao implements TimeslotDao {
//
// private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
//
// @Autowired
// private ObjectMapper jsonMapper;
//
// private static List<Day> days;
//
// @Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
// private String filePath;
//
// public JsonTimeslotDao() {
// }
//
// public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
// this.filePath = filePath;
// this.jsonMapper = mapper;
// }
//
// public List<Timeslot> getTimeslots(String dayName) {
// loadDaysSafely();
// for (Day day : days) {
// if (day.getShortName().equals(dayName))
// return day.getTimeslots();
// }
// return new ArrayList<Timeslot>();
// }
//
// public List<Day> getConferenceDays() {
// loadDaysSafely();
// return days;
// }
//
// private synchronized void loadDaysSafely() {
// if (days == null)
// loadDays();
// }
//
// private void loadDays() {
//
// days = new ArrayList<Day>();
//
// try {
// InputStream jsonStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
// if (jsonStream != null) {
// days = jsonMapper.readValue(jsonStream, new TypeReference<List<Day>>() {
// });
// }
// } catch (JsonParseException e) {
// LOGGER.error("JsonParseException", e);
// } catch (IOException e) {
// LOGGER.error("IOException", e);
// }
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.dao.impl.JsonTimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.domain;
public class TimeSlotDaoTest {
@Test
public void wrongTimeslotNameShouldReturnEmptyList() {
final TimeslotDao dao = getDaoInstance();
final List<Timeslot> timeslots = dao.getTimeslots("Err");
assertNotNull(timeslots);
assertEquals(0, timeslots.size());
}
@Test
public void shouldReturnWednesdayTimeSlot() {
final TimeslotDao dao = getDaoInstance();
final List<Timeslot> timeslots = dao.getTimeslots("20.08.2014");
assertEquals(3, timeslots.size());
assertEquals("16:15", timeslots.get(1).getStart());
}
| // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
// @Repository
// public class JsonTimeslotDao implements TimeslotDao {
//
// private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
//
// @Autowired
// private ObjectMapper jsonMapper;
//
// private static List<Day> days;
//
// @Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
// private String filePath;
//
// public JsonTimeslotDao() {
// }
//
// public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
// this.filePath = filePath;
// this.jsonMapper = mapper;
// }
//
// public List<Timeslot> getTimeslots(String dayName) {
// loadDaysSafely();
// for (Day day : days) {
// if (day.getShortName().equals(dayName))
// return day.getTimeslots();
// }
// return new ArrayList<Timeslot>();
// }
//
// public List<Day> getConferenceDays() {
// loadDaysSafely();
// return days;
// }
//
// private synchronized void loadDaysSafely() {
// if (days == null)
// loadDays();
// }
//
// private void loadDays() {
//
// days = new ArrayList<Day>();
//
// try {
// InputStream jsonStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
// if (jsonStream != null) {
// days = jsonMapper.readValue(jsonStream, new TypeReference<List<Day>>() {
// });
// }
// } catch (JsonParseException e) {
// LOGGER.error("JsonParseException", e);
// } catch (IOException e) {
// LOGGER.error("IOException", e);
// }
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/TimeSlotDaoTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.dao.impl.JsonTimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.domain;
public class TimeSlotDaoTest {
@Test
public void wrongTimeslotNameShouldReturnEmptyList() {
final TimeslotDao dao = getDaoInstance();
final List<Timeslot> timeslots = dao.getTimeslots("Err");
assertNotNull(timeslots);
assertEquals(0, timeslots.size());
}
@Test
public void shouldReturnWednesdayTimeSlot() {
final TimeslotDao dao = getDaoInstance();
final List<Timeslot> timeslots = dao.getTimeslots("20.08.2014");
assertEquals(3, timeslots.size());
assertEquals("16:15", timeslots.get(1).getStart());
}
| private JsonTimeslotDao getDaoInstance() {
|
codecentric/conference-app | app/src/test/java/de/codecentric/domain/TimeSlotDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
// @Repository
// public class JsonTimeslotDao implements TimeslotDao {
//
// private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
//
// @Autowired
// private ObjectMapper jsonMapper;
//
// private static List<Day> days;
//
// @Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
// private String filePath;
//
// public JsonTimeslotDao() {
// }
//
// public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
// this.filePath = filePath;
// this.jsonMapper = mapper;
// }
//
// public List<Timeslot> getTimeslots(String dayName) {
// loadDaysSafely();
// for (Day day : days) {
// if (day.getShortName().equals(dayName))
// return day.getTimeslots();
// }
// return new ArrayList<Timeslot>();
// }
//
// public List<Day> getConferenceDays() {
// loadDaysSafely();
// return days;
// }
//
// private synchronized void loadDaysSafely() {
// if (days == null)
// loadDays();
// }
//
// private void loadDays() {
//
// days = new ArrayList<Day>();
//
// try {
// InputStream jsonStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
// if (jsonStream != null) {
// days = jsonMapper.readValue(jsonStream, new TypeReference<List<Day>>() {
// });
// }
// } catch (JsonParseException e) {
// LOGGER.error("JsonParseException", e);
// } catch (IOException e) {
// LOGGER.error("IOException", e);
// }
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.dao.impl.JsonTimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.domain;
public class TimeSlotDaoTest {
@Test
public void wrongTimeslotNameShouldReturnEmptyList() {
final TimeslotDao dao = getDaoInstance();
final List<Timeslot> timeslots = dao.getTimeslots("Err");
assertNotNull(timeslots);
assertEquals(0, timeslots.size());
}
@Test
public void shouldReturnWednesdayTimeSlot() {
final TimeslotDao dao = getDaoInstance();
final List<Timeslot> timeslots = dao.getTimeslots("20.08.2014");
assertEquals(3, timeslots.size());
assertEquals("16:15", timeslots.get(1).getStart());
}
private JsonTimeslotDao getDaoInstance() {
return new JsonTimeslotDao(new ObjectMapper(), "daysAndTimeslots.json");
}
@Test
public void shouldGetDaysOfConference() {
TimeslotDao dao = getDaoInstance();
| // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
// @Repository
// public class JsonTimeslotDao implements TimeslotDao {
//
// private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
//
// @Autowired
// private ObjectMapper jsonMapper;
//
// private static List<Day> days;
//
// @Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
// private String filePath;
//
// public JsonTimeslotDao() {
// }
//
// public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
// this.filePath = filePath;
// this.jsonMapper = mapper;
// }
//
// public List<Timeslot> getTimeslots(String dayName) {
// loadDaysSafely();
// for (Day day : days) {
// if (day.getShortName().equals(dayName))
// return day.getTimeslots();
// }
// return new ArrayList<Timeslot>();
// }
//
// public List<Day> getConferenceDays() {
// loadDaysSafely();
// return days;
// }
//
// private synchronized void loadDaysSafely() {
// if (days == null)
// loadDays();
// }
//
// private void loadDays() {
//
// days = new ArrayList<Day>();
//
// try {
// InputStream jsonStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
// if (jsonStream != null) {
// days = jsonMapper.readValue(jsonStream, new TypeReference<List<Day>>() {
// });
// }
// } catch (JsonParseException e) {
// LOGGER.error("JsonParseException", e);
// } catch (IOException e) {
// LOGGER.error("IOException", e);
// }
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/TimeSlotDaoTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.dao.impl.JsonTimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.domain;
public class TimeSlotDaoTest {
@Test
public void wrongTimeslotNameShouldReturnEmptyList() {
final TimeslotDao dao = getDaoInstance();
final List<Timeslot> timeslots = dao.getTimeslots("Err");
assertNotNull(timeslots);
assertEquals(0, timeslots.size());
}
@Test
public void shouldReturnWednesdayTimeSlot() {
final TimeslotDao dao = getDaoInstance();
final List<Timeslot> timeslots = dao.getTimeslots("20.08.2014");
assertEquals(3, timeslots.size());
assertEquals("16:15", timeslots.get(1).getStart());
}
private JsonTimeslotDao getDaoInstance() {
return new JsonTimeslotDao(new ObjectMapper(), "daysAndTimeslots.json");
}
@Test
public void shouldGetDaysOfConference() {
TimeslotDao dao = getDaoInstance();
| List<Day> days = dao.getConferenceDays();
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaFeedbackDao.java | // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
| import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
| package de.codecentric.dao.impl;
@Transactional
@Repository
| // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaFeedbackDao.java
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
package de.codecentric.dao.impl;
@Transactional
@Repository
| public class JpaFeedbackDao implements FeedbackDao {
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaFeedbackDao.java | // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
| import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
| package de.codecentric.dao.impl;
@Transactional
@Repository
public class JpaFeedbackDao implements FeedbackDao {
@PersistenceContext
private EntityManager em;
@Override
| // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaFeedbackDao.java
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
package de.codecentric.dao.impl;
@Transactional
@Repository
public class JpaFeedbackDao implements FeedbackDao {
@PersistenceContext
private EntityManager em;
@Override
| public void save(Feedback feedback) {
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaLinkDao.java | // Path: app/src/main/java/de/codecentric/dao/LinkDao.java
// public interface LinkDao {
//
// public List<Link> getLinksBySessionId(Long sessionId);
//
// public void saveLink(Link link);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Link.java
// @Entity(name = "link")
// @NamedQueries({ @NamedQuery(name = "findLinksForSession", query = "from link where sessionId=:sessionId order by date desc"), })
// public class Link {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// @Lob
// private String link;
// private String comment;
// private Long sessionId;
//
// public Link() {
// }
//
// public Link(Date date, String comment, String link, Long sessionId) {
// super();
// this.date = date;
// this.comment = comment;
// this.link = link;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((comment == null) ? 0 : comment.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// result = prime * result + (int) (id ^ (id >>> 32));
// result = prime * result + ((link == null) ? 0 : link.hashCode());
// result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Link other = (Link) obj;
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// } else if (!comment.equals(other.comment))
// return false;
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// if (id != other.id) {
// return false;
// }
// if (link == null) {
// if (other.link != null) {
// return false;
// }
// } else if (!link.equals(other.link))
// return false;
// if (sessionId == null) {
// if (other.sessionId != null) {
// return false;
// }
// } else if (!sessionId.equals(other.sessionId)) {
// return false;
// }
// return true;
// }
// }
| import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.LinkDao;
import de.codecentric.domain.Link;
| package de.codecentric.dao.impl;
@Repository("linkDao")
@Transactional
| // Path: app/src/main/java/de/codecentric/dao/LinkDao.java
// public interface LinkDao {
//
// public List<Link> getLinksBySessionId(Long sessionId);
//
// public void saveLink(Link link);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Link.java
// @Entity(name = "link")
// @NamedQueries({ @NamedQuery(name = "findLinksForSession", query = "from link where sessionId=:sessionId order by date desc"), })
// public class Link {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// @Lob
// private String link;
// private String comment;
// private Long sessionId;
//
// public Link() {
// }
//
// public Link(Date date, String comment, String link, Long sessionId) {
// super();
// this.date = date;
// this.comment = comment;
// this.link = link;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((comment == null) ? 0 : comment.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// result = prime * result + (int) (id ^ (id >>> 32));
// result = prime * result + ((link == null) ? 0 : link.hashCode());
// result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Link other = (Link) obj;
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// } else if (!comment.equals(other.comment))
// return false;
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// if (id != other.id) {
// return false;
// }
// if (link == null) {
// if (other.link != null) {
// return false;
// }
// } else if (!link.equals(other.link))
// return false;
// if (sessionId == null) {
// if (other.sessionId != null) {
// return false;
// }
// } else if (!sessionId.equals(other.sessionId)) {
// return false;
// }
// return true;
// }
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaLinkDao.java
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.LinkDao;
import de.codecentric.domain.Link;
package de.codecentric.dao.impl;
@Repository("linkDao")
@Transactional
| public class JpaLinkDao implements LinkDao {
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaLinkDao.java | // Path: app/src/main/java/de/codecentric/dao/LinkDao.java
// public interface LinkDao {
//
// public List<Link> getLinksBySessionId(Long sessionId);
//
// public void saveLink(Link link);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Link.java
// @Entity(name = "link")
// @NamedQueries({ @NamedQuery(name = "findLinksForSession", query = "from link where sessionId=:sessionId order by date desc"), })
// public class Link {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// @Lob
// private String link;
// private String comment;
// private Long sessionId;
//
// public Link() {
// }
//
// public Link(Date date, String comment, String link, Long sessionId) {
// super();
// this.date = date;
// this.comment = comment;
// this.link = link;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((comment == null) ? 0 : comment.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// result = prime * result + (int) (id ^ (id >>> 32));
// result = prime * result + ((link == null) ? 0 : link.hashCode());
// result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Link other = (Link) obj;
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// } else if (!comment.equals(other.comment))
// return false;
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// if (id != other.id) {
// return false;
// }
// if (link == null) {
// if (other.link != null) {
// return false;
// }
// } else if (!link.equals(other.link))
// return false;
// if (sessionId == null) {
// if (other.sessionId != null) {
// return false;
// }
// } else if (!sessionId.equals(other.sessionId)) {
// return false;
// }
// return true;
// }
// }
| import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.LinkDao;
import de.codecentric.domain.Link;
| package de.codecentric.dao.impl;
@Repository("linkDao")
@Transactional
public class JpaLinkDao implements LinkDao {
@PersistenceContext
private EntityManager em;
public JpaLinkDao() {
}
// test constructor
public JpaLinkDao(EntityManager em) {
this.em = em;
}
@SuppressWarnings("unchecked")
| // Path: app/src/main/java/de/codecentric/dao/LinkDao.java
// public interface LinkDao {
//
// public List<Link> getLinksBySessionId(Long sessionId);
//
// public void saveLink(Link link);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Link.java
// @Entity(name = "link")
// @NamedQueries({ @NamedQuery(name = "findLinksForSession", query = "from link where sessionId=:sessionId order by date desc"), })
// public class Link {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// @Lob
// private String link;
// private String comment;
// private Long sessionId;
//
// public Link() {
// }
//
// public Link(Date date, String comment, String link, Long sessionId) {
// super();
// this.date = date;
// this.comment = comment;
// this.link = link;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((comment == null) ? 0 : comment.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// result = prime * result + (int) (id ^ (id >>> 32));
// result = prime * result + ((link == null) ? 0 : link.hashCode());
// result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Link other = (Link) obj;
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// } else if (!comment.equals(other.comment))
// return false;
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// if (id != other.id) {
// return false;
// }
// if (link == null) {
// if (other.link != null) {
// return false;
// }
// } else if (!link.equals(other.link))
// return false;
// if (sessionId == null) {
// if (other.sessionId != null) {
// return false;
// }
// } else if (!sessionId.equals(other.sessionId)) {
// return false;
// }
// return true;
// }
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaLinkDao.java
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.LinkDao;
import de.codecentric.domain.Link;
package de.codecentric.dao.impl;
@Repository("linkDao")
@Transactional
public class JpaLinkDao implements LinkDao {
@PersistenceContext
private EntityManager em;
public JpaLinkDao() {
}
// test constructor
public JpaLinkDao(EntityManager em) {
this.em = em;
}
@SuppressWarnings("unchecked")
| public List<Link> getLinksBySessionId(Long sessionId) {
|
codecentric/conference-app | app/src/test/java/de/codecentric/controller/StaticTimeslotDao.java | // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.controller;
public class StaticTimeslotDao implements TimeslotDao {
private Map<String, List<Timeslot>> timeslotsPerDay;
| // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/test/java/de/codecentric/controller/StaticTimeslotDao.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.controller;
public class StaticTimeslotDao implements TimeslotDao {
private Map<String, List<Timeslot>> timeslotsPerDay;
| private ArrayList<Day> days;
|
codecentric/conference-app | app/src/test/java/de/codecentric/domain/JpaLinkDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/impl/JpaLinkDao.java
// @Repository("linkDao")
// @Transactional
// public class JpaLinkDao implements LinkDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaLinkDao() {
// }
//
// // test constructor
// public JpaLinkDao(EntityManager em) {
// this.em = em;
// }
//
// @SuppressWarnings("unchecked")
// public List<Link> getLinksBySessionId(Long sessionId) {
// Query query = em.createNamedQuery("findLinksForSession");
// return query.setParameter("sessionId", sessionId).getResultList();
// }
//
// public void saveLink(Link link) {
// em.merge(link);
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Link.java
// @Entity(name = "link")
// @NamedQueries({ @NamedQuery(name = "findLinksForSession", query = "from link where sessionId=:sessionId order by date desc"), })
// public class Link {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// @Lob
// private String link;
// private String comment;
// private Long sessionId;
//
// public Link() {
// }
//
// public Link(Date date, String comment, String link, Long sessionId) {
// super();
// this.date = date;
// this.comment = comment;
// this.link = link;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((comment == null) ? 0 : comment.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// result = prime * result + (int) (id ^ (id >>> 32));
// result = prime * result + ((link == null) ? 0 : link.hashCode());
// result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Link other = (Link) obj;
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// } else if (!comment.equals(other.comment))
// return false;
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// if (id != other.id) {
// return false;
// }
// if (link == null) {
// if (other.link != null) {
// return false;
// }
// } else if (!link.equals(other.link))
// return false;
// if (sessionId == null) {
// if (other.sessionId != null) {
// return false;
// }
// } else if (!sessionId.equals(other.sessionId)) {
// return false;
// }
// return true;
// }
// }
| import static org.mockito.Mockito.verify;
import java.util.Date;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.dao.impl.JpaLinkDao;
import de.codecentric.domain.Link;
| package de.codecentric.domain;
public class JpaLinkDaoTest {
@Mock
private EntityManager emMock;
| // Path: app/src/main/java/de/codecentric/dao/impl/JpaLinkDao.java
// @Repository("linkDao")
// @Transactional
// public class JpaLinkDao implements LinkDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaLinkDao() {
// }
//
// // test constructor
// public JpaLinkDao(EntityManager em) {
// this.em = em;
// }
//
// @SuppressWarnings("unchecked")
// public List<Link> getLinksBySessionId(Long sessionId) {
// Query query = em.createNamedQuery("findLinksForSession");
// return query.setParameter("sessionId", sessionId).getResultList();
// }
//
// public void saveLink(Link link) {
// em.merge(link);
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Link.java
// @Entity(name = "link")
// @NamedQueries({ @NamedQuery(name = "findLinksForSession", query = "from link where sessionId=:sessionId order by date desc"), })
// public class Link {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// @Lob
// private String link;
// private String comment;
// private Long sessionId;
//
// public Link() {
// }
//
// public Link(Date date, String comment, String link, Long sessionId) {
// super();
// this.date = date;
// this.comment = comment;
// this.link = link;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((comment == null) ? 0 : comment.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// result = prime * result + (int) (id ^ (id >>> 32));
// result = prime * result + ((link == null) ? 0 : link.hashCode());
// result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Link other = (Link) obj;
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// } else if (!comment.equals(other.comment))
// return false;
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// if (id != other.id) {
// return false;
// }
// if (link == null) {
// if (other.link != null) {
// return false;
// }
// } else if (!link.equals(other.link))
// return false;
// if (sessionId == null) {
// if (other.sessionId != null) {
// return false;
// }
// } else if (!sessionId.equals(other.sessionId)) {
// return false;
// }
// return true;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/JpaLinkDaoTest.java
import static org.mockito.Mockito.verify;
import java.util.Date;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.dao.impl.JpaLinkDao;
import de.codecentric.domain.Link;
package de.codecentric.domain;
public class JpaLinkDaoTest {
@Mock
private EntityManager emMock;
| private JpaLinkDao dao;
|
codecentric/conference-app | app/src/test/java/de/codecentric/domain/JpaLinkDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/impl/JpaLinkDao.java
// @Repository("linkDao")
// @Transactional
// public class JpaLinkDao implements LinkDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaLinkDao() {
// }
//
// // test constructor
// public JpaLinkDao(EntityManager em) {
// this.em = em;
// }
//
// @SuppressWarnings("unchecked")
// public List<Link> getLinksBySessionId(Long sessionId) {
// Query query = em.createNamedQuery("findLinksForSession");
// return query.setParameter("sessionId", sessionId).getResultList();
// }
//
// public void saveLink(Link link) {
// em.merge(link);
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Link.java
// @Entity(name = "link")
// @NamedQueries({ @NamedQuery(name = "findLinksForSession", query = "from link where sessionId=:sessionId order by date desc"), })
// public class Link {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// @Lob
// private String link;
// private String comment;
// private Long sessionId;
//
// public Link() {
// }
//
// public Link(Date date, String comment, String link, Long sessionId) {
// super();
// this.date = date;
// this.comment = comment;
// this.link = link;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((comment == null) ? 0 : comment.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// result = prime * result + (int) (id ^ (id >>> 32));
// result = prime * result + ((link == null) ? 0 : link.hashCode());
// result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Link other = (Link) obj;
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// } else if (!comment.equals(other.comment))
// return false;
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// if (id != other.id) {
// return false;
// }
// if (link == null) {
// if (other.link != null) {
// return false;
// }
// } else if (!link.equals(other.link))
// return false;
// if (sessionId == null) {
// if (other.sessionId != null) {
// return false;
// }
// } else if (!sessionId.equals(other.sessionId)) {
// return false;
// }
// return true;
// }
// }
| import static org.mockito.Mockito.verify;
import java.util.Date;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.dao.impl.JpaLinkDao;
import de.codecentric.domain.Link;
| package de.codecentric.domain;
public class JpaLinkDaoTest {
@Mock
private EntityManager emMock;
private JpaLinkDao dao;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
dao = new JpaLinkDao(emMock);
}
@Test
public void shouldSaveLink() {
| // Path: app/src/main/java/de/codecentric/dao/impl/JpaLinkDao.java
// @Repository("linkDao")
// @Transactional
// public class JpaLinkDao implements LinkDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaLinkDao() {
// }
//
// // test constructor
// public JpaLinkDao(EntityManager em) {
// this.em = em;
// }
//
// @SuppressWarnings("unchecked")
// public List<Link> getLinksBySessionId(Long sessionId) {
// Query query = em.createNamedQuery("findLinksForSession");
// return query.setParameter("sessionId", sessionId).getResultList();
// }
//
// public void saveLink(Link link) {
// em.merge(link);
// }
// }
//
// Path: app/src/main/java/de/codecentric/domain/Link.java
// @Entity(name = "link")
// @NamedQueries({ @NamedQuery(name = "findLinksForSession", query = "from link where sessionId=:sessionId order by date desc"), })
// public class Link {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// @Lob
// private String link;
// private String comment;
// private Long sessionId;
//
// public Link() {
// }
//
// public Link(Date date, String comment, String link, Long sessionId) {
// super();
// this.date = date;
// this.comment = comment;
// this.link = link;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((comment == null) ? 0 : comment.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// result = prime * result + (int) (id ^ (id >>> 32));
// result = prime * result + ((link == null) ? 0 : link.hashCode());
// result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Link other = (Link) obj;
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// } else if (!comment.equals(other.comment))
// return false;
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// if (id != other.id) {
// return false;
// }
// if (link == null) {
// if (other.link != null) {
// return false;
// }
// } else if (!link.equals(other.link))
// return false;
// if (sessionId == null) {
// if (other.sessionId != null) {
// return false;
// }
// } else if (!sessionId.equals(other.sessionId)) {
// return false;
// }
// return true;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/JpaLinkDaoTest.java
import static org.mockito.Mockito.verify;
import java.util.Date;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.dao.impl.JpaLinkDao;
import de.codecentric.domain.Link;
package de.codecentric.domain;
public class JpaLinkDaoTest {
@Mock
private EntityManager emMock;
private JpaLinkDao dao;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
dao = new JpaLinkDao(emMock);
}
@Test
public void shouldSaveLink() {
| Link link = new Link();
|
codecentric/conference-app | app/src/main/java/de/codecentric/config/ApplicationWebConfiguration.java | // Path: app/src/main/java/de/codecentric/validate/TimeValidator.java
// public interface TimeValidator {
//
// /**
// * Validate time in 24 hours format with regular expression
// *
// * @param time
// * time address for validation
// * @return true valid time format, false invalid time format
// */
// public abstract boolean validate(String time);
//
// }
//
// Path: app/src/main/java/de/codecentric/validate/impl/Time24HoursValidator.java
// public class Time24HoursValidator implements TimeValidator {
//
// private Pattern pattern;
// private Matcher matcher;
//
// private static final String TIME24HOURS_PATTERN = "([01]?[0-9]|2[0-3]):[0-5][0-9]";
//
// public Time24HoursValidator() {
// pattern = Pattern.compile(TIME24HOURS_PATTERN);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * de.codecentric.validate.impl.TimeValidator#validate(java.lang.String)
// */
// @Override
// public boolean validate(final String time) {
// matcher = pattern.matcher(time);
// return matcher.matches();
// }
//
// }
| import java.util.Locale;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import de.codecentric.validate.TimeValidator;
import de.codecentric.validate.impl.Time24HoursValidator; | package de.codecentric.config;
@Configuration
public class ApplicationWebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
super.addViewControllers(registry);
registry.addViewController("/").setViewName("redirect:/currentSessions");
}
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
@Bean | // Path: app/src/main/java/de/codecentric/validate/TimeValidator.java
// public interface TimeValidator {
//
// /**
// * Validate time in 24 hours format with regular expression
// *
// * @param time
// * time address for validation
// * @return true valid time format, false invalid time format
// */
// public abstract boolean validate(String time);
//
// }
//
// Path: app/src/main/java/de/codecentric/validate/impl/Time24HoursValidator.java
// public class Time24HoursValidator implements TimeValidator {
//
// private Pattern pattern;
// private Matcher matcher;
//
// private static final String TIME24HOURS_PATTERN = "([01]?[0-9]|2[0-3]):[0-5][0-9]";
//
// public Time24HoursValidator() {
// pattern = Pattern.compile(TIME24HOURS_PATTERN);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * de.codecentric.validate.impl.TimeValidator#validate(java.lang.String)
// */
// @Override
// public boolean validate(final String time) {
// matcher = pattern.matcher(time);
// return matcher.matches();
// }
//
// }
// Path: app/src/main/java/de/codecentric/config/ApplicationWebConfiguration.java
import java.util.Locale;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import de.codecentric.validate.TimeValidator;
import de.codecentric.validate.impl.Time24HoursValidator;
package de.codecentric.config;
@Configuration
public class ApplicationWebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
super.addViewControllers(registry);
registry.addViewController("/").setViewName("redirect:/currentSessions");
}
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
@Bean | public TimeValidator timeValidator() { |
codecentric/conference-app | app/src/main/java/de/codecentric/config/ApplicationWebConfiguration.java | // Path: app/src/main/java/de/codecentric/validate/TimeValidator.java
// public interface TimeValidator {
//
// /**
// * Validate time in 24 hours format with regular expression
// *
// * @param time
// * time address for validation
// * @return true valid time format, false invalid time format
// */
// public abstract boolean validate(String time);
//
// }
//
// Path: app/src/main/java/de/codecentric/validate/impl/Time24HoursValidator.java
// public class Time24HoursValidator implements TimeValidator {
//
// private Pattern pattern;
// private Matcher matcher;
//
// private static final String TIME24HOURS_PATTERN = "([01]?[0-9]|2[0-3]):[0-5][0-9]";
//
// public Time24HoursValidator() {
// pattern = Pattern.compile(TIME24HOURS_PATTERN);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * de.codecentric.validate.impl.TimeValidator#validate(java.lang.String)
// */
// @Override
// public boolean validate(final String time) {
// matcher = pattern.matcher(time);
// return matcher.matches();
// }
//
// }
| import java.util.Locale;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import de.codecentric.validate.TimeValidator;
import de.codecentric.validate.impl.Time24HoursValidator; | package de.codecentric.config;
@Configuration
public class ApplicationWebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
super.addViewControllers(registry);
registry.addViewController("/").setViewName("redirect:/currentSessions");
}
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
@Bean
public TimeValidator timeValidator() { | // Path: app/src/main/java/de/codecentric/validate/TimeValidator.java
// public interface TimeValidator {
//
// /**
// * Validate time in 24 hours format with regular expression
// *
// * @param time
// * time address for validation
// * @return true valid time format, false invalid time format
// */
// public abstract boolean validate(String time);
//
// }
//
// Path: app/src/main/java/de/codecentric/validate/impl/Time24HoursValidator.java
// public class Time24HoursValidator implements TimeValidator {
//
// private Pattern pattern;
// private Matcher matcher;
//
// private static final String TIME24HOURS_PATTERN = "([01]?[0-9]|2[0-3]):[0-5][0-9]";
//
// public Time24HoursValidator() {
// pattern = Pattern.compile(TIME24HOURS_PATTERN);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * de.codecentric.validate.impl.TimeValidator#validate(java.lang.String)
// */
// @Override
// public boolean validate(final String time) {
// matcher = pattern.matcher(time);
// return matcher.matches();
// }
//
// }
// Path: app/src/main/java/de/codecentric/config/ApplicationWebConfiguration.java
import java.util.Locale;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import de.codecentric.validate.TimeValidator;
import de.codecentric.validate.impl.Time24HoursValidator;
package de.codecentric.config;
@Configuration
public class ApplicationWebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
super.addViewControllers(registry);
registry.addViewController("/").setViewName("redirect:/currentSessions");
}
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
@Bean
public TimeValidator timeValidator() { | return new Time24HoursValidator(); |
codecentric/conference-app | app/src/test/java/de/codecentric/domain/DayTest.java | // Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.domain;
public class DayTest {
@Test
public void testGetShortNameWithoutDots() throws Exception {
| // Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/DayTest.java
import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.domain;
public class DayTest {
@Test
public void testGetShortNameWithoutDots() throws Exception {
| Day day = new Day("20.08.2014", new ArrayList<Timeslot>());
|
codecentric/conference-app | app/src/test/java/de/codecentric/domain/DayTest.java | // Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.domain;
public class DayTest {
@Test
public void testGetShortNameWithoutDots() throws Exception {
| // Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/DayTest.java
import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.domain;
public class DayTest {
@Test
public void testGetShortNameWithoutDots() throws Exception {
| Day day = new Day("20.08.2014", new ArrayList<Timeslot>());
|
codecentric/conference-app | app/src/test/java/de/codecentric/controller/VenueMapControllerTest.java | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/Application.java
// @EnableAutoConfiguration
// @SpringBootApplication
// @ComponentScan
// @Import(ApplicationWebConfiguration.class)
// public class Application extends SpringBootServletInitializer {
//
// public static void main(String[] args) {
// SpringApplication.run(Application.class, args);
// }
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
// }
| import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.View;
import de.codecentric.Application;
import java.util.Collections; | package de.codecentric.controller;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class VenueMapControllerTest {
@InjectMocks
VenueMapController controller;
@Mock
View mockView;
@Mock | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/Application.java
// @EnableAutoConfiguration
// @SpringBootApplication
// @ComponentScan
// @Import(ApplicationWebConfiguration.class)
// public class Application extends SpringBootServletInitializer {
//
// public static void main(String[] args) {
// SpringApplication.run(Application.class, args);
// }
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
// }
// Path: app/src/test/java/de/codecentric/controller/VenueMapControllerTest.java
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.View;
import de.codecentric.Application;
import java.util.Collections;
package de.codecentric.controller;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class VenueMapControllerTest {
@InjectMocks
VenueMapController controller;
@Mock
View mockView;
@Mock | NewsDao newsDao; |
codecentric/conference-app | app/src/test/java/de/codecentric/controller/VenueMapControllerTest.java | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/Application.java
// @EnableAutoConfiguration
// @SpringBootApplication
// @ComponentScan
// @Import(ApplicationWebConfiguration.class)
// public class Application extends SpringBootServletInitializer {
//
// public static void main(String[] args) {
// SpringApplication.run(Application.class, args);
// }
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
// }
| import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.View;
import de.codecentric.Application;
import java.util.Collections; | package de.codecentric.controller;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class VenueMapControllerTest {
@InjectMocks
VenueMapController controller;
@Mock
View mockView;
@Mock
NewsDao newsDao;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = standaloneSetup(controller).setSingleView(mockView).build();
}
@Test
public void testVenueMapController() throws Exception { | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/Application.java
// @EnableAutoConfiguration
// @SpringBootApplication
// @ComponentScan
// @Import(ApplicationWebConfiguration.class)
// public class Application extends SpringBootServletInitializer {
//
// public static void main(String[] args) {
// SpringApplication.run(Application.class, args);
// }
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
// }
// Path: app/src/test/java/de/codecentric/controller/VenueMapControllerTest.java
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.View;
import de.codecentric.Application;
import java.util.Collections;
package de.codecentric.controller;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class VenueMapControllerTest {
@InjectMocks
VenueMapController controller;
@Mock
View mockView;
@Mock
NewsDao newsDao;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = standaloneSetup(controller).setSingleView(mockView).build();
}
@Test
public void testVenueMapController() throws Exception { | when(newsDao.getAllNews()).thenReturn(Collections.<News>emptyList()); |
codecentric/conference-app | app/src/test/java/de/codecentric/domain/JpaNewsDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/impl/JpaNewsDao.java
// @Repository("newsDao")
// @Transactional
// public class JpaNewsDao implements NewsDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaNewsDao() {
// // default constructor
// }
//
// // Test constructor
// public JpaNewsDao(EntityManager em) {
// this.em = em;
// }
//
// @Override public List<News> getAllNews() {
// return em.createNamedQuery("findAllNews", News.class).getResultList();
// }
//
// @Override public void saveNews(News n) {
// em.merge(n);
// }
//
// }
| import de.codecentric.dao.impl.JpaNewsDao;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import javax.persistence.EntityManager;
import static org.mockito.Mockito.verify;
| package de.codecentric.domain;
public class JpaNewsDaoTest {
@Mock
private EntityManager emMock;
| // Path: app/src/main/java/de/codecentric/dao/impl/JpaNewsDao.java
// @Repository("newsDao")
// @Transactional
// public class JpaNewsDao implements NewsDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaNewsDao() {
// // default constructor
// }
//
// // Test constructor
// public JpaNewsDao(EntityManager em) {
// this.em = em;
// }
//
// @Override public List<News> getAllNews() {
// return em.createNamedQuery("findAllNews", News.class).getResultList();
// }
//
// @Override public void saveNews(News n) {
// em.merge(n);
// }
//
// }
// Path: app/src/test/java/de/codecentric/domain/JpaNewsDaoTest.java
import de.codecentric.dao.impl.JpaNewsDao;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import javax.persistence.EntityManager;
import static org.mockito.Mockito.verify;
package de.codecentric.domain;
public class JpaNewsDaoTest {
@Mock
private EntityManager emMock;
| private JpaNewsDao dao;
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/CommentDao.java | // Path: app/src/main/java/de/codecentric/domain/Comment.java
// @Entity(name = "comment")
// @NamedQueries({ @NamedQuery(name = "findCommentForSession", query = "from comment where sessionId=:sessionId order by date desc"),
// @NamedQuery(name = "findRecentComments", query = "select c.date, c.author, c.text, s.id, s.title from comment c, session s where c.sessionId = s.id order by c.date desc") })
// public class Comment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// private String author;
//
// @Column(length = 2048)
// private String text;
// private Long sessionId;
//
// public Comment() {
// }
//
// public Comment(Date date, String author, String text, Long sessionId) {
// super();
// this.date = date;
// this.author = author;
// this.text = text;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public String getProcessedAuthor() {
// return author;
// // return TwitterLinkCreator.process(author);
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((text == null) ? 0 : text.hashCode());
// result = prime * result + ((author == null) ? 0 : author.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Comment other = (Comment) obj;
// if (text == null) {
// if (other.text != null) {
// return false;
// }
// } else if (!text.equals(other.text)) {
// return false;
// }
// if (author == null) {
// if (other.author != null) {
// return false;
// }
// } else if (!author.equals(other.author)) {
// return false;
// }
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// return true;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
// public class TimelineEntry {
//
// private String date;
// private String user;
// private String comment;
// private String sessionId;
// private String sessionTitle;
//
// public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
// super();
// this.date = date;
// this.user = user;
// this.comment = comment;
// this.sessionId = sessionId;
// this.sessionTitle = sessionTitle;
// }
//
// public String getDate() {
// return date;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getProcessedUser() {
// return TwitterLinkCreator.process(user);
// }
//
// public String getComment() {
// return comment;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getSessionTitle() {
// return sessionTitle;
// }
//
// }
| import java.util.List;
import de.codecentric.domain.Comment;
import de.codecentric.model.TimelineEntry;
| package de.codecentric.dao;
public interface CommentDao {
public List<Comment> getCommentsBySessionId(Long sessionId);
| // Path: app/src/main/java/de/codecentric/domain/Comment.java
// @Entity(name = "comment")
// @NamedQueries({ @NamedQuery(name = "findCommentForSession", query = "from comment where sessionId=:sessionId order by date desc"),
// @NamedQuery(name = "findRecentComments", query = "select c.date, c.author, c.text, s.id, s.title from comment c, session s where c.sessionId = s.id order by c.date desc") })
// public class Comment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// private String author;
//
// @Column(length = 2048)
// private String text;
// private Long sessionId;
//
// public Comment() {
// }
//
// public Comment(Date date, String author, String text, Long sessionId) {
// super();
// this.date = date;
// this.author = author;
// this.text = text;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public String getProcessedAuthor() {
// return author;
// // return TwitterLinkCreator.process(author);
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((text == null) ? 0 : text.hashCode());
// result = prime * result + ((author == null) ? 0 : author.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Comment other = (Comment) obj;
// if (text == null) {
// if (other.text != null) {
// return false;
// }
// } else if (!text.equals(other.text)) {
// return false;
// }
// if (author == null) {
// if (other.author != null) {
// return false;
// }
// } else if (!author.equals(other.author)) {
// return false;
// }
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// return true;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
// public class TimelineEntry {
//
// private String date;
// private String user;
// private String comment;
// private String sessionId;
// private String sessionTitle;
//
// public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
// super();
// this.date = date;
// this.user = user;
// this.comment = comment;
// this.sessionId = sessionId;
// this.sessionTitle = sessionTitle;
// }
//
// public String getDate() {
// return date;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getProcessedUser() {
// return TwitterLinkCreator.process(user);
// }
//
// public String getComment() {
// return comment;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getSessionTitle() {
// return sessionTitle;
// }
//
// }
// Path: app/src/main/java/de/codecentric/dao/CommentDao.java
import java.util.List;
import de.codecentric.domain.Comment;
import de.codecentric.model.TimelineEntry;
package de.codecentric.dao;
public interface CommentDao {
public List<Comment> getCommentsBySessionId(Long sessionId);
| public List<TimelineEntry> getRecentComments();
|
codecentric/conference-app | app/src/main/java/de/codecentric/controller/FeedbackController.java | // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
| import java.util.Date;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData;
| package de.codecentric.controller;
@Controller
@RequestMapping("/feedback")
public class FeedbackController {
@Autowired
| // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
// Path: app/src/main/java/de/codecentric/controller/FeedbackController.java
import java.util.Date;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData;
package de.codecentric.controller;
@Controller
@RequestMapping("/feedback")
public class FeedbackController {
@Autowired
| private FeedbackDao feedbackDao;
|
codecentric/conference-app | app/src/main/java/de/codecentric/controller/FeedbackController.java | // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
| import java.util.Date;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData;
| package de.codecentric.controller;
@Controller
@RequestMapping("/feedback")
public class FeedbackController {
@Autowired
private FeedbackDao feedbackDao;
@ModelAttribute("feedbackFormData")
| // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
// Path: app/src/main/java/de/codecentric/controller/FeedbackController.java
import java.util.Date;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData;
package de.codecentric.controller;
@Controller
@RequestMapping("/feedback")
public class FeedbackController {
@Autowired
private FeedbackDao feedbackDao;
@ModelAttribute("feedbackFormData")
| public FeedbackFormData getFeedbackFormData() {
|
codecentric/conference-app | app/src/main/java/de/codecentric/controller/FeedbackController.java | // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
| import java.util.Date;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData;
| package de.codecentric.controller;
@Controller
@RequestMapping("/feedback")
public class FeedbackController {
@Autowired
private FeedbackDao feedbackDao;
@ModelAttribute("feedbackFormData")
public FeedbackFormData getFeedbackFormData() {
return new FeedbackFormData();
}
@RequestMapping(method = RequestMethod.GET)
public String getFeedback(Map<String, Object> modelMap) {
modelMap.put("feedbackList", feedbackDao.getFeedbackList());
return "feedback";
}
@RequestMapping(method = RequestMethod.POST)
public ModelAndView saveFeedback(ModelMap modelMap, @ModelAttribute("feedbackFormData") FeedbackFormData formData) {
modelMap.put("feedbackFormData", formData);
| // Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
// Path: app/src/main/java/de/codecentric/controller/FeedbackController.java
import java.util.Date;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData;
package de.codecentric.controller;
@Controller
@RequestMapping("/feedback")
public class FeedbackController {
@Autowired
private FeedbackDao feedbackDao;
@ModelAttribute("feedbackFormData")
public FeedbackFormData getFeedbackFormData() {
return new FeedbackFormData();
}
@RequestMapping(method = RequestMethod.GET)
public String getFeedback(Map<String, Object> modelMap) {
modelMap.put("feedbackList", feedbackDao.getFeedbackList());
return "feedback";
}
@RequestMapping(method = RequestMethod.POST)
public ModelAndView saveFeedback(ModelMap modelMap, @ModelAttribute("feedbackFormData") FeedbackFormData formData) {
modelMap.put("feedbackFormData", formData);
| Feedback feedback = new Feedback();
|
codecentric/conference-app | app/src/test/java/de/codecentric/domain/JpaCommentDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/impl/JpaCommentDao.java
// @Repository("commentDao")
// @Transactional
// public class JpaCommentDao implements CommentDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaCommentDao() {
// }
//
// // test constructor
// public JpaCommentDao(EntityManager em) {
// this.em = em;
// }
//
// @SuppressWarnings("unchecked")
// public List<Comment> getCommentsBySessionId(Long sessionId) {
// Query query = em.createNamedQuery("findCommentForSession");
// return query.setParameter("sessionId", sessionId).getResultList();
// }
//
// public List<TimelineEntry> getRecentComments() {
// List<TimelineEntry> result = new ArrayList<TimelineEntry>();
//
// @SuppressWarnings("unchecked")
// List<Object[]> resultList = em.createNamedQuery("findRecentComments").setMaxResults(25).getResultList();
//
// for (Object[] entry : resultList) {
// result.add(new TimelineEntry(entry[0] != null ? entry[0].toString() : "", entry[0] != null ? entry[1].toString() : "", entry[0] != null ? entry[2].toString() : "",
// entry[0] != null ? entry[3].toString() : "", entry[0] != null ? entry[4].toString() : ""));
// }
//
// return result;
// }
//
// public void saveComment(Comment comment) {
// em.merge(comment);
// }
//
// }
| import static org.mockito.Mockito.verify;
import java.util.Date;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.dao.impl.JpaCommentDao;
| package de.codecentric.domain;
public class JpaCommentDaoTest {
@Mock
private EntityManager emMock;
| // Path: app/src/main/java/de/codecentric/dao/impl/JpaCommentDao.java
// @Repository("commentDao")
// @Transactional
// public class JpaCommentDao implements CommentDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaCommentDao() {
// }
//
// // test constructor
// public JpaCommentDao(EntityManager em) {
// this.em = em;
// }
//
// @SuppressWarnings("unchecked")
// public List<Comment> getCommentsBySessionId(Long sessionId) {
// Query query = em.createNamedQuery("findCommentForSession");
// return query.setParameter("sessionId", sessionId).getResultList();
// }
//
// public List<TimelineEntry> getRecentComments() {
// List<TimelineEntry> result = new ArrayList<TimelineEntry>();
//
// @SuppressWarnings("unchecked")
// List<Object[]> resultList = em.createNamedQuery("findRecentComments").setMaxResults(25).getResultList();
//
// for (Object[] entry : resultList) {
// result.add(new TimelineEntry(entry[0] != null ? entry[0].toString() : "", entry[0] != null ? entry[1].toString() : "", entry[0] != null ? entry[2].toString() : "",
// entry[0] != null ? entry[3].toString() : "", entry[0] != null ? entry[4].toString() : ""));
// }
//
// return result;
// }
//
// public void saveComment(Comment comment) {
// em.merge(comment);
// }
//
// }
// Path: app/src/test/java/de/codecentric/domain/JpaCommentDaoTest.java
import static org.mockito.Mockito.verify;
import java.util.Date;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.dao.impl.JpaCommentDao;
package de.codecentric.domain;
public class JpaCommentDaoTest {
@Mock
private EntityManager emMock;
| private JpaCommentDao dao;
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java | // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.dao.impl;
@Repository
public class JsonTimeslotDao implements TimeslotDao {
private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
@Autowired
private ObjectMapper jsonMapper;
| // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.dao.impl;
@Repository
public class JsonTimeslotDao implements TimeslotDao {
private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
@Autowired
private ObjectMapper jsonMapper;
| private static List<Day> days;
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java | // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.dao.impl;
@Repository
public class JsonTimeslotDao implements TimeslotDao {
private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
@Autowired
private ObjectMapper jsonMapper;
private static List<Day> days;
@Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
private String filePath;
public JsonTimeslotDao() {
}
public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
this.filePath = filePath;
this.jsonMapper = mapper;
}
| // Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
// public interface TimeslotDao {
//
// List<Timeslot> getTimeslots(String day);
//
// List<Day> getConferenceDays();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JsonTimeslotDao.java
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import de.codecentric.dao.TimeslotDao;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.dao.impl;
@Repository
public class JsonTimeslotDao implements TimeslotDao {
private static final Logger LOGGER = Logger.getLogger(JsonTimeslotDao.class);
@Autowired
private ObjectMapper jsonMapper;
private static List<Day> days;
@Value("default.file.path.days.and.timeslots:json/daysAndTimeslots.json")
private String filePath;
public JsonTimeslotDao() {
}
public JsonTimeslotDao(ObjectMapper mapper, String filePath) {
this.filePath = filePath;
this.jsonMapper = mapper;
}
| public List<Timeslot> getTimeslots(String dayName) {
|
codecentric/conference-app | app/src/main/java/de/codecentric/Application.java | // Path: app/src/main/java/de/codecentric/config/ApplicationWebConfiguration.java
// @Configuration
// public class ApplicationWebConfiguration extends WebMvcConfigurerAdapter {
//
// @Override
// public void addViewControllers(ViewControllerRegistry registry) {
// super.addViewControllers(registry);
// registry.addViewController("/").setViewName("redirect:/currentSessions");
// }
//
// @Bean
// public ObjectMapper objectMapper() {
// return new ObjectMapper();
// }
//
// @Bean
// public TimeValidator timeValidator() {
// return new Time24HoursValidator();
// }
//
// @Bean
// public LocaleResolver localeResolver() {
// SessionLocaleResolver slr = new SessionLocaleResolver();
// slr.setDefaultLocale(Locale.US);
// return slr;
// }
//
// }
| import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import de.codecentric.config.ApplicationWebConfiguration; | package de.codecentric;
@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan | // Path: app/src/main/java/de/codecentric/config/ApplicationWebConfiguration.java
// @Configuration
// public class ApplicationWebConfiguration extends WebMvcConfigurerAdapter {
//
// @Override
// public void addViewControllers(ViewControllerRegistry registry) {
// super.addViewControllers(registry);
// registry.addViewController("/").setViewName("redirect:/currentSessions");
// }
//
// @Bean
// public ObjectMapper objectMapper() {
// return new ObjectMapper();
// }
//
// @Bean
// public TimeValidator timeValidator() {
// return new Time24HoursValidator();
// }
//
// @Bean
// public LocaleResolver localeResolver() {
// SessionLocaleResolver slr = new SessionLocaleResolver();
// slr.setDefaultLocale(Locale.US);
// return slr;
// }
//
// }
// Path: app/src/main/java/de/codecentric/Application.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import de.codecentric.config.ApplicationWebConfiguration;
package de.codecentric;
@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan | @Import(ApplicationWebConfiguration.class) |
codecentric/conference-app | app/src/main/java/de/codecentric/model/TimelineEntry.java | // Path: app/src/main/java/de/codecentric/util/TwitterLinkCreator.java
// public class TwitterLinkCreator {
//
// public static final Pattern TWITTER_NAME_PATTERN = Pattern.compile("@[a-zA-Z0-9_]+");
//
// public static String process(String result) {
// Matcher m = TWITTER_NAME_PATTERN.matcher(result);
//
// while (m.find()) {
// final String name = m.group();
// result = result.replaceFirst(name, "<a href=\"http://twitter.com/" + name.substring(1) + "\">" + name + "</a>");
// }
//
// return result;
// }
// }
| import de.codecentric.util.TwitterLinkCreator; | package de.codecentric.model;
public class TimelineEntry {
private String date;
private String user;
private String comment;
private String sessionId;
private String sessionTitle;
public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
super();
this.date = date;
this.user = user;
this.comment = comment;
this.sessionId = sessionId;
this.sessionTitle = sessionTitle;
}
public String getDate() {
return date;
}
public String getUser() {
return user;
}
public String getProcessedUser() { | // Path: app/src/main/java/de/codecentric/util/TwitterLinkCreator.java
// public class TwitterLinkCreator {
//
// public static final Pattern TWITTER_NAME_PATTERN = Pattern.compile("@[a-zA-Z0-9_]+");
//
// public static String process(String result) {
// Matcher m = TWITTER_NAME_PATTERN.matcher(result);
//
// while (m.find()) {
// final String name = m.group();
// result = result.replaceFirst(name, "<a href=\"http://twitter.com/" + name.substring(1) + "\">" + name + "</a>");
// }
//
// return result;
// }
// }
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
import de.codecentric.util.TwitterLinkCreator;
package de.codecentric.model;
public class TimelineEntry {
private String date;
private String user;
private String comment;
private String sessionId;
private String sessionTitle;
public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
super();
this.date = date;
this.user = user;
this.comment = comment;
this.sessionId = sessionId;
this.sessionTitle = sessionTitle;
}
public String getDate() {
return date;
}
public String getUser() {
return user;
}
public String getProcessedUser() { | return TwitterLinkCreator.process(user); |
codecentric/conference-app | app/src/main/java/de/codecentric/dao/TimeslotDao.java | // Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import java.util.List;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
| package de.codecentric.dao;
public interface TimeslotDao {
List<Timeslot> getTimeslots(String day);
| // Path: app/src/main/java/de/codecentric/domain/Day.java
// public class Day {
//
// private String shortName;
// private List<Timeslot> timeslots;
//
// @JsonCreator
// public Day(@JsonProperty("shortName") String shortName, @JsonProperty("timeslots") List<Timeslot> timeslots) {
// this.shortName = shortName;
// this.timeslots = timeslots;
// }
//
// public String getShortName() {
// return shortName;
// }
//
// public List<Timeslot> getTimeslots() {
// return timeslots;
// }
//
// public String getShortNameWithoutDots() {
// return shortName.replace(".", "");
// }
//
// @Override
// public String toString() {
// return "Day [shortName=" + shortName + ", timeslots=" + timeslots + "]";
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/main/java/de/codecentric/dao/TimeslotDao.java
import java.util.List;
import de.codecentric.domain.Day;
import de.codecentric.domain.Timeslot;
package de.codecentric.dao;
public interface TimeslotDao {
List<Timeslot> getTimeslots(String day);
| List<Day> getConferenceDays();
|
codecentric/conference-app | app/src/main/java/de/codecentric/controller/VenueMapController.java | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JpaNewsDao.java
// @Repository("newsDao")
// @Transactional
// public class JpaNewsDao implements NewsDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaNewsDao() {
// // default constructor
// }
//
// // Test constructor
// public JpaNewsDao(EntityManager em) {
// this.em = em;
// }
//
// @Override public List<News> getAllNews() {
// return em.createNamedQuery("findAllNews", News.class).getResultList();
// }
//
// @Override public void saveNews(News n) {
// em.merge(n);
// }
//
// }
| import java.util.Map;
import de.codecentric.dao.NewsDao;
import de.codecentric.dao.impl.JpaNewsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
| package de.codecentric.controller;
@Controller
@RequestMapping("/venueMap")
public class VenueMapController {
@Autowired
| // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/dao/impl/JpaNewsDao.java
// @Repository("newsDao")
// @Transactional
// public class JpaNewsDao implements NewsDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaNewsDao() {
// // default constructor
// }
//
// // Test constructor
// public JpaNewsDao(EntityManager em) {
// this.em = em;
// }
//
// @Override public List<News> getAllNews() {
// return em.createNamedQuery("findAllNews", News.class).getResultList();
// }
//
// @Override public void saveNews(News n) {
// em.merge(n);
// }
//
// }
// Path: app/src/main/java/de/codecentric/controller/VenueMapController.java
import java.util.Map;
import de.codecentric.dao.NewsDao;
import de.codecentric.dao.impl.JpaNewsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
package de.codecentric.controller;
@Controller
@RequestMapping("/venueMap")
public class VenueMapController {
@Autowired
| private NewsDao newsDao;
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaCommentDao.java | // Path: app/src/main/java/de/codecentric/dao/CommentDao.java
// public interface CommentDao {
//
// public List<Comment> getCommentsBySessionId(Long sessionId);
//
// public List<TimelineEntry> getRecentComments();
//
// public void saveComment(Comment comment);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Comment.java
// @Entity(name = "comment")
// @NamedQueries({ @NamedQuery(name = "findCommentForSession", query = "from comment where sessionId=:sessionId order by date desc"),
// @NamedQuery(name = "findRecentComments", query = "select c.date, c.author, c.text, s.id, s.title from comment c, session s where c.sessionId = s.id order by c.date desc") })
// public class Comment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// private String author;
//
// @Column(length = 2048)
// private String text;
// private Long sessionId;
//
// public Comment() {
// }
//
// public Comment(Date date, String author, String text, Long sessionId) {
// super();
// this.date = date;
// this.author = author;
// this.text = text;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public String getProcessedAuthor() {
// return author;
// // return TwitterLinkCreator.process(author);
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((text == null) ? 0 : text.hashCode());
// result = prime * result + ((author == null) ? 0 : author.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Comment other = (Comment) obj;
// if (text == null) {
// if (other.text != null) {
// return false;
// }
// } else if (!text.equals(other.text)) {
// return false;
// }
// if (author == null) {
// if (other.author != null) {
// return false;
// }
// } else if (!author.equals(other.author)) {
// return false;
// }
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// return true;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
// public class TimelineEntry {
//
// private String date;
// private String user;
// private String comment;
// private String sessionId;
// private String sessionTitle;
//
// public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
// super();
// this.date = date;
// this.user = user;
// this.comment = comment;
// this.sessionId = sessionId;
// this.sessionTitle = sessionTitle;
// }
//
// public String getDate() {
// return date;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getProcessedUser() {
// return TwitterLinkCreator.process(user);
// }
//
// public String getComment() {
// return comment;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getSessionTitle() {
// return sessionTitle;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.CommentDao;
import de.codecentric.domain.Comment;
import de.codecentric.model.TimelineEntry;
| package de.codecentric.dao.impl;
@Repository("commentDao")
@Transactional
| // Path: app/src/main/java/de/codecentric/dao/CommentDao.java
// public interface CommentDao {
//
// public List<Comment> getCommentsBySessionId(Long sessionId);
//
// public List<TimelineEntry> getRecentComments();
//
// public void saveComment(Comment comment);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Comment.java
// @Entity(name = "comment")
// @NamedQueries({ @NamedQuery(name = "findCommentForSession", query = "from comment where sessionId=:sessionId order by date desc"),
// @NamedQuery(name = "findRecentComments", query = "select c.date, c.author, c.text, s.id, s.title from comment c, session s where c.sessionId = s.id order by c.date desc") })
// public class Comment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// private String author;
//
// @Column(length = 2048)
// private String text;
// private Long sessionId;
//
// public Comment() {
// }
//
// public Comment(Date date, String author, String text, Long sessionId) {
// super();
// this.date = date;
// this.author = author;
// this.text = text;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public String getProcessedAuthor() {
// return author;
// // return TwitterLinkCreator.process(author);
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((text == null) ? 0 : text.hashCode());
// result = prime * result + ((author == null) ? 0 : author.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Comment other = (Comment) obj;
// if (text == null) {
// if (other.text != null) {
// return false;
// }
// } else if (!text.equals(other.text)) {
// return false;
// }
// if (author == null) {
// if (other.author != null) {
// return false;
// }
// } else if (!author.equals(other.author)) {
// return false;
// }
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// return true;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
// public class TimelineEntry {
//
// private String date;
// private String user;
// private String comment;
// private String sessionId;
// private String sessionTitle;
//
// public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
// super();
// this.date = date;
// this.user = user;
// this.comment = comment;
// this.sessionId = sessionId;
// this.sessionTitle = sessionTitle;
// }
//
// public String getDate() {
// return date;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getProcessedUser() {
// return TwitterLinkCreator.process(user);
// }
//
// public String getComment() {
// return comment;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getSessionTitle() {
// return sessionTitle;
// }
//
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaCommentDao.java
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.CommentDao;
import de.codecentric.domain.Comment;
import de.codecentric.model.TimelineEntry;
package de.codecentric.dao.impl;
@Repository("commentDao")
@Transactional
| public class JpaCommentDao implements CommentDao {
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaCommentDao.java | // Path: app/src/main/java/de/codecentric/dao/CommentDao.java
// public interface CommentDao {
//
// public List<Comment> getCommentsBySessionId(Long sessionId);
//
// public List<TimelineEntry> getRecentComments();
//
// public void saveComment(Comment comment);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Comment.java
// @Entity(name = "comment")
// @NamedQueries({ @NamedQuery(name = "findCommentForSession", query = "from comment where sessionId=:sessionId order by date desc"),
// @NamedQuery(name = "findRecentComments", query = "select c.date, c.author, c.text, s.id, s.title from comment c, session s where c.sessionId = s.id order by c.date desc") })
// public class Comment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// private String author;
//
// @Column(length = 2048)
// private String text;
// private Long sessionId;
//
// public Comment() {
// }
//
// public Comment(Date date, String author, String text, Long sessionId) {
// super();
// this.date = date;
// this.author = author;
// this.text = text;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public String getProcessedAuthor() {
// return author;
// // return TwitterLinkCreator.process(author);
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((text == null) ? 0 : text.hashCode());
// result = prime * result + ((author == null) ? 0 : author.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Comment other = (Comment) obj;
// if (text == null) {
// if (other.text != null) {
// return false;
// }
// } else if (!text.equals(other.text)) {
// return false;
// }
// if (author == null) {
// if (other.author != null) {
// return false;
// }
// } else if (!author.equals(other.author)) {
// return false;
// }
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// return true;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
// public class TimelineEntry {
//
// private String date;
// private String user;
// private String comment;
// private String sessionId;
// private String sessionTitle;
//
// public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
// super();
// this.date = date;
// this.user = user;
// this.comment = comment;
// this.sessionId = sessionId;
// this.sessionTitle = sessionTitle;
// }
//
// public String getDate() {
// return date;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getProcessedUser() {
// return TwitterLinkCreator.process(user);
// }
//
// public String getComment() {
// return comment;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getSessionTitle() {
// return sessionTitle;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.CommentDao;
import de.codecentric.domain.Comment;
import de.codecentric.model.TimelineEntry;
| package de.codecentric.dao.impl;
@Repository("commentDao")
@Transactional
public class JpaCommentDao implements CommentDao {
@PersistenceContext
private EntityManager em;
public JpaCommentDao() {
}
// test constructor
public JpaCommentDao(EntityManager em) {
this.em = em;
}
@SuppressWarnings("unchecked")
| // Path: app/src/main/java/de/codecentric/dao/CommentDao.java
// public interface CommentDao {
//
// public List<Comment> getCommentsBySessionId(Long sessionId);
//
// public List<TimelineEntry> getRecentComments();
//
// public void saveComment(Comment comment);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Comment.java
// @Entity(name = "comment")
// @NamedQueries({ @NamedQuery(name = "findCommentForSession", query = "from comment where sessionId=:sessionId order by date desc"),
// @NamedQuery(name = "findRecentComments", query = "select c.date, c.author, c.text, s.id, s.title from comment c, session s where c.sessionId = s.id order by c.date desc") })
// public class Comment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// private String author;
//
// @Column(length = 2048)
// private String text;
// private Long sessionId;
//
// public Comment() {
// }
//
// public Comment(Date date, String author, String text, Long sessionId) {
// super();
// this.date = date;
// this.author = author;
// this.text = text;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public String getProcessedAuthor() {
// return author;
// // return TwitterLinkCreator.process(author);
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((text == null) ? 0 : text.hashCode());
// result = prime * result + ((author == null) ? 0 : author.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Comment other = (Comment) obj;
// if (text == null) {
// if (other.text != null) {
// return false;
// }
// } else if (!text.equals(other.text)) {
// return false;
// }
// if (author == null) {
// if (other.author != null) {
// return false;
// }
// } else if (!author.equals(other.author)) {
// return false;
// }
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// return true;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
// public class TimelineEntry {
//
// private String date;
// private String user;
// private String comment;
// private String sessionId;
// private String sessionTitle;
//
// public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
// super();
// this.date = date;
// this.user = user;
// this.comment = comment;
// this.sessionId = sessionId;
// this.sessionTitle = sessionTitle;
// }
//
// public String getDate() {
// return date;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getProcessedUser() {
// return TwitterLinkCreator.process(user);
// }
//
// public String getComment() {
// return comment;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getSessionTitle() {
// return sessionTitle;
// }
//
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaCommentDao.java
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.CommentDao;
import de.codecentric.domain.Comment;
import de.codecentric.model.TimelineEntry;
package de.codecentric.dao.impl;
@Repository("commentDao")
@Transactional
public class JpaCommentDao implements CommentDao {
@PersistenceContext
private EntityManager em;
public JpaCommentDao() {
}
// test constructor
public JpaCommentDao(EntityManager em) {
this.em = em;
}
@SuppressWarnings("unchecked")
| public List<Comment> getCommentsBySessionId(Long sessionId) {
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaCommentDao.java | // Path: app/src/main/java/de/codecentric/dao/CommentDao.java
// public interface CommentDao {
//
// public List<Comment> getCommentsBySessionId(Long sessionId);
//
// public List<TimelineEntry> getRecentComments();
//
// public void saveComment(Comment comment);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Comment.java
// @Entity(name = "comment")
// @NamedQueries({ @NamedQuery(name = "findCommentForSession", query = "from comment where sessionId=:sessionId order by date desc"),
// @NamedQuery(name = "findRecentComments", query = "select c.date, c.author, c.text, s.id, s.title from comment c, session s where c.sessionId = s.id order by c.date desc") })
// public class Comment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// private String author;
//
// @Column(length = 2048)
// private String text;
// private Long sessionId;
//
// public Comment() {
// }
//
// public Comment(Date date, String author, String text, Long sessionId) {
// super();
// this.date = date;
// this.author = author;
// this.text = text;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public String getProcessedAuthor() {
// return author;
// // return TwitterLinkCreator.process(author);
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((text == null) ? 0 : text.hashCode());
// result = prime * result + ((author == null) ? 0 : author.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Comment other = (Comment) obj;
// if (text == null) {
// if (other.text != null) {
// return false;
// }
// } else if (!text.equals(other.text)) {
// return false;
// }
// if (author == null) {
// if (other.author != null) {
// return false;
// }
// } else if (!author.equals(other.author)) {
// return false;
// }
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// return true;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
// public class TimelineEntry {
//
// private String date;
// private String user;
// private String comment;
// private String sessionId;
// private String sessionTitle;
//
// public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
// super();
// this.date = date;
// this.user = user;
// this.comment = comment;
// this.sessionId = sessionId;
// this.sessionTitle = sessionTitle;
// }
//
// public String getDate() {
// return date;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getProcessedUser() {
// return TwitterLinkCreator.process(user);
// }
//
// public String getComment() {
// return comment;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getSessionTitle() {
// return sessionTitle;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.CommentDao;
import de.codecentric.domain.Comment;
import de.codecentric.model.TimelineEntry;
| package de.codecentric.dao.impl;
@Repository("commentDao")
@Transactional
public class JpaCommentDao implements CommentDao {
@PersistenceContext
private EntityManager em;
public JpaCommentDao() {
}
// test constructor
public JpaCommentDao(EntityManager em) {
this.em = em;
}
@SuppressWarnings("unchecked")
public List<Comment> getCommentsBySessionId(Long sessionId) {
Query query = em.createNamedQuery("findCommentForSession");
return query.setParameter("sessionId", sessionId).getResultList();
}
| // Path: app/src/main/java/de/codecentric/dao/CommentDao.java
// public interface CommentDao {
//
// public List<Comment> getCommentsBySessionId(Long sessionId);
//
// public List<TimelineEntry> getRecentComments();
//
// public void saveComment(Comment comment);
//
// }
//
// Path: app/src/main/java/de/codecentric/domain/Comment.java
// @Entity(name = "comment")
// @NamedQueries({ @NamedQuery(name = "findCommentForSession", query = "from comment where sessionId=:sessionId order by date desc"),
// @NamedQuery(name = "findRecentComments", query = "select c.date, c.author, c.text, s.id, s.title from comment c, session s where c.sessionId = s.id order by c.date desc") })
// public class Comment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// private Date date;
//
// private String author;
//
// @Column(length = 2048)
// private String text;
// private Long sessionId;
//
// public Comment() {
// }
//
// public Comment(Date date, String author, String text, Long sessionId) {
// super();
// this.date = date;
// this.author = author;
// this.text = text;
// this.sessionId = sessionId;
// }
//
// public long getId() {
// return id;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public String getProcessedAuthor() {
// return author;
// // return TwitterLinkCreator.process(author);
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getSessionId() {
// return sessionId;
// }
//
// public void setSessionId(Long sessionId) {
// this.sessionId = sessionId;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((text == null) ? 0 : text.hashCode());
// result = prime * result + ((author == null) ? 0 : author.hashCode());
// result = prime * result + ((date == null) ? 0 : date.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// Comment other = (Comment) obj;
// if (text == null) {
// if (other.text != null) {
// return false;
// }
// } else if (!text.equals(other.text)) {
// return false;
// }
// if (author == null) {
// if (other.author != null) {
// return false;
// }
// } else if (!author.equals(other.author)) {
// return false;
// }
// if (date == null) {
// if (other.date != null) {
// return false;
// }
// } else if (!date.equals(other.date)) {
// return false;
// }
// return true;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/TimelineEntry.java
// public class TimelineEntry {
//
// private String date;
// private String user;
// private String comment;
// private String sessionId;
// private String sessionTitle;
//
// public TimelineEntry(String date, String user, String comment, String sessionId, String sessionTitle) {
// super();
// this.date = date;
// this.user = user;
// this.comment = comment;
// this.sessionId = sessionId;
// this.sessionTitle = sessionTitle;
// }
//
// public String getDate() {
// return date;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getProcessedUser() {
// return TwitterLinkCreator.process(user);
// }
//
// public String getComment() {
// return comment;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getSessionTitle() {
// return sessionTitle;
// }
//
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaCommentDao.java
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import de.codecentric.dao.CommentDao;
import de.codecentric.domain.Comment;
import de.codecentric.model.TimelineEntry;
package de.codecentric.dao.impl;
@Repository("commentDao")
@Transactional
public class JpaCommentDao implements CommentDao {
@PersistenceContext
private EntityManager em;
public JpaCommentDao() {
}
// test constructor
public JpaCommentDao(EntityManager em) {
this.em = em;
}
@SuppressWarnings("unchecked")
public List<Comment> getCommentsBySessionId(Long sessionId) {
Query query = em.createNamedQuery("findCommentForSession");
return query.setParameter("sessionId", sessionId).getResultList();
}
| public List<TimelineEntry> getRecentComments() {
|
codecentric/conference-app | app/src/test/java/de/codecentric/validate/NameValidatorTests.java | // Path: app/src/main/java/de/codecentric/validate/impl/NameValidatorImpl.java
// public class NameValidatorImpl implements NameValidator {
//
// @Override
// public boolean isValid(String speaker) {
//
// if (speaker.isEmpty()) {
// return false;
// }
//
// return TwitterLinkCreator.TWITTER_NAME_PATTERN.matcher(speaker).matches();
// }
//
// }
| import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.codecentric.validate.impl.NameValidatorImpl; | package de.codecentric.validate;
/**
* Created by adi on 8/21/14.
*/
public class NameValidatorTests {
@Test
public void nameValidWhenContainsNumbers() { | // Path: app/src/main/java/de/codecentric/validate/impl/NameValidatorImpl.java
// public class NameValidatorImpl implements NameValidator {
//
// @Override
// public boolean isValid(String speaker) {
//
// if (speaker.isEmpty()) {
// return false;
// }
//
// return TwitterLinkCreator.TWITTER_NAME_PATTERN.matcher(speaker).matches();
// }
//
// }
// Path: app/src/test/java/de/codecentric/validate/NameValidatorTests.java
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.codecentric.validate.impl.NameValidatorImpl;
package de.codecentric.validate;
/**
* Created by adi on 8/21/14.
*/
public class NameValidatorTests {
@Test
public void nameValidWhenContainsNumbers() { | NameValidatorImpl nameValidator = new NameValidatorImpl(); |
codecentric/conference-app | app/src/test/java/de/codecentric/domain/TimeslotTest.java | // Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import de.codecentric.domain.Timeslot;
| package de.codecentric.domain;
public class TimeslotTest {
@Test
public void shouldFormatStringForTimeslotWithStartAndEnd() {
| // Path: app/src/main/java/de/codecentric/domain/Timeslot.java
// public class Timeslot {
//
// private String start;
// private String end;
//
// @JsonCreator
// public Timeslot(@JsonProperty("start") String start, @JsonProperty("end") String end) {
// this(start);
// this.end = end;
// }
//
// public Timeslot(String start) {
// this.start = start;
// }
//
// public String getStart() {
// return start;
// }
//
// public String getEnd() {
// return end;
// }
//
// @Override
// public String toString() {
// String endToConcatenate = end != null ? " - " + end : "";
// return start + endToConcatenate;
// }
// }
// Path: app/src/test/java/de/codecentric/domain/TimeslotTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import de.codecentric.domain.Timeslot;
package de.codecentric.domain;
public class TimeslotTest {
@Test
public void shouldFormatStringForTimeslotWithStartAndEnd() {
| Timeslot timeslot = new Timeslot("15:30", "16:15");
|
codecentric/conference-app | app/src/main/java/de/codecentric/controller/NewsController.java | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/NewsFormData.java
// public class NewsFormData {
//
// private String text;
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// }
| import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import de.codecentric.model.NewsFormData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map; | package de.codecentric.controller;
@Controller
@RequestMapping("/admin/news")
public class NewsController {
@Autowired | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/NewsFormData.java
// public class NewsFormData {
//
// private String text;
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// }
// Path: app/src/main/java/de/codecentric/controller/NewsController.java
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import de.codecentric.model.NewsFormData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
package de.codecentric.controller;
@Controller
@RequestMapping("/admin/news")
public class NewsController {
@Autowired | private NewsDao newsDao; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.