code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
package br.com.teckstoq.dao; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; import br.com.teckstoq.hibernate.HibernateUtil; /** * @author Paulo Lima * @category Projeto TeckEstoq Java SE * @since 05/09/2014 * @version 1.0 * */ public class Dao { private static Dao instance; private Session sessao; private Transaction tx; private Dao() { } public static Dao getInstance() { if (instance == null) instance = new Dao(); return instance; } public <T> boolean save(T object) { try { sessao = HibernateUtil.getSession(); tx = sessao.beginTransaction(); sessao.save(object); tx.commit(); return true; } catch (Exception e) { e.printStackTrace(); return false; } finally { sessao.close(); } } public <T> boolean update(T object) { try { sessao = HibernateUtil.getSession(); tx = sessao.beginTransaction(); sessao.update(object); tx.commit(); return true; } catch (Exception e) { e.printStackTrace(); return false; } finally { sessao.close(); } } public <T> boolean delete(T object) { try { sessao = HibernateUtil.getSession(); tx = sessao.beginTransaction(); sessao.delete(object); tx.commit(); return true; } catch (Exception e) { e.printStackTrace(); return false; } finally { sessao.close(); } } public List<?> list(Class<?> classe) { try { sessao = HibernateUtil.getSession(); tx = sessao.beginTransaction(); Criteria criteria = sessao.createCriteria(classe); tx.commit(); return criteria.list(); } catch (Exception e) { e.printStackTrace(); return null; } finally { sessao.close(); } } public List<?> createQuery(String query) { try { sessao = HibernateUtil.getSession(); tx = sessao.beginTransaction(); Query select = sessao.createQuery(query); tx.commit(); return select.list(); } catch (Exception e) { e.printStackTrace(); return null; } } }
09012015teckstoq09012015
src/br/com/teckstoq/dao/Dao.java
Java
oos
2,156
package br.com.teckstoq.models; import java.util.ArrayList; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; @Entity @Table(name = "equipamento") public class Equipamento { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id_maquina") private long idMaquina; @Column(name = "nome_maquina") private String nomeMaquina; @Column(name = "observcoes") private String observacoes; @Column(name = "valor") private String valor; @Column(name = "data_compra") private String dataCompra; @Column(name = "data_fabricacao") private String dataFabricacao; @Column(name = "horas_ativa") private String horasAtiva; @Column(name = "qtd_operadores") private String qtdOperadores; @Column(name = "eficacia_tempo") private String eficaciaTempo; @Column(name = "edicacia_producao") private String edicaciaProducao; @Column(name = "status") private String status; @Column(name = "hora_cadastro") private String horaCadastro; @Column(name = "data_cadastro") private String dataCadastro; @Column(name = "codigo_de_fabrica") private String codigoFabrica; @Column(name = "codigo_de_fornecedor") private String codigoFornecedor; @Column(name = "numero_nota_fiscal") private String numeroNotaFiscal; @Column(name = "data_fim_garantia") private String dataFimGarantia; @Column(name = "potencia") private String potencia; @Column(name = "consumo") private String consumo; @Column(name = "tensao") private String tensao; @OneToOne private Fornecedor fornecedor; @OneToOne private Funcionario funcionario; @OneToOne private Setor setor; @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, orphanRemoval = true) @JoinTable(name = "equipamento_operador", joinColumns = { @JoinColumn(name = "id_equipamento") }, inverseJoinColumns = { @JoinColumn(name = "id_funcionario") }) private List<Funcionario> operadores = new ArrayList<Funcionario>(0); // GETs e SETs // -------------------------------------------------------------------- public long getIdMaquina() { return idMaquina; } public void setIdMaquina(long idMaquina) { this.idMaquina = idMaquina; } public String getNomeMaquina() { return nomeMaquina; } public void setNomeMaquina(String nomeMaquina) { this.nomeMaquina = nomeMaquina; } public String getObservacoes() { return observacoes; } public void setObservacoes(String observacoes) { this.observacoes = observacoes; } public String getValor() { return valor; } public void setValor(String valor) { this.valor = valor; } public String getDataCompra() { return dataCompra; } public void setDataCompra(String dataCompra) { this.dataCompra = dataCompra; } public String getDataFabricacao() { return dataFabricacao; } public void setDataFabricacao(String dataFabricacao) { this.dataFabricacao = dataFabricacao; } public String getHorasAtiva() { return horasAtiva; } public void setHorasAtiva(String horasAtiva) { this.horasAtiva = horasAtiva; } public String getQtdOperadores() { return qtdOperadores; } public void setQtdOperadores(String qtdOperadores) { this.qtdOperadores = qtdOperadores; } public String getEficaciaTempo() { return eficaciaTempo; } public void setEficaciaTempo(String eficaciaTempo) { this.eficaciaTempo = eficaciaTempo; } public String getEdicaciaProducao() { return edicaciaProducao; } public void setEdicaciaProducao(String edicaciaProducao) { this.edicaciaProducao = edicaciaProducao; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getHoraCadastro() { return horaCadastro; } public void setHoraCadastro(String horaCadastro) { this.horaCadastro = horaCadastro; } public String getDataCadastro() { return dataCadastro; } public void setDataCadastro(String dataCadastro) { this.dataCadastro = dataCadastro; } public String getCodigoFabrica() { return codigoFabrica; } public void setCodigoFabrica(String codigoFabrica) { this.codigoFabrica = codigoFabrica; } public String getCodigoFornecedor() { return codigoFornecedor; } public void setCodigoFornecedor(String codigoFornecedor) { this.codigoFornecedor = codigoFornecedor; } public String getNumeroNotaFiscal() { return numeroNotaFiscal; } public void setNumeroNotaFiscal(String numeroNotaFiscal) { this.numeroNotaFiscal = numeroNotaFiscal; } public String getDataFimGarantia() { return dataFimGarantia; } public void setDataFimGarantia(String dataFimGarantia) { this.dataFimGarantia = dataFimGarantia; } public String getPotencia() { return potencia; } public void setPotencia(String potencia) { this.potencia = potencia; } public String getConsumo() { return consumo; } public void setConsumo(String consumo) { this.consumo = consumo; } public String getTensao() { return tensao; } public void setTensao(String tensao) { this.tensao = tensao; } public Fornecedor getFornecedor() { return fornecedor; } public void setFornecedor(Fornecedor fornecedor) { this.fornecedor = fornecedor; } public Funcionario getFuncionario() { return funcionario; } public void setFuncionario(Funcionario funcionario) { this.funcionario = funcionario; } public Setor getSetor() { return setor; } public void setSetor(Setor setor) { this.setor = setor; } public List<Funcionario> getOperadores() { return operadores; } public void setOperadores(List<Funcionario> operadores) { this.operadores = operadores; } public String toString() { return this.nomeMaquina; } // ----------------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/models/Equipamento.java
Java
oos
6,366
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.EntradaEmprestimo; public interface IRepositorioEntradaEmprestimo { public void inserirEntradaEmprestimo(EntradaEmprestimo entradaEmprestimo) throws SQLException; public void atualizarEntradaEmprestimo(EntradaEmprestimo entradaEmprestimo) throws SQLException; public void removerEntradaEmprestimo(EntradaEmprestimo entradaEmprestimo) throws SQLException; public ArrayList<EntradaEmprestimo> listarEntradaEmprestimo() throws SQLException; public EntradaEmprestimo retornaEntradaEmprestimo(long chave)throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioEntradaEmprestimo.java
Java
oos
675
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.SaidaEmprestimo; public interface IRepositorioSaidaEmprestimo { public void inserirSaidaEmprestimo(SaidaEmprestimo saidaEmprestimo) throws SQLException; public void atualizarSaidaEmprestimo(SaidaEmprestimo saidaEmprestimo) throws SQLException; public void removerSaidaEmprestimo(SaidaEmprestimo saidaEmprestimo) throws SQLException; public ArrayList<SaidaEmprestimo> listarSaidaEmprestimo() throws SQLException; public SaidaEmprestimo retornaSaidaEmprestimo(long chave)throws SQLException; public ArrayList<SaidaEmprestimo> buscarSaidaEmprestimos(String chave, String tipo) throws SQLException; public ArrayList<SaidaEmprestimo> buscarSaidaEmprestimosData() throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioSaidaEmprestimo.java
Java
oos
838
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import br.com.teckstoq.models.ValidarAcesso; public interface IRepositorioAcesso { public void inserirAcesso(ValidarAcesso acesso) throws SQLException; public void atualizarAcesso(ValidarAcesso acesso) throws SQLException; public ValidarAcesso retornaAcesso(long chave) throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioAcesso.java
Java
oos
385
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Estoque; public interface IRepositorioEstoque { public void inserirEstoque(Estoque estoque) throws SQLException; public void atualizarEstoque(Estoque estoque) throws SQLException; public void removerEstoque(Estoque estoque) throws SQLException; public ArrayList<Estoque> listarEstoque() throws SQLException; public Estoque retornaEstoquePorProduto(long chave)throws SQLException; public ArrayList<Estoque> buscarQuantidadeMinima() throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioEstoque.java
Java
oos
616
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Compra; public interface IRepositorioCompra { public void inserirCompra(Compra compra) throws SQLException; public void atualizarCompra(Compra compra) throws SQLException; public void removerCompra(Compra compra) throws SQLException; public ArrayList<Compra> listarCompra() throws SQLException; public Compra retornaCompra(long chave)throws SQLException; public ArrayList<Compra> buscarCompra(String chave, String tipo) throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioCompra.java
Java
oos
601
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Comodatario; public interface IRepositorioComodatario { public void inserirComodatario(Comodatario comodatario) throws SQLException; public void atualizarComodatario(Comodatario comodatario) throws SQLException; public void removerComodatario(Comodatario comodatario) throws SQLException; public ArrayList<Comodatario> listarComodatario() throws SQLException; public Comodatario retornaComodatario(long chave)throws SQLException; public ArrayList<Comodatario> buscarComodatarios(String chave, String tipo) throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioComodatario.java
Java
oos
681
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Setor; public interface IRepositorioSetor { public void inserirSetor(Setor setor) throws SQLException; public void atualizarSetor(Setor setor) throws SQLException; public void removerSetor(Setor setor) throws SQLException; public ArrayList<Setor> listarSetor() throws SQLException; public Setor retornaSetor(long chave)throws SQLException; public ArrayList<Setor> buscarSetor(String chave, String tipo) throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioSetor.java
Java
oos
581
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.SaidaEstoque; public interface IRepositorioSaidaEstoque { public void inserirSaidaEstoque(SaidaEstoque saidaEstoque) throws SQLException; public void atualizarSaidaEstoque(SaidaEstoque saidaEstoque) throws SQLException; public void removerSaidaEstoque(SaidaEstoque saidaEstoque) throws SQLException; public ArrayList<SaidaEstoque> listarSaidaEstoque() throws SQLException; public SaidaEstoque retornaSaidaEstoque(long chave)throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioSaidaEstoque.java
Java
oos
597
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Funcionario; public interface IRepositorioFuncionario { public void inserirFuncionario(Funcionario funcionario) throws SQLException; public void atualizarFuncionario(Funcionario funcionario) throws SQLException; public void removerFuncionario(Funcionario funcionario) throws SQLException; public ArrayList<Funcionario> listarFuncionario() throws SQLException; public Funcionario retornaFuncionario(long chave)throws SQLException; public Funcionario login(String login, String senha) throws SQLException; public Funcionario procurarFuncaco(String login)throws SQLException; public ArrayList<Funcionario> buscarFuncionario(String chave, String tipo) throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioFuncionario.java
Java
oos
831
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Peca; /** * @author Paulo Lima * @category Projeto TeckEstoq Java SE * @since 27/10/2014 * @version 1.0 * */ public interface IRepositorioPeca { public void inserirPeca(Peca peca) throws SQLException; public void atualizarPeca(Peca peca) throws SQLException; public void removerPeca(Peca peca) throws SQLException; public ArrayList<Peca> listarPeca() throws SQLException; public Peca retornaPeca(long chave)throws SQLException; public ArrayList<Peca> buscarPeca(String chave, String tipo) throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioPeca.java
Java
oos
681
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Empresa; public interface IRepositorioEmpresa { public void inserirEmpresa(Empresa empresa) throws SQLException; public void atualizarEmpresa(Empresa empresa) throws SQLException; public void removerEmpresa(Empresa empresa) throws SQLException; public ArrayList<Empresa> listarEmpresa() throws SQLException; public Empresa retornaEmpresa(long chave)throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioEmpresa.java
Java
oos
537
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Equipamento; public interface IRepositorioEquipamento { public void inserirEquipamento(Equipamento equipamento) throws SQLException; public void atualizarEquipamento(Equipamento equipamento) throws SQLException; public void removerEquipamento(Equipamento equipamento) throws SQLException; public ArrayList<Equipamento> listarEquipamento() throws SQLException; public Equipamento retornaEquipamento(long chave)throws SQLException; public ArrayList<Equipamento> buscarEquipamento(String chave, String tipo) throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioEquipamento.java
Java
oos
686
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.LogHistorico; public interface IRepositorioLogHistorico { public void inserirLogHistorico(LogHistorico logHistorico) throws SQLException; public void atualizarLogHistorico(LogHistorico logHistorico) throws SQLException; public void removerLogHistorico(LogHistorico logHistorico) throws SQLException; public ArrayList<LogHistorico> listarLogHistorico() throws SQLException; public LogHistorico retornaLogHistorico(long chave)throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioLogHistorico.java
Java
oos
602
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Permissoes; public interface IRepositorioPermissoes { public void inserirPermissoes(Permissoes permissoes) throws SQLException; public void atualizarPermissoes(Permissoes permissoes) throws SQLException; public void removerPermissoes(Permissoes permissoes) throws SQLException; public ArrayList<Permissoes> listarPermissoes() throws SQLException; public Permissoes retornaPermissoes(long chave) throws SQLException ; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioPermissoes.java
Java
oos
574
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.Fornecedor; public interface IRepositorioFornecedor { public void inserirFornecedor(Fornecedor fornecedor) throws SQLException; public void atualizarFornecedor(Fornecedor fornecedor) throws SQLException; public void removerFornecedor(Fornecedor fornecedor) throws SQLException; public ArrayList<Fornecedor> listarFornecedor() throws SQLException; public Fornecedor retornaFornecedor(long chave)throws SQLException; public ArrayList<Fornecedor> buscarFornecedor(String chave, String tipo) throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioFornecedor.java
Java
oos
679
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.SolicitacaoCompra; public interface IRepositorioSolicitacaoCompra { public void inserirSolicitacaoCompra(SolicitacaoCompra SolicitacaoCompra) throws SQLException; public void atualizarSolicitacaoCompra(SolicitacaoCompra SolicitacaoCompra) throws SQLException; public void removerSolicitacaoCompra(SolicitacaoCompra SolicitacaoCompra) throws SQLException; public ArrayList<SolicitacaoCompra> listarSolicitacaoCompra() throws SQLException; public SolicitacaoCompra retornaSolicitacaoCompra(long chave)throws SQLException; public ArrayList<SolicitacaoCompra> buscarSolicitacaoCompra(String chave, String tipo) throws SQLException; public ArrayList<SolicitacaoCompra> buscarSolicitacoesCompra() throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioSolicitacaoCompra.java
Java
oos
868
package br.com.teckstoq.irepositorio; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.models.EntradaEstoque; public interface IRepositorioEntradaEstoque { public void inserirEntradaEstoque(EntradaEstoque entradaEstoque) throws SQLException; public void atualizarEntradaEstoque(EntradaEstoque entradaEstoque) throws SQLException; public void removerEntradaEstoque(EntradaEstoque entradaEstoque) throws SQLException; public ArrayList<EntradaEstoque> listarEntradaEstoque() throws SQLException; public EntradaEstoque retornaEntradaEstoque(long chave)throws SQLException; }
09012015teckstoq09012015
src/br/com/teckstoq/irepositorio/IRepositorioEntradaEstoque.java
Java
oos
630
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioSaidaEstoque; import br.com.teckstoq.models.SaidaEstoque; import br.com.teckstoq.repositorio.RepositorioSaidaEstoque; public class ControleSaidaEstoque { private IRepositorioSaidaEstoque saidaEstoque; public IRepositorioSaidaEstoque getSaidaEstoque() { return saidaEstoque; } public void setSaidaEstoque(IRepositorioSaidaEstoque saidaEstoque) { this.saidaEstoque = saidaEstoque; } public ControleSaidaEstoque(RepositorioSaidaEstoque repSaidaEstoque) { setSaidaEstoque(repSaidaEstoque); } //-------------------------------------------------------------- public void inserirSaidaEstoque(SaidaEstoque saidaEstoque) throws SQLException{ this.saidaEstoque.inserirSaidaEstoque(saidaEstoque); } //-------------------------------------------------------------- public void atualizarSaidaEstoque(SaidaEstoque saidaEstoque) throws SQLException{ this.saidaEstoque.atualizarSaidaEstoque(saidaEstoque); } //-------------------------------------------------------------- public void removerSaidaEstoque(SaidaEstoque saidaEstoque) throws SQLException{ this.saidaEstoque.removerSaidaEstoque(saidaEstoque); } //-------------------------------------------------------------- public ArrayList<SaidaEstoque> listarSaidaEstoque()throws SQLException{ return this.saidaEstoque.listarSaidaEstoque(); } //-------------------------------------------------------------- public SaidaEstoque retornaSaidaEstoque(long chave)throws SQLException{ return this.saidaEstoque.retornaSaidaEstoque(chave); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleSaidaEstoque.java
Java
oos
1,778
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioEntradaEmprestimo; import br.com.teckstoq.models.EntradaEmprestimo; import br.com.teckstoq.repositorio.RepositorioEntradaEmprestimo; public class ControleEntradaEmprestimo { private IRepositorioEntradaEmprestimo entradaEmprestimo; public IRepositorioEntradaEmprestimo getEntradaEmprestimo() { return entradaEmprestimo; } public void setEntradaEmprestimo(IRepositorioEntradaEmprestimo entradaEmprestimo) { this.entradaEmprestimo = entradaEmprestimo; } public ControleEntradaEmprestimo(RepositorioEntradaEmprestimo repEntradaEmprestimo) { setEntradaEmprestimo(repEntradaEmprestimo); } //-------------------------------------------------------------- public void inserirEntradaEmprestimo(EntradaEmprestimo entradaEmprestimo) throws SQLException{ this.entradaEmprestimo.inserirEntradaEmprestimo(entradaEmprestimo); } //-------------------------------------------------------------- public void atualizarEntradaEmprestimo(EntradaEmprestimo entradaEmprestimo) throws SQLException{ this.entradaEmprestimo.atualizarEntradaEmprestimo(entradaEmprestimo); } //-------------------------------------------------------------- public void removerEntradaEmprestimo(EntradaEmprestimo entradaEmprestimo) throws SQLException{ this.entradaEmprestimo.removerEntradaEmprestimo(entradaEmprestimo); } //-------------------------------------------------------------- public ArrayList<EntradaEmprestimo> listarEntradaEmprestimo()throws SQLException{ return this.entradaEmprestimo.listarEntradaEmprestimo(); } //-------------------------------------------------------------- public EntradaEmprestimo retornaEntradaEmprestimo(long chave)throws SQLException{ return this.entradaEmprestimo.retornaEntradaEmprestimo(chave); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleEntradaEmprestimo.java
Java
oos
2,001
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioEquipamento; import br.com.teckstoq.models.Equipamento; import br.com.teckstoq.repositorio.RepositorioEquipamento; public class ControleEquipamento { private IRepositorioEquipamento equipamento; public IRepositorioEquipamento getEquipamento() { return equipamento; } public void setEquipamento(IRepositorioEquipamento equipamento) { this.equipamento = equipamento; } public ControleEquipamento(RepositorioEquipamento repEquipamento) { setEquipamento(repEquipamento); } //-------------------------------------------------------------- public void inserirEquipamento(Equipamento equipamento) throws SQLException{ this.equipamento.inserirEquipamento(equipamento); } //-------------------------------------------------------------- public void atualizarEquipamento(Equipamento equipamento) throws SQLException{ this.equipamento.atualizarEquipamento(equipamento); } //-------------------------------------------------------------- public void removerEquipamento(Equipamento equipamento) throws SQLException{ this.equipamento.removerEquipamento(equipamento); } //-------------------------------------------------------------- public ArrayList<Equipamento> listarEquipamento()throws SQLException{ return this.equipamento.listarEquipamento(); } //-------------------------------------------------------------- public Equipamento retornaEquipamento(long chave)throws SQLException{ return this.equipamento.retornaEquipamento(chave); } //-------------------------------------------------------------- public ArrayList<Equipamento> buscarEquipamento(String chave, String tipo) throws SQLException { return this.equipamento.buscarEquipamento(chave, tipo); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleEquipamento.java
Java
oos
1,961
package br.com.teckstoq.controllers; import java.sql.SQLException; import br.com.teckstoq.irepositorio.IRepositorioAcesso; import br.com.teckstoq.models.ValidarAcesso; import br.com.teckstoq.repositorio.RepositorioAcesso; public class ControleAcesso { private IRepositorioAcesso acesso; public IRepositorioAcesso getAcesso() { return acesso; } public void setAcesso(IRepositorioAcesso acesso) { this.acesso = acesso; } public ControleAcesso(RepositorioAcesso repAcesso) { setAcesso(repAcesso); } // ---------------------------------------------------------- public void inserirAcesso(ValidarAcesso acesso) throws SQLException { this.acesso.inserirAcesso(acesso); } // ---------------------------------------------------------- public void atualizarAcesso(ValidarAcesso acesso) throws SQLException { this.acesso.atualizarAcesso(acesso); } // ---------------------------------------------------------- public ValidarAcesso retornaAcesso(long chave) throws SQLException { return this.acesso.retornaAcesso(chave); } }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleAcesso.java
Java
oos
1,095
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioSaidaEmprestimo; import br.com.teckstoq.models.SaidaEmprestimo; import br.com.teckstoq.repositorio.RepositorioSaidaEmprestimo; public class ControleSaidaEmprestimo { private IRepositorioSaidaEmprestimo saidaEmprestimo; public IRepositorioSaidaEmprestimo getSaidaEmprestimo() { return saidaEmprestimo; } public void setSaidaEmprestimo(IRepositorioSaidaEmprestimo saidaEmprestimo) { this.saidaEmprestimo = saidaEmprestimo; } public ControleSaidaEmprestimo(RepositorioSaidaEmprestimo repSaidaEmprestimo) { setSaidaEmprestimo(repSaidaEmprestimo); } //-------------------------------------------------------------- public void inserirSaidaEmprestimo(SaidaEmprestimo saidaEmprestimo) throws SQLException{ this.saidaEmprestimo.inserirSaidaEmprestimo(saidaEmprestimo); } //-------------------------------------------------------------- public void atualizarSaidaEmprestimo(SaidaEmprestimo saidaEmprestimo) throws SQLException{ this.saidaEmprestimo.atualizarSaidaEmprestimo(saidaEmprestimo); } //-------------------------------------------------------------- public void removerSaidaEmprestimo(SaidaEmprestimo saidaEmprestimo) throws SQLException{ this.saidaEmprestimo.removerSaidaEmprestimo(saidaEmprestimo); } //-------------------------------------------------------------- public ArrayList<SaidaEmprestimo> listarSaidaEmprestimo()throws SQLException{ return this.saidaEmprestimo.listarSaidaEmprestimo(); } //-------------------------------------------------------------- public SaidaEmprestimo retornaSaidaEmprestimo(long chave)throws SQLException{ return this.saidaEmprestimo.retornaSaidaEmprestimo(chave); } //-------------------------------------------------------------- public ArrayList<SaidaEmprestimo> buscarSaidaEmprestimos(String chave, String tipo) throws SQLException { return this.saidaEmprestimo.buscarSaidaEmprestimos(chave, tipo); } //-------------------------------------------------------------- public ArrayList<SaidaEmprestimo> buscarSaidaEmprestimosData() throws SQLException { return this.saidaEmprestimo.buscarSaidaEmprestimosData(); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleSaidaEmprestimo.java
Java
oos
2,379
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioEntradaEstoque; import br.com.teckstoq.models.EntradaEstoque; import br.com.teckstoq.repositorio.RepositorioEntradaEstoque; public class ControleEntradaEstoque { private IRepositorioEntradaEstoque entradaEstoque; public IRepositorioEntradaEstoque getEntradaEstoque() { return entradaEstoque; } public void setEntradaEstoque(IRepositorioEntradaEstoque entradaEstoque) { this.entradaEstoque = entradaEstoque; } public ControleEntradaEstoque(RepositorioEntradaEstoque repEntradaEstoque) { setEntradaEstoque(repEntradaEstoque); } //-------------------------------------------------------------- public void inserirEntradaEstoque(EntradaEstoque entradaEstoque) throws SQLException{ this.entradaEstoque.inserirEntradaEstoque(entradaEstoque); } //-------------------------------------------------------------- public void atualizarEntradaEstoque(EntradaEstoque entradaEstoque) throws SQLException{ this.entradaEstoque.atualizarEntradaEstoque(entradaEstoque); } //-------------------------------------------------------------- public void removerEntradaEstoque(EntradaEstoque entradaEstoque) throws SQLException{ this.entradaEstoque.removerEntradaEstoque(entradaEstoque); } //-------------------------------------------------------------- public ArrayList<EntradaEstoque> listarEntradaEstoque()throws SQLException{ return this.entradaEstoque.listarEntradaEstoque(); } //-------------------------------------------------------------- public EntradaEstoque retornaEntradaEstoque(long chave)throws SQLException{ return this.entradaEstoque.retornaEntradaEstoque(chave); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleEntradaEstoque.java
Java
oos
1,871
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioEstoque; import br.com.teckstoq.models.Estoque; import br.com.teckstoq.repositorio.RepositorioEstoque; public class ControleEstoque { private IRepositorioEstoque estoque; public IRepositorioEstoque getEstoque() { return estoque; } public void setEstoque(IRepositorioEstoque estoque) { this.estoque = estoque; } public ControleEstoque(RepositorioEstoque repEstoque) { setEstoque(repEstoque); } //-------------------------------------------------------------- public void inserirEstoque(Estoque estoque) throws SQLException{ this.estoque.inserirEstoque(estoque); } //-------------------------------------------------------------- public void atualizarEstoque(Estoque estoque) throws SQLException{ this.estoque.atualizarEstoque(estoque); } //-------------------------------------------------------------- public void removerEstoque(Estoque estoque) throws SQLException{ this.estoque.removerEstoque(estoque); } //-------------------------------------------------------------- public ArrayList<Estoque> listarEstoque()throws SQLException{ return this.estoque.listarEstoque(); } //-------------------------------------------------------------- public Estoque retornaEstoquePorProduto(long chave)throws SQLException{ return this.estoque.retornaEstoquePorProduto(chave); } //-------------------------------------------------------------- public ArrayList<Estoque> buscarQuantidadeMinima() throws SQLException { return this.estoque.buscarQuantidadeMinima(); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleEstoque.java
Java
oos
1,764
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioFornecedor; import br.com.teckstoq.models.Fornecedor; import br.com.teckstoq.repositorio.RepositorioFornecedor; public class ControleFornecedor { private IRepositorioFornecedor fornecedor; public IRepositorioFornecedor getFornecedor() { return fornecedor; } public void setFornecedor(IRepositorioFornecedor fornecedor) { this.fornecedor = fornecedor; } public ControleFornecedor(RepositorioFornecedor repFornecedor) { setFornecedor(repFornecedor); } //-------------------------------------------------------------- public void inserirFornecedor(Fornecedor fornecedor) throws SQLException{ this.fornecedor.inserirFornecedor(fornecedor); } //-------------------------------------------------------------- public void atualizarFornecedor(Fornecedor fornecedor) throws SQLException{ this.fornecedor.atualizarFornecedor(fornecedor); } //-------------------------------------------------------------- public void removerFornecedor(Fornecedor fornecedor) throws SQLException{ this.fornecedor.removerFornecedor(fornecedor); } //-------------------------------------------------------------- public ArrayList<Fornecedor> listarFornecedor()throws SQLException{ return this.fornecedor.listarFornecedor(); } //-------------------------------------------------------------- public Fornecedor retornaFornecedor(long chave)throws SQLException{ return this.fornecedor.retornaFornecedor(chave); } //-------------------------------------------------------------- public ArrayList<Fornecedor> buscarFornecedor(String chave, String tipo) throws SQLException { return this.fornecedor.buscarFornecedor(chave, tipo); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleFornecedor.java
Java
oos
1,921
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioCompra; import br.com.teckstoq.models.Compra; import br.com.teckstoq.models.Fornecedor; import br.com.teckstoq.repositorio.RepositorioCompra; @SuppressWarnings("unused") public class ControleCompra { private IRepositorioCompra compra; public IRepositorioCompra getCompra() { return compra; } public void setCompra(IRepositorioCompra compra) { this.compra = compra; } public ControleCompra(RepositorioCompra repCompra) { setCompra(repCompra); } //-------------------------------------------------------------- public void inserirCompra(Compra compra) throws SQLException{ this.compra.inserirCompra(compra); } //-------------------------------------------------------------- public void atualizarCompra(Compra compra) throws SQLException{ this.compra.atualizarCompra(compra); } //-------------------------------------------------------------- public void removerCompra(Compra compra) throws SQLException{ this.compra.removerCompra(compra); } //-------------------------------------------------------------- public ArrayList<Compra> listarCompra()throws SQLException{ return this.compra.listarCompra(); } //-------------------------------------------------------------- public Compra retornaCompra(long chave)throws SQLException{ return this.compra.retornaCompra(chave); } //-------------------------------------------------------------- public ArrayList<Compra> buscarCompra(String chave, String tipo) throws SQLException { return this.compra.buscarCompra(chave, tipo); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleCompra.java
Java
oos
1,788
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioSetor; import br.com.teckstoq.models.Setor; import br.com.teckstoq.repositorio.RepositorioSetor; public class ControleSetor { private IRepositorioSetor setor; public IRepositorioSetor getSetor() { return setor; } public void setSetor(IRepositorioSetor setor) { this.setor = setor; } public ControleSetor(RepositorioSetor repSetor) { setSetor(repSetor); } //-------------------------------------------------------------- public void inserirSetor(Setor setor) throws SQLException{ this.setor.inserirSetor(setor); } //-------------------------------------------------------------- public void atualizarSetor(Setor setor) throws SQLException{ this.setor.atualizarSetor(setor); } //-------------------------------------------------------------- public void removerSetor(Setor setor) throws SQLException{ this.setor.removerSetor(setor); } //-------------------------------------------------------------- public ArrayList<Setor> listarSetor()throws SQLException{ return this.setor.listarSetor(); } //-------------------------------------------------------------- public Setor retornaSetor(long chave)throws SQLException{ return this.setor.retornaSetor(chave); } //-------------------------------------------------------------- public ArrayList<Setor> buscarSetor(String chave, String tipo) throws SQLException { return this.setor.buscarSetor(chave, tipo); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleSetor.java
Java
oos
1,670
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioPermissoes; import br.com.teckstoq.models.Permissoes; import br.com.teckstoq.repositorio.RepositorioPermissoes; public class ControlePermissoes { private IRepositorioPermissoes permissoes; public IRepositorioPermissoes getPermissoes() { return permissoes; } public void setPermissoes(IRepositorioPermissoes permissoes) { this.permissoes = permissoes; } public ControlePermissoes(RepositorioPermissoes repPermissoes) { setPermissoes(repPermissoes); } public void inserirPermissoes(Permissoes permissoes) throws SQLException { this.permissoes.inserirPermissoes(permissoes); } // ---------------------------------------------------------- public void atualizarPermissoes(Permissoes permissoes) throws SQLException { this.permissoes.atualizarPermissoes(permissoes); } // ---------------------------------------------------------- public void removerPermissoes(Permissoes permissoes) throws SQLException { this.permissoes.removerPermissoes(permissoes); } // ---------------------------------------------------------- public ArrayList<Permissoes> listarPermissoes() throws SQLException { return (ArrayList<Permissoes>) this.permissoes.listarPermissoes(); } // ---------------------------------------------------------- public Permissoes retornaPermissoes(long chave) throws SQLException { return this.permissoes.retornaPermissoes(chave); } }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControlePermissoes.java
Java
oos
1,583
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioPeca; import br.com.teckstoq.models.Peca; import br.com.teckstoq.repositorio.RepositorioPeca; /** * @author Paulo Lima * @category Projeto TeckEstoq Java SE * @since 27/10/2014 * @version 1.0 * */ public class ControlePeca { private IRepositorioPeca peca; public IRepositorioPeca getPeca() { return peca; } public void setPeca(IRepositorioPeca peca) { this.peca = peca; } public ControlePeca(RepositorioPeca repPeca) { setPeca(repPeca); } //-------------------------------------------------------------- public void inserirPeca(Peca peca) throws SQLException{ this.peca.inserirPeca(peca); } //-------------------------------------------------------------- public void atualizarPeca(Peca peca) throws SQLException{ this.peca.atualizarPeca(peca); } //-------------------------------------------------------------- public void removerPeca(Peca peca) throws SQLException{ this.peca.removerPeca(peca); } //-------------------------------------------------------------- public ArrayList<Peca> listarPeca()throws SQLException{ return this.peca.listarPeca(); } //-------------------------------------------------------------- public Peca retornaPeca(long chave)throws SQLException{ return this.peca.retornaPeca(chave); } //-------------------------------------------------------------- public ArrayList<Peca> buscarPeca(String chave, String tipo) throws SQLException { return this.peca.buscarPeca(chave, tipo); //-------------------------------------------------------------- } }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControlePeca.java
Java
oos
1,749
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioSolicitacaoCompra; import br.com.teckstoq.models.SolicitacaoCompra; import br.com.teckstoq.repositorio.RepositorioSolicitacaoCompra; public class ControleSolicitacaoCompra { private IRepositorioSolicitacaoCompra solicitacaoCompra; public IRepositorioSolicitacaoCompra getSolicitacaoCompra() { return solicitacaoCompra; } public void setSolicitacaoCompra(IRepositorioSolicitacaoCompra solicitacaoCompra) { this.solicitacaoCompra = solicitacaoCompra; } public ControleSolicitacaoCompra(RepositorioSolicitacaoCompra repSolicitacaoCompra) { setSolicitacaoCompra(repSolicitacaoCompra); } //-------------------------------------------------------------- public void inserirSolicitacaoCompra(SolicitacaoCompra solicitacaoCompra) throws SQLException{ this.solicitacaoCompra.inserirSolicitacaoCompra(solicitacaoCompra); } //-------------------------------------------------------------- public void atualizarSolicitacaoCompra(SolicitacaoCompra solicitacaoCompra) throws SQLException{ this.solicitacaoCompra.atualizarSolicitacaoCompra(solicitacaoCompra); } //-------------------------------------------------------------- public void removerSolicitacaoCompra(SolicitacaoCompra solicitacaoCompra) throws SQLException{ this.solicitacaoCompra.removerSolicitacaoCompra(solicitacaoCompra); } //-------------------------------------------------------------- public ArrayList<SolicitacaoCompra> listarSolicitacaoCompra()throws SQLException{ return this.solicitacaoCompra.listarSolicitacaoCompra(); } //-------------------------------------------------------------- public SolicitacaoCompra retornaSolicitacaoCompra(long chave)throws SQLException{ return this.solicitacaoCompra.retornaSolicitacaoCompra(chave); } //-------------------------------------------------------------- public ArrayList<SolicitacaoCompra> buscarSolicitacaoCompra(String chave, String tipo) throws SQLException { return this.solicitacaoCompra.buscarSolicitacaoCompra(chave, tipo); } //-------------------------------------------------------------- public ArrayList<SolicitacaoCompra> buscarSolicitacoesCompra() throws SQLException { return this.solicitacaoCompra.buscarSolicitacoesCompra(); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleSolicitacaoCompra.java
Java
oos
2,475
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioComodatario; import br.com.teckstoq.models.Comodatario; import br.com.teckstoq.repositorio.RepositorioComodatario; public class ControleComodatario { private IRepositorioComodatario comodatario; public IRepositorioComodatario getComodatario() { return comodatario; } public void setComodatario(IRepositorioComodatario comodatario) { this.comodatario = comodatario; } public ControleComodatario(RepositorioComodatario repComodatario) { setComodatario(repComodatario); } //-------------------------------------------------------------- public void inserirComodatario(Comodatario comodatario) throws SQLException{ this.comodatario.inserirComodatario(comodatario); } //-------------------------------------------------------------- public void atualizarComodatario(Comodatario comodatario) throws SQLException{ this.comodatario.atualizarComodatario(comodatario); } //-------------------------------------------------------------- public void removerComodatario(Comodatario comodatario) throws SQLException{ this.comodatario.removerComodatario(comodatario); } //-------------------------------------------------------------- public ArrayList<Comodatario> listarComodatario()throws SQLException{ return this.comodatario.listarComodatario(); } //-------------------------------------------------------------- public Comodatario retornaComodatario(long chave)throws SQLException{ return this.comodatario.retornaComodatario(chave); } public ArrayList<Comodatario> buscarComodatarios(String chave, String tipo) throws SQLException { return this.comodatario.buscarComodatarios(chave, tipo); } //-------------------------------------------------------------- public ArrayList<Comodatario> buscarComodatario(String chave, String tipo) throws SQLException { return this.comodatario.buscarComodatarios(chave, tipo); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleComodatario.java
Java
oos
2,133
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioEmpresa; import br.com.teckstoq.models.Empresa; import br.com.teckstoq.repositorio.RepositorioEmpresa; public class ControleEmpresa { private IRepositorioEmpresa empresa; public IRepositorioEmpresa getEmpresa() { return empresa; } public void setEmpresa(IRepositorioEmpresa empresa) { this.empresa = empresa; } public ControleEmpresa(RepositorioEmpresa repEmpresa) { setEmpresa(repEmpresa); } //-------------------------------------------------------------- public void inserirEmpresa(Empresa empresa) throws SQLException{ this.empresa.inserirEmpresa(empresa); } //-------------------------------------------------------------- public void atualizarEmpresa(Empresa empresa) throws SQLException{ this.empresa.atualizarEmpresa(empresa); } //-------------------------------------------------------------- public void removerEmpresa(Empresa empresa) throws SQLException{ this.empresa.removerEmpresa(empresa); } //-------------------------------------------------------------- public ArrayList<Empresa> listarEmpresa()throws SQLException{ return this.empresa.listarEmpresa(); } //-------------------------------------------------------------- public Empresa retornaEmpresa(long chave)throws SQLException{ return this.empresa.retornaEmpresa(chave); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleEmpresa.java
Java
oos
1,551
package br.com.teckstoq.controllers; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.irepositorio.IRepositorioLogHistorico; import br.com.teckstoq.models.LogHistorico; import br.com.teckstoq.repositorio.RepositorioLogHistorico; public class ControleLogHistorico { private IRepositorioLogHistorico logHistorico; public IRepositorioLogHistorico getLogHistorico() { return logHistorico; } public void setLogHistorico(IRepositorioLogHistorico logHistorico) { this.logHistorico = logHistorico; } public ControleLogHistorico(RepositorioLogHistorico repLogHistorico) { setLogHistorico(repLogHistorico); } //-------------------------------------------------------------- public void inserirLogHistorico(LogHistorico logHistorico) throws SQLException{ this.logHistorico.inserirLogHistorico(logHistorico); } //-------------------------------------------------------------- public void atualizarLogHistorico(LogHistorico logHistorico) throws SQLException{ this.logHistorico.atualizarLogHistorico(logHistorico); } //-------------------------------------------------------------- public void removerLogHistorico(LogHistorico logHistorico) throws SQLException{ this.logHistorico.removerLogHistorico(logHistorico); } //-------------------------------------------------------------- public ArrayList<LogHistorico> listarLogHistorico()throws SQLException{ return this.logHistorico.listarLogHistorico(); } //-------------------------------------------------------------- public LogHistorico retornaLogHistorico(long chave)throws SQLException{ return this.logHistorico.retornaLogHistorico(chave); } //-------------------------------------------------------------- }
09012015teckstoq09012015
src/br/com/teckstoq/controllers/ControleLogHistorico.java
Java
oos
1,773
package br.com.teckstoq.utilitarios; import java.util.InputMismatchException; public class ValidaCPF { public static boolean isCPF(String CPF) { // considera-se erro CPF's formados por uma sequencia de numeros iguais if (CPF.equals("00000000000") || CPF.equals("11111111111") || CPF.equals("22222222222") || CPF.equals("33333333333") || CPF.equals("44444444444") || CPF.equals("55555555555") || CPF.equals("66666666666") || CPF.equals("77777777777") || CPF.equals("88888888888") || CPF.equals("99999999999") || (CPF.length() != 11)) return (false); char dig10, dig11; int sm, i, r, num, peso; // "try" - protege o codigo para eventuais erros de conversao de tipo // (int) try { // Calculo do 1o. Digito Verificador sm = 0; peso = 10; for (i = 0; i < 9; i++) { // converte o i-esimo caractere do CPF em um numero: // por exemplo, transforma o caractere '0' no inteiro 0 // (48 eh a posicao de '0' na tabela ASCII) num = (int) (CPF.charAt(i) - 48); sm = sm + (num * peso); peso = peso - 1; } r = 11 - (sm % 11); if ((r == 10) || (r == 11)) dig10 = '0'; else dig10 = (char) (r + 48); // converte no respectivo caractere // numerico // Calculo do 2o. Digito Verificador sm = 0; peso = 11; for (i = 0; i < 10; i++) { num = (int) (CPF.charAt(i) - 48); sm = sm + (num * peso); peso = peso - 1; } r = 11 - (sm % 11); if ((r == 10) || (r == 11)) dig11 = '0'; else dig11 = (char) (r + 48); // Verifica se os digitos calculados conferem com os digitos // informados. if ((dig10 == CPF.charAt(9)) && (dig11 == CPF.charAt(10))) return (true); else return (false); } catch (InputMismatchException erro) { return (false); } } public static String imprimeCPF(String CPF) { return (CPF.substring(0, 3) + "." + CPF.substring(3, 6) + "." + CPF.substring(6, 9) + "-" + CPF.substring(9, 11)); } /*public static void main(String[] args) { Scanner ler = new Scanner(System.in); String CPF; System.out.printf("Informe um CPF: "); CPF = ler.next(); System.out.printf("\nResultado: "); // usando os metodos isCPF() e imprimeCPF() da classe "ValidaCPF" if (ValidaCPF.isCPF(CPF) == true) System.out.printf("%s\n", ValidaCPF.imprimeCPF(CPF)); else System.out.printf("Erro, CPF invalido !!!\n"); }*/ }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/ValidaCPF.java
Java
oos
2,483
package br.com.teckstoq.utilitarios; import java.sql.SQLException; import java.util.ArrayList; import br.com.teckstoq.facade.Fachada; import br.com.teckstoq.models.Estoque; import br.com.teckstoq.models.Peca; public class TesteBuscarQtdMinimo { public static void main(String[] args) { //---------------------------------------------------------------------------- try { Fachada fachada = Fachada.getInstance(); ArrayList<Estoque> estoque = new ArrayList<Estoque>(); Peca peca = new Peca(); estoque = fachada.buscarQuantidadeMinima(); for (Estoque estoqueLista : estoque) { peca = fachada.retornaPeca(estoqueLista.getIdEstoque()); System.out.println(peca.getIdPeca()); System.out.println(peca.getNumeroFiscal()); System.out.println(peca.getEstoque().getQuantidadeMinima()); System.out.println("-----------------------------------------"); } } catch (SQLException e) { e.printStackTrace(); } //---------------------------------------------------------------------------- } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/TesteBuscarQtdMinimo.java
Java
oos
1,109
package br.com.teckstoq.utilitarios; public class removendoMask { public String removeMask(String cpf) { String str = cpf; while (str.indexOf("-") != -1) { if (str.indexOf("-") != 0) { str = str.substring(0, str.indexOf("-")) + str.substring(str.indexOf("-") + 1); } else { str = str.substring(str.indexOf("-") + 1); } } while (str.indexOf(".") != -1) { if (str.indexOf(".") != 0) { str = str.substring(0, str.indexOf(".")) + str.substring(str.indexOf(".") + 1); } else { str = str.substring(str.indexOf(".") + 1); } } return str; } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/removendoMask.java
Java
oos
774
package br.com.teckstoq.utilitarios; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import br.com.teckstoq.facade.Fachada; import br.com.teckstoq.models.SaidaEmprestimo; public class TesteBuscarSaidaEmprestimoData { public static void main(String[] args) { //--------------------------------------------------------- try { String dataSistema = new SimpleDateFormat("dd/MM/yyyy").format(new Date()); Fachada fachada = Fachada.getInstance(); ArrayList<SaidaEmprestimo> emprestimos = new ArrayList<SaidaEmprestimo>(); ArrayList<SaidaEmprestimo> emprestimosEmAtraso = new ArrayList<SaidaEmprestimo>(); emprestimos = fachada.buscarSaidaEmprestimosData(); String data; int dia; int mes; int ano; int diaAtual = Integer.parseInt(dataSistema.substring(0, 2)); int mesAtual = Integer.parseInt(dataSistema.substring(3, 5)); int anoAtual = Integer.parseInt(dataSistema.substring(6, 10)); for (SaidaEmprestimo saidaEmprestimo : emprestimos) { data = saidaEmprestimo.getDataCadastro(); dia = Integer.parseInt(saidaEmprestimo.getDataPrevistaDevolucao().substring(0, 2)); System.out.println(dia); mes = Integer.parseInt(saidaEmprestimo.getDataPrevistaDevolucao().substring(3, 5)); System.out.println(mes); ano = Integer.parseInt(saidaEmprestimo.getDataPrevistaDevolucao().substring(6, 10)); System.out.println(ano); int dataBD = ano+mes+dia; int dataAtual = anoAtual+mesAtual+diaAtual; if (dataBD <= dataAtual){ emprestimosEmAtraso.add(saidaEmprestimo); } } for (SaidaEmprestimo saidaEmprestimo : emprestimosEmAtraso) { System.out.println(saidaEmprestimo.getStatus()); } } catch (Exception e) { e.printStackTrace(); } //------------------------------------------------------------ } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/TesteBuscarSaidaEmprestimoData.java
Java
oos
1,967
package br.com.teckstoq.utilitarios; import br.com.teckstoq.facade.Fachada; import br.com.teckstoq.models.Empresa; public class bb { public static void main (String[]a){ try { Fachada fachada = Fachada.getInstance(); Empresa empresa = fachada.retornaEmpresa(1); System.out.println(empresa.getNomeEmpresa()); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/bb.java
Java
oos
456
package br.com.teckstoq.utilitarios; /* FixedLengthDocument.java */ import javax.swing.*; import javax.swing.text.*; public class limiteDeCaracter extends PlainDocument { private int iMaxLength; public limiteDeCaracter(int maxlen) { super(); iMaxLength = maxlen; } public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException { if (str == null) { return; } if (iMaxLength <= 0) // aceitara qualquer no. de caracteres { super.insertString(offset, str, attr); return; } int ilen = (getLength() + str.length()); if (ilen <= iMaxLength) {// se o comprimento final for menor... super.insertString(offset, str, attr); // ...aceita str } } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/limiteDeCaracter.java
Java
oos
761
package br.com.teckstoq.utilitarios; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; public class testeCampos extends PlainDocument { public static final int NUMERO_DIGITOS_MAXIMO = 5; public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { String texto = getText(0, getLength()); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (!Character.isDigit(c)) { return; } } if (texto.length() < this.NUMERO_DIGITOS_MAXIMO) { super.remove(0, getLength()); texto = texto.replace("", ""); StringBuffer s = new StringBuffer(texto + str); if (s.length() > 0 && s.charAt(0) == '0') { s.deleteCharAt(0); } if (s.length() < 3) { if (s.length() < 1){ s.insert(0, "00000"); } else if (s.length() < 2){ s.insert(0, "0000"); } else if(s.length()<4){ s.insert(0, "00"); } else if(s.length()<5){ s.insert(0, "0"); } else{ s.insert(0,"0"); } } // s.insert(s.length() - 3, ""); // // if (s.length() > 6) { // s.insert(s.length() - 5, ""); // } // // if (s.length() > 10) { // s.insert(s.length() - 10, ""); // } super.insertString(0, s.toString(), a); } } public void remove(int offset, int length) throws BadLocationException { super.remove(offset, length); String texto = getText(0, getLength()); texto = texto.replace("", ""); texto = texto.replace("", ""); super.remove(0, getLength()); insertString(0, texto, null); } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/testeCampos.java
Java
oos
1,678
package br.com.teckstoq.utilitarios; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import br.com.teckstoq.facade.Fachada; import br.com.teckstoq.models.Equipamento; import br.com.teckstoq.models.Funcionario; public class TesteEquipamento { public static void main(String[] args) { //------------------------------------------------------- try { Fachada fachada = Fachada.getInstance(); Equipamento equipamento = new Equipamento(); List<Funcionario> operadores = new ArrayList<Funcionario>(); equipamento = fachada.retornaEquipamento(1); operadores = equipamento.getOperadores(); for (Funcionario funcionario : operadores) { System.out.println(funcionario.getNome()); } } catch (SQLException e) { e.printStackTrace(); } //-------------------------------------------------------- } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/TesteEquipamento.java
Java
oos
947
package br.com.teckstoq.utilitarios; import br.com.teckstoq.facade.Fachada; import br.com.teckstoq.models.Contato; import br.com.teckstoq.models.Endereco; import br.com.teckstoq.models.Fornecedor; public class testeSalvarFornecedor { public static void main (String []a){ Fachada fachada = Fachada.getInstance(); Fornecedor fornecedor = new Fornecedor(); Endereco endereco = new Endereco(); Contato contato = new Contato(); for (int i = 0; i < 110; i++) { try { fornecedor.setNome("teste "+i); fornecedor.setContato(contato); fornecedor.setEndereco(endereco); fachada.inserirFornecedor(fornecedor); System.out.println("fornecedor "+i+" inserido com sucesso!!"); } catch (Exception e) { e.printStackTrace(); } } } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/testeSalvarFornecedor.java
Java
oos
821
package br.com.teckstoq.utilitarios; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; @SuppressWarnings("serial") public class camposDecimais extends PlainDocument { public static final int NUMERO_DIGITOS_MAXIMO = 12; @SuppressWarnings("static-access") public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { String texto = getText(0, getLength()); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (!Character.isDigit(c)) { return; } } if (texto.length() < this.NUMERO_DIGITOS_MAXIMO) { super.remove(0, getLength()); texto = texto.replace(".", "").replace(",", ""); StringBuffer s = new StringBuffer(texto + str); if (s.length() > 0 && s.charAt(0) == '0') { s.deleteCharAt(0); } if (s.length() < 3) { if (s.length() < 1) { s.insert(0, "000"); } else if (s.length() < 2) { s.insert(0, "00"); } else { s.insert(0, "0"); } } s.insert(s.length() - 2, ","); if (s.length() > 6) { s.insert(s.length() - 6, "."); } if (s.length() > 10) { s.insert(s.length() - 10, "."); } super.insertString(0, s.toString(), a); } } public void remove(int offset, int length) throws BadLocationException { super.remove(offset, length); String texto = getText(0, getLength()); texto = texto.replace(",", ""); texto = texto.replace(".", ""); super.remove(0, getLength()); insertString(0, texto, null); } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/camposDecimais.java
Java
oos
1,618
package br.com.teckstoq.utilitarios; import br.com.teckstoq.facade.Fachada; import br.com.teckstoq.models.Setor; public class buscarSetorID { public static void main (String []a){ try { Fachada fachada = Fachada.getInstance(); Setor setor = fachada.retornaSetor(1); System.out.println("nome setor: "+setor.getDescricao()); } catch (Exception e) { e.printStackTrace(); } } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/buscarSetorID.java
Java
oos
445
package br.com.teckstoq.utilitarios; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.util.Locale; public class decimal { @SuppressWarnings("unused") private static final String COMMA_SEPERATED = "###,###.###"; @SuppressWarnings("unused") private static double number = 12345.6; public static void main(String[] args) { try { NumberFormat nf = new DecimalFormat ("#,##0.00", new DecimalFormatSymbols (new Locale ("pt", "BR"))); double valor = 100000000; System.out.println (nf.format (valor / 100)); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/decimal.java
Java
oos
716
package br.com.teckstoq.utilitarios; public class acrescentarZero { public String strZero(int value, int n) { String s = Integer.toString(value).trim(); StringBuffer resp = new StringBuffer(); int fim = n - s.length(); for (int x = 0; x < fim; x++) resp.append('0'); return resp + s; } // public static void main(String [] a) { // // a aa = new a(); // // System.out.println(aa.strZero(1, 5)); // } // }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/acrescentarZero.java
Java
oos
450
package br.com.teckstoq.utilitarios; import java.io.IOException; import java.net.SocketTimeoutException; import org.jsoup.HttpStatusException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public class buscaCep { public String getEndereco(String CEP) throws IOException { // *************************************************** try { Document doc = Jsoup .connect("http://www.qualocep.com/busca-cep/" + CEP) .timeout(120000).get(); Elements urlPesquisa = doc.select("span[itemprop=streetAddress]"); for (Element urlEndereco : urlPesquisa) { return urlEndereco.text(); } } catch (SocketTimeoutException e) { } catch (HttpStatusException w) { } return CEP; } public String getBairro(String CEP) throws IOException { // *************************************************** try { Document doc = Jsoup .connect("http://www.qualocep.com/busca-cep/" + CEP) .timeout(120000).get(); Elements urlPesquisa = doc.select("td:gt(1)"); for (Element urlBairro : urlPesquisa) { return urlBairro.text(); } } catch (SocketTimeoutException e) { } catch (HttpStatusException w) { } return CEP; } public String getCidade(String CEP) throws IOException { // *************************************************** try { Document doc = Jsoup .connect("http://www.qualocep.com/busca-cep/" + CEP) .timeout(120000).get(); Elements urlPesquisa = doc.select("span[itemprop=addressLocality]"); for (Element urlCidade : urlPesquisa) { return urlCidade.text(); } } catch (SocketTimeoutException e) { } catch (HttpStatusException w) { } return CEP; } public String getUF(String CEP) throws IOException { // *************************************************** try { Document doc = Jsoup .connect("http://www.qualocep.com/busca-cep/" + CEP) .timeout(120000).get(); Elements urlPesquisa = doc.select("span[itemprop=addressRegion]"); for (Element urlUF : urlPesquisa) { return urlUF.text(); } } catch (SocketTimeoutException e) { } catch (HttpStatusException w) { } return CEP; } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/buscaCep.java
Java
oos
2,298
package br.com.teckstoq.utilitarios; import java.sql.SQLException; import java.util.List; import br.com.teckstoq.facade.Fachada; import br.com.teckstoq.models.Peca; public class listaProdutos { public static void main(String[] a) { try { Fachada fachada = Fachada.getInstance(); List<Peca> produtos = fachada.listarPeca(); int i = 0; for (Peca produto : produtos) { System.out.println(produto.getCodigoFabrica() + "\n" + produto.getDescricao() + "\n" + produto.getPrecoCompra() + "\n" + produto.getEstoque().getQuatidade()); i++; } } catch (SQLException e) { e.printStackTrace(); } } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/listaProdutos.java
Java
oos
676
package br.com.teckstoq.utilitarios; import java.sql.SQLException; import java.util.ArrayList; import antlr.collections.List; import br.com.teckstoq.facade.Fachada; import br.com.teckstoq.models.Compra; import br.com.teckstoq.models.Estoque; import br.com.teckstoq.models.Peca; import br.com.teckstoq.models.SolicitacaoCompra; public class TesteBuscarSolicitacaoCompra { public static void main(String[] args) { //--------------------------------------------------------------------------- try { Fachada fachada = Fachada.getInstance(); ArrayList<SolicitacaoCompra> solicitacaoCompras = new ArrayList<SolicitacaoCompra>(); solicitacaoCompras = fachada.buscarSolicitacoesCompra(); for (SolicitacaoCompra solicitacoes : solicitacaoCompras) { System.out.println(solicitacoes.getIdSolicitacaoCompra()); System.out.println(solicitacoes.getStatus()); System.out.println("-----------------------------------------"); } } catch (SQLException e) { e.printStackTrace(); } //--------------------------------------------------------------------------- } }
09012015teckstoq09012015
src/br/com/teckstoq/utilitarios/TesteBuscarSolicitacaoCompra.java
Java
oos
1,177
package net.appositedesigns.fileexplorer.workers; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.model.FileListing; import net.appositedesigns.fileexplorer.util.FileListSorter; import net.appositedesigns.fileexplorer.util.Util; import android.app.ProgressDialog; import android.os.AsyncTask; import android.util.Log; public class Finder extends AsyncTask<File, Integer, FileListing> { private static final String TAG = Finder.class.getName(); private FileListActivity caller; private ProgressDialog waitDialog; private File currentDir; public Finder(FileListActivity caller) { this.caller = caller; } @Override protected void onPostExecute(FileListing result) { FileListing childFilesList = result; Log.v(TAG, "Children for "+currentDir.getAbsolutePath()+" received"); if(waitDialog!=null && waitDialog.isShowing()) { waitDialog.dismiss(); } Log.v(TAG, "Children for "+currentDir.getAbsolutePath()+" passed to caller"); caller.setCurrentDirAndChilren(currentDir,childFilesList); } @Override protected FileListing doInBackground(File... params) { Thread waitForASec = new Thread() { @Override public void run() { waitDialog = new ProgressDialog(caller); waitDialog.setTitle(""); waitDialog.setMessage(caller.getString(R.string.querying_filesys)); waitDialog.setIndeterminate(true); try { Thread.sleep(100); if(this.isInterrupted()) { return; } else { caller.runOnUiThread(new Runnable() { @Override public void run() { if(waitDialog!=null) waitDialog.show(); } }); } } catch (InterruptedException e) { Log.e(TAG, "Progressbar waiting thread encountered exception ",e); e.printStackTrace(); } } }; caller.runOnUiThread(waitForASec); currentDir = params[0]; Log.v(TAG, "Received directory to list paths - "+currentDir.getAbsolutePath()); String[] children = currentDir.list(); FileListing listing = new FileListing(new ArrayList<FileListEntry>()); List<FileListEntry> childFiles = listing.getChildren(); boolean showHidden = caller.getPreferenceHelper().isShowHidden(); boolean showSystem = caller.getPreferenceHelper().isShowSystemFiles(); Map<String, Long> dirSizes = Util.getDirSizes(currentDir); for(String fileName : children) { if(".nomedia".equals(fileName)) { listing.setExcludeFromMedia(true); } File f = new File(currentDir.getAbsolutePath()+File.separator+fileName); if(!f.exists()) { continue; } if(Util.isProtected(f) && !showSystem) { continue; } if(f.isHidden() && !showHidden) { continue; } String fname = f.getName(); FileListEntry child = new FileListEntry(); child.setName(fname); child.setPath(f); if(f.isDirectory()) { try { Long dirSize = dirSizes.get(f.getCanonicalPath()); child.setSize(dirSize); } catch (Exception e) { Log.w(TAG, "Could not find size for "+child.getPath().getAbsolutePath()); child.setSize(0); } } else { child.setSize(f.length()); } child.setLastModified(new Date(f.lastModified())); childFiles.add(child); } FileListSorter sorter = new FileListSorter(caller); Collections.sort(childFiles, sorter); Log.v(TAG, "Will now interrupt thread waiting to show progress bar"); if(waitForASec.isAlive()) { try { waitForASec.interrupt(); } catch (Exception e) { Log.e(TAG, "Error while interrupting thread",e); } } return listing; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/workers/Finder.java
Java
gpl3
4,111
package net.appositedesigns.fileexplorer.workers; import java.io.File; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.util.AbortionFlag; import net.appositedesigns.fileexplorer.util.Util; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.AsyncTask; import android.util.Log; import android.widget.Toast; public class FileMover extends AsyncTask<File, Integer, Boolean> { private static final String TAG = FileMover.class.getName(); private int mode= 1; private AbortionFlag flag; private FileListActivity caller; private ProgressDialog moveProgressDialog; public FileMover(FileListActivity context, int mode) { caller = context; this.mode =mode; flag = new AbortionFlag(); } @Override protected void onPostExecute(Boolean result) { Log.v(TAG, "Inside post execute. Result of paste operation is - "+result); if(result) { if(mode==Util.PASTE_MODE_MOVE) { Log.v(TAG, "Paste mode was MOVE - set src file to null"); Util.setPasteSrcFile(null, 0); } caller.runOnUiThread(new Runnable() { @Override public void run() { if(moveProgressDialog.isShowing()) { moveProgressDialog.dismiss(); } if(mode==Util.PASTE_MODE_COPY) { Toast.makeText(caller.getApplicationContext(), caller.getString(R.string.copy_complete), Toast.LENGTH_LONG); } else { Toast.makeText(caller.getApplicationContext(), caller.getString(R.string.move_complete), Toast.LENGTH_LONG); } caller.refresh(); } }); } else { caller.runOnUiThread(new Runnable() { @Override public void run() { if(moveProgressDialog.isShowing()) { moveProgressDialog.dismiss(); } Toast.makeText(caller.getApplicationContext(), caller.getString(R.string.generic_operation_failed), Toast.LENGTH_LONG); } }); } } @Override protected Boolean doInBackground(File... params) { Log.v(TAG, "Started doInBackground"); File destDir = params[0]; return Util.paste(mode, destDir, flag); } @Override protected void onPreExecute() { caller.runOnUiThread(new Runnable() { @Override public void run() { String message = caller.getString(R.string.copying_path,Util.getFileToPaste().getName()); if(mode==Util.PASTE_MODE_MOVE) { message = caller.getString(R.string.moving_path,Util.getFileToPaste().getName()); } moveProgressDialog = new ProgressDialog(caller); moveProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); moveProgressDialog.setMessage(message); moveProgressDialog.setButton(caller.getString(R.string.run_in_background), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); moveProgressDialog.setButton2(caller.getString(R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); FileMover.this.flag.abort(); } }); moveProgressDialog.show(); } }); } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/workers/FileMover.java
Java
gpl3
3,427
package net.appositedesigns.fileexplorer.workers; import java.io.File; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.exception.LocationInvalidException; import net.appositedesigns.fileexplorer.util.AbortionFlag; import net.appositedesigns.fileexplorer.util.ZipUtil; import android.app.AlertDialog.Builder; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.AsyncTask; import android.util.Log; public class Zipper extends AsyncTask<File, Integer, String> { private static final String TAG = Zipper.class.getName(); private AbortionFlag flag; private FileListActivity caller; private String zipName; private ProgressDialog zipProgress; private boolean zippedAtleastOne; private File destination; public Zipper(String zipName, File destination, FileListActivity mContext) { this.destination = destination; this.flag = new AbortionFlag(); this.caller = mContext; this.zipName = zipName; } @Override protected void onPostExecute(String result) { final String zipFile = result; caller.runOnUiThread(new Runnable() { @Override public void run() { if (zipProgress != null && zipProgress.isShowing()) { zipProgress.dismiss(); } } }); if(zipFile!=null) { caller.runOnUiThread(new Runnable() { @Override public void run() { caller.refresh(); new Builder(caller) .setIcon(android.R.drawable.ic_dialog_info) .setTitle(caller.getString(R.string.success)) .setMessage(caller.getString(R.string.zip_success, zipFile)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } }); } } @Override protected String doInBackground(File... params) { try { File zipDest = destination; File zipFile = new File(zipDest, zipName+".zip"); zippedAtleastOne = false; for(File fileToBeZipped : params) { if(flag.isAborted()) { caller.runOnUiThread(new Runnable() { @Override public void run() { String message = zippedAtleastOne?caller.getString(R.string.zip_abort_partial):caller.getString(R.string.zip_aborted); new Builder(caller) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(caller.getString(R.string.abort)) .setMessage(message) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } }); } else { if(fileToBeZipped.isDirectory()) { if(fileToBeZipped.listFiles().length==0) { caller.runOnUiThread(new Runnable() { @Override public void run() { new Builder(caller) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(caller.getString(R.string.zip)) .setMessage(caller.getString(R.string.zip_dir_empty)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } }); continue; } else { ZipUtil.zipFolder(fileToBeZipped.getAbsolutePath(), zipFile.getAbsolutePath(),flag); zippedAtleastOne = true; } } else { ZipUtil.zipFile(fileToBeZipped.getAbsolutePath(), zipFile.getAbsolutePath(),flag); zippedAtleastOne = true; } } if(zippedAtleastOne) { return zipFile.getAbsolutePath(); } } } catch (LocationInvalidException e) { Log.e(TAG, "Zip destination was invalid", e); caller.runOnUiThread(new Runnable() { @Override public void run() { new Builder(caller) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(caller.getString(R.string.error)) .setMessage(caller.getString(R.string.zip_dest_invalid)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } }); } catch(Exception e) { Log.e(TAG, "An error occured while running in background", e); caller.runOnUiThread(new Runnable() { @Override public void run() { new Builder(caller) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(caller.getString(R.string.zip)) .setMessage(caller.getString(R.string.zip_dir_empty)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } }); } return null; } @Override protected void onPreExecute() { caller.runOnUiThread(new Runnable() { @Override public void run() { zipProgress = new ProgressDialog(caller); zipProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER); zipProgress.setMessage(caller.getString(R.string.zip_in_progress)); zipProgress.setButton(caller.getString(R.string.run_in_background), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); zipProgress.setButton2(caller.getString(R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { zipProgress.getButton(which).setText(R.string.cancelling); Zipper.this.flag.abort(); } }); zipProgress.show(); } }); } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/workers/Zipper.java
Java
gpl3
6,303
package net.appositedesigns.fileexplorer.workers; import java.io.File; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.callbacks.OperationCallback; import net.appositedesigns.fileexplorer.util.Util; import android.app.AlertDialog.Builder; import android.app.ProgressDialog; import android.os.AsyncTask; import android.util.Log; import android.widget.Toast; public class Trasher extends AsyncTask<File, Integer, Boolean> { private static final String TAG = Trasher.class.getName(); private File fileToBeDeleted; private FileListActivity caller; private ProgressDialog waitDialog; private OperationCallback<Void> callback; public Trasher(FileListActivity caller, OperationCallback<Void> callback) { this.caller = caller; if(callback!=null) { this.callback = callback; } else { this.callback = new OperationCallback<Void>() { @Override public Void onSuccess() {return null;} @Override public void onFailure(Throwable e) {Log.e(TAG, "Error occurred", e);} }; } } @Override protected void onPostExecute(Boolean result) { Log.v(TAG, "In post execute. Result of deletion was - "+result); if(result) { Log.i(TAG, fileToBeDeleted.getAbsolutePath()+" deleted successfully"); caller.runOnUiThread(new Runnable() { @Override public void run() { waitDialog.dismiss(); Toast.makeText(caller.getApplicationContext(), "Deleted", Toast.LENGTH_LONG); if(callback!=null) { callback.onSuccess(); } caller.refresh(); } }); } else { Util.setPasteSrcFile(fileToBeDeleted, Util.getPasteMode()); caller.runOnUiThread(new Runnable() { @Override public void run() { if(callback!=null) { callback.onFailure(new Exception()); } waitDialog.dismiss(); new Builder(caller) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(caller.getString(R.string.error)) .setMessage(caller.getString(R.string.delete_failed, fileToBeDeleted.getName())) .show(); } }); } } @Override protected Boolean doInBackground(File... params) { fileToBeDeleted = params[0]; caller.runOnUiThread(new Runnable() { @Override public void run() { waitDialog = new ProgressDialog(caller); waitDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); waitDialog.setMessage(caller.getString(R.string.deleting_path,fileToBeDeleted.getName())); waitDialog.setCancelable(false); waitDialog.show(); } }); try { Log.v(TAG, "Checking if file on clipboard is same as that being deleted"); if(Util.getFileToPaste() != null && Util.getFileToPaste().getCanonicalPath().equals(fileToBeDeleted.getCanonicalPath())) { Log.v(TAG, "File on clipboard is being deleted"); Util.setPasteSrcFile(null, Util.getPasteMode()); } return Util.delete(fileToBeDeleted); } catch (Exception e) { Log.e(TAG, "Error occured while deleting file "+fileToBeDeleted.getAbsolutePath(),e); return false; } } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/workers/Trasher.java
Java
gpl3
3,281
package net.appositedesigns.fileexplorer.workers; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.util.AbortionFlag; import android.app.ProgressDialog; import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.AsyncTask; import android.util.Log; public class Unzipper extends AsyncTask<File, String, List<String>> { private static final String TAG = Unzipper.class.getName(); private FileListActivity mContext; private AbortionFlag flag; private ProgressDialog zipProgress; private File destination; private int unzippedCount; public Unzipper(FileListActivity context, File destination) { mContext = context; unzippedCount = 0; this.flag = new AbortionFlag(); this.destination = destination; } @Override protected void onPostExecute(final List<String> result) { mContext.runOnUiThread(new Runnable() { @Override public void run() { boolean unzippedAtleastOne = (result!=null) && (result.size()>0); if (zipProgress != null && zipProgress.isShowing()) { zipProgress.dismiss(); } if(flag.isAborted()) { mContext.refresh(); String message = unzippedAtleastOne?mContext.getString(R.string.unzip_abort_partial, destination.getAbsolutePath()):mContext.getString(R.string.unzip_aborted); new Builder(mContext) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(mContext.getString(R.string.abort)) .setMessage(message) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } else if(unzippedAtleastOne) { mContext.refresh(); new Builder(mContext) .setIcon(android.R.drawable.ic_dialog_info) .setTitle(mContext.getString(R.string.success)) .setMessage(mContext.getString(R.string.unzip_success, result.size())) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } } }); } @Override protected void onPreExecute() { mContext.runOnUiThread(new Runnable() { @Override public void run() { zipProgress = new ProgressDialog(mContext); zipProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER); zipProgress.setMessage(mContext.getString(R.string.unzip_progress)); zipProgress.setButton(mContext.getString(R.string.run_in_background), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); zipProgress.setButton2(mContext.getString(R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { zipProgress.getButton(which).setText(R.string.cancelling); Unzipper.this.flag.abort(); } }); zipProgress.show(); } }); } @Override protected List<String> doInBackground(File... files) { List<String> extracted = new ArrayList<String>(); if(files!=null && files.length >= 1) { Log.i(TAG, "Zip files: "+files); for(File zipFile : files) { try { extractFolder(zipFile, extracted); extracted.add(zipFile.getAbsolutePath()); } catch (Exception e) { Log.e(TAG, "Failed to unzip "+zipFile.getAbsolutePath()+". File exists - "+zipFile.exists(), e); mContext.runOnUiThread(new Runnable() { @Override public void run() { new Builder(mContext) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(mContext.getString(R.string.zip)) .setMessage(mContext.getString(R.string.unzip_failed_generic)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } }); } } } else { return null; } return extracted; } @Override protected void onProgressUpdate(String... values) { if(values!=null && values.length > 0) { unzippedCount +=values.length; final String curr = values[0]; mContext.runOnUiThread(new Runnable() { @Override public void run() { if(zipProgress!=null && zipProgress.isShowing()) { zipProgress.setMessage(mContext.getString(R.string.unzip_progress, curr)); } } }); } } private void extractFolder(File zipFile, List<String> extracted) throws ZipException, IOException { Log.i(TAG,zipFile.getAbsolutePath()); int BUFFER = 2048; File file = zipFile; ZipFile zip = new ZipFile(file); String newPath = destination.getAbsolutePath()+"/"+zipFile.getName().substring(0, zipFile.getName().length() - 4); new File(newPath).mkdir(); Enumeration zipFileEntries = zip.entries(); // Process each entry while (zipFileEntries.hasMoreElements() && !flag.isAborted()) { // grab a zip file entry ZipEntry entry = (ZipEntry) zipFileEntries.nextElement(); String currentEntry = entry.getName(); File destFile = new File(newPath, currentEntry); //destFile = new File(newPath, destFile.getName()); File destinationParent = destFile.getParentFile(); publishProgress(destinationParent.getName()); // create the parent directory structure if needed destinationParent.mkdirs(); extracted.add(destinationParent.getAbsolutePath()); if (!entry.isDirectory()) { publishProgress(entry.getName()); BufferedInputStream is = new BufferedInputStream(zip .getInputStream(entry)); int currentByte; // establish buffer for writing file byte data[] = new byte[BUFFER]; // write the current file to disk FileOutputStream fos = new FileOutputStream(destFile); BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER); // read and write until last byte is encountered while ((currentByte = is.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, currentByte); } dest.flush(); dest.close(); is.close(); extracted.add(destFile.getAbsolutePath()); } // if (currentEntry.endsWith(".zip")) // { // // found a zip file, try to open // extractFolder(destFile.getAbsolutePath()); // } } } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/workers/Unzipper.java
Java
gpl3
7,521
package net.appositedesigns.fileexplorer.workers; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.BookmarkListActivity; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.util.FileListSorter; import android.app.ProgressDialog; import android.os.AsyncTask; import android.util.Log; public class BookmarkLoader extends AsyncTask<File, Integer, List<FileListEntry>> { private static final String TAG = BookmarkLoader.class.getName(); private BookmarkListActivity caller; private ProgressDialog waitDialog; public BookmarkLoader(BookmarkListActivity caller) { this.caller = caller; } @Override protected void onPostExecute(List<FileListEntry> result) { final List<FileListEntry> childFiles = result; caller.runOnUiThread(new Runnable() { @Override public void run() { if(waitDialog!=null && waitDialog.isShowing()) { waitDialog.dismiss(); } Log.v(TAG, "Bookmarks for passed to caller"); caller.setBookmarks(childFiles); if(childFiles.size()>0) { caller.getActionBar().setSubtitle(caller.getString(R.string.bookmarks_count, childFiles.size())); } else { caller.getActionBar().setSubtitle(caller.getString(R.string.bookmarks_count_0)); } } }); } @Override protected List<FileListEntry> doInBackground(File... params) { Thread waitForASec = new Thread() { @Override public void run() { waitDialog = new ProgressDialog(caller); waitDialog.setTitle(""); waitDialog.setMessage(caller.getString(R.string.querying_filesys)); waitDialog.setIndeterminate(true); try { Thread.sleep(100); if(this.isInterrupted()) { return; } else { caller.runOnUiThread(new Runnable() { @Override public void run() { if(waitDialog!=null) waitDialog.show(); } }); } } catch (InterruptedException e) { Log.e(TAG, "Progressbar waiting thread encountered exception ",e); e.printStackTrace(); } } }; caller.runOnUiThread(waitForASec); List<FileListEntry> childFiles = new ArrayList<FileListEntry>(caller.getBookmarker().getBookmarks()); FileListSorter sorter = new FileListSorter(caller); Collections.sort(childFiles, sorter); Log.v(TAG, "Will now interrupt thread waiting to show progress bar"); if(waitForASec.isAlive()) { try { waitForASec.interrupt(); } catch (Exception e) { Log.e(TAG, "Error while interrupting thread",e); } } return childFiles; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/workers/BookmarkLoader.java
Java
gpl3
2,891
package net.appositedesigns.fileexplorer.exception; public class LocationInvalidException extends Exception { private static final long serialVersionUID = -4046926680600982016L; private String location; public LocationInvalidException(String location) { super(); this.location = location; } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/exception/LocationInvalidException.java
Java
gpl3
462
package net.appositedesigns.fileexplorer.callbacks; import android.content.Intent; import android.net.Uri; import android.view.ActionMode; import android.view.ActionMode.Callback; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.webkit.MimeTypeMap; import android.widget.ShareActionProvider; import android.widget.ShareActionProvider.OnShareTargetSelectedListener; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.util.FileActionsHelper; public abstract class FileActionsCallback implements Callback { private FileListActivity activity; private FileListEntry file; static int[] allOptions = {R.id.menu_copy,R.id.menu_cut, R.id.menu_delete, R.id.menu_props, R.id.menu_share, R.id.menu_rename, R.id.menu_zip, R.id.menu_unzip}; public FileActionsCallback(FileListActivity activity, FileListEntry fileListEntry) { this.activity = activity; this.file = fileListEntry; } @Override public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { FileActionsHelper.doOperation(file, item.getItemId(), activity, new OperationCallback<Void>() { @Override public Void onSuccess() { return null; } @Override public void onFailure(Throwable e) { } }); mode.finish(); return true; } @Override public boolean onCreateActionMode(final ActionMode actionMode, Menu menu) { int[] validOptions = FileActionsHelper.getContextMenuOptions(file.getPath(), activity); if(validOptions==null || validOptions.length ==0) { onDestroyActionMode(actionMode); return false; } actionMode.setTitle(activity.getString(R.string.selected_, file.getName())); MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.context_menu, menu); for(int o :allOptions) { boolean valid = false; for(int v : validOptions) { if(o == v) { valid = true; break; } } if(!valid) { menu.removeItem(o); } else { if(o == R.id.menu_share) { MenuItem menuItem = menu.findItem(R.id.menu_share); ShareActionProvider mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider(); mShareActionProvider.setOnShareTargetSelectedListener(new OnShareTargetSelectedListener() { @Override public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { actionMode.finish(); return false; } }); final Intent intent = new Intent(Intent.ACTION_SEND); Uri uri = Uri.fromFile(file.getPath()); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString())); intent.setType(type); intent.setAction(Intent.ACTION_SEND); intent.setType(type==null?"*/*":type); intent.putExtra(Intent.EXTRA_STREAM, uri); mShareActionProvider.setShareIntent(intent); } } } return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/callbacks/FileActionsCallback.java
Java
gpl3
3,369
package net.appositedesigns.fileexplorer.callbacks; public interface OperationCallback<T> { T onSuccess(); void onFailure(Throwable e); }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/callbacks/OperationCallback.java
Java
gpl3
149
package net.appositedesigns.fileexplorer.callbacks; public interface CancellationCallback { void onCancel(); }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/callbacks/CancellationCallback.java
Java
gpl3
120
package net.appositedesigns.fileexplorer.adapters; import java.util.List; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.BookmarkListActivity; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.util.Util; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; public class BookmarkListAdapter extends BaseAdapter { public static class ViewHolder { public TextView resName; public ImageView resIcon; public TextView resMeta; } private static final String TAG = BookmarkListAdapter.class.getName(); private BookmarkListActivity mContext; private List<FileListEntry> files; private LayoutInflater mInflater; public BookmarkListAdapter(BookmarkListActivity context, List<FileListEntry> files) { super(); mContext = context; this.files = files; mInflater = mContext.getLayoutInflater(); } @Override public int getCount() { if(files == null) { return 0; } else { return files.size(); } } @Override public Object getItem(int arg0) { if(files == null) return null; else return files.get(arg0); } public List<FileListEntry> getItems() { return files; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { convertView = mInflater.inflate(R.layout.bookmark_list_item, parent, false); holder = new ViewHolder(); holder.resName = (TextView)convertView.findViewById(R.id.explorer_resName); holder.resMeta = (TextView)convertView.findViewById(R.id.explorer_resMeta); holder.resIcon = (ImageView)convertView.findViewById(R.id.explorer_resIcon); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } final FileListEntry currentFile = files.get(position); holder.resName.setText(currentFile.getName()); if(Util.isRoot(currentFile.getPath())) { holder.resName.setText(mContext.getString(R.string.filesystem_root)); } holder.resIcon.setImageDrawable(Util.getIcon(mContext, currentFile.getPath())); holder.resMeta.setText(currentFile.getPath().getAbsolutePath()); return convertView; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/adapters/BookmarkListAdapter.java
Java
gpl3
2,702
package net.appositedesigns.fileexplorer.adapters; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.util.Util; import java.util.List; public class FileListAdapter extends BaseAdapter { public static class ViewHolder { public TextView resName; public ImageView resIcon; public TextView resMeta; } private static final String TAG = FileListAdapter.class.getName(); private FileListActivity mContext; private List<FileListEntry> files; private LayoutInflater mInflater; public FileListAdapter(FileListActivity context, List<FileListEntry> files) { super(); mContext = context; this.files = files; mInflater = mContext.getLayoutInflater(); } @Override public int getCount() { if(files == null) { return 0; } else { return files.size(); } } @Override public Object getItem(int arg0) { if(files == null) return null; else return files.get(arg0); } public List<FileListEntry> getItems() { return files; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { convertView = mInflater.inflate(R.layout.explorer_item, parent, false); holder = new ViewHolder(); holder.resName = (TextView)convertView.findViewById(R.id.explorer_resName); holder.resMeta = (TextView)convertView.findViewById(R.id.explorer_resMeta); holder.resIcon = (ImageView)convertView.findViewById(R.id.explorer_resIcon); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } final FileListEntry currentFile = files.get(position); holder.resName.setText(currentFile.getName()); holder.resIcon.setImageDrawable(Util.getIcon(mContext, currentFile.getPath())); String meta = Util.prepareMeta(currentFile, mContext); holder.resMeta.setText(meta); return convertView; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/adapters/FileListAdapter.java
Java
gpl3
2,561
package net.appositedesigns.fileexplorer; import android.app.Application; import android.content.Intent; public class FileExplorerApp extends Application { public static final int THEME_BLACK = R.style.Theme_FileExplorer; public static final int THEME_WHITE = R.style.Theme_FileExplorer_Light; public static final int THEME_WHITE_BLACK = android.R.style.Theme_Holo_Light_DarkActionBar; public static final String ACTION_OPEN_BOOKMARK = "net.appositedesigns.fileexplorer.action.OPEN_BOOKMARKS"; public static final String ACTION_OPEN_FOLDER = "net.appositedesigns.fileexplorer.action.OPEN_FOLDER"; public static final String EXTRA_IS_PICKER = "net.appositedesigns.fileexplorer.extra.IS_PICKER"; public static final int REQ_PICK_FILE = 10; public static final int REQ_PICK_BOOKMARK = 11; public static final String EXTRA_SELECTED_BOOKMARK = "net.appositedesigns.fileexplorer.extra.SELECTED_BOOKMARK"; public static final String EXTRA_FOLDER = "net.appositedesigns.fileexplorer.extra.FOLDER"; private Intent fileAttachIntent; public Intent getFileAttachIntent() { return fileAttachIntent; } public void setFileAttachIntent(Intent fileAttachIntent) { this.fileAttachIntent = fileAttachIntent; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/FileExplorerApp.java
Java
gpl3
1,261
package net.appositedesigns.fileexplorer.util; import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Environment; import android.os.StatFs; import android.text.InputType; import android.text.format.DateFormat; import android.util.Log; import android.webkit.MimeTypeMap; import android.widget.EditText; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.callbacks.CancellationCallback; import net.appositedesigns.fileexplorer.model.FileListEntry; import org.apache.commons.io.FileUtils; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; public final class Util { private static final String TAG = Util.class.getName(); private static File COPIED_FILE = null; private static int pasteMode = 1; public static final int PASTE_MODE_COPY = 0; public static final int PASTE_MODE_MOVE = 1; private Util(){} public static synchronized void setPasteSrcFile(File f, int mode) { COPIED_FILE = f; pasteMode = mode%2; } public static synchronized File getFileToPaste() { return COPIED_FILE; } public static synchronized int getPasteMode() { return pasteMode; } static boolean isMusic(File file) { Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString())); if(type == null) return false; else return (type.toLowerCase().startsWith("audio/")); } static boolean isVideo(File file) { Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString())); if(type == null) return false; else return (type.toLowerCase().startsWith("video/")); } public static boolean isPicture(File file) { Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString())); if(type == null) return false; else return (type.toLowerCase().startsWith("image/")); } public static boolean isProtected(File path) { return (!path.canRead() && !path.canWrite()); } public static boolean isUnzippable(File path) { return (path.isFile() && path.canRead() && path.getName().endsWith(".zip")); } public static boolean isRoot(File dir) { return dir.getAbsolutePath().equals("/"); } public static boolean isSdCard(File file) { try { return (file.getCanonicalPath().equals(Environment.getExternalStorageDirectory().getCanonicalPath())); } catch (IOException e) { return false; } } public static Drawable getIcon(Context mContext, File file) { if(!file.isFile()) //dir { if(Util.isProtected(file)) { return mContext.getResources().getDrawable(R.drawable.filetype_sys_dir); } else if(Util.isSdCard(file)) { return mContext.getResources().getDrawable(R.drawable.filetype_sdcard); } else { return mContext.getResources().getDrawable(R.drawable.filetype_dir); } } else //file { String fileName = file.getName(); if(Util.isProtected(file)) { return mContext.getResources().getDrawable(R.drawable.filetype_sys_file); } if(fileName.endsWith(".apk")) { return mContext.getResources().getDrawable(R.drawable.filetype_apk); } if(fileName.endsWith(".zip")) { return mContext.getResources().getDrawable(R.drawable.filetype_zip); } else if(Util.isMusic(file)) { return mContext.getResources().getDrawable(R.drawable.filetype_music); } else if(Util.isVideo(file)) { return mContext.getResources().getDrawable(R.drawable.filetype_video); } else if(Util.isPicture(file)) { return mContext.getResources().getDrawable(R.drawable.filetype_image); } else { return mContext.getResources().getDrawable(R.drawable.filetype_generic); } } } public static boolean delete(File fileToBeDeleted) { try { FileUtils.forceDelete(fileToBeDeleted); return true; } catch (IOException e) { return false; } } public static boolean mkDir(String canonicalPath, CharSequence newDirName) { File newdir = new File(canonicalPath+File.separator+newDirName); return newdir.mkdirs(); } public static String prepareMeta(FileListEntry file,FileListActivity context) { File f = file.getPath(); try { if(isProtected(f)) { return context.getString(R.string.system_path); } if(file.getPath().isFile()) { return context.getString(R.string.size_is, FileUtils.byteCountToDisplaySize(file.getSize())); } } catch (Exception e) { Log.e(Util.class.getName(), e.getMessage()); } return ""; } public static boolean paste(int mode, File destinationDir, AbortionFlag flag) { Log.v(TAG, "Will now paste file on clipboard"); File fileBeingPasted = new File(getFileToPaste().getParent(),getFileToPaste().getName()); if(doPaste(mode, getFileToPaste(), destinationDir, flag)) { if(getPasteMode() == PASTE_MODE_MOVE) { if(fileBeingPasted.isFile()) { if(FileUtils.deleteQuietly(fileBeingPasted)) { Log.i(TAG, "File deleted after paste "+fileBeingPasted.getAbsolutePath()); } else { Log.w(TAG, "File NOT deleted after paste "+fileBeingPasted.getAbsolutePath()); } } else { try { FileUtils.deleteDirectory(fileBeingPasted); } catch (IOException e) { Log.e(TAG, "Error while deleting directory after paste - "+fileBeingPasted.getAbsolutePath(), e); return false; } } } return true; } else { return false; } } private static boolean doPaste(int mode, File srcFile, File destinationDir, AbortionFlag flag) { if(!flag.isAborted()) try { if(srcFile.isDirectory()) { File newDir = new File(destinationDir.getAbsolutePath()+File.separator+srcFile.getName()); newDir.mkdirs(); for(File child : srcFile.listFiles()) { doPaste(mode, child, newDir, flag); } return true; } else { FileUtils.copyFileToDirectory(srcFile, destinationDir); return true; } } catch (Exception e) { return false; } else { return false; } } public static boolean canPaste(File destDir) { if(getFileToPaste() == null) { return false; } if(getFileToPaste().isFile()) { return true; } try { if(destDir.getCanonicalPath().startsWith(COPIED_FILE.getCanonicalPath())) { return false; } else { return true; } } catch (Exception e) { return false; } } public static boolean canShowQuickActions(FileListEntry currentFile, FileListActivity mContext) { if(!mContext.getPreferenceHelper().useQuickActions() || mContext.isInPickMode()) { return false; } File path = currentFile.getPath(); if(isProtected(path)) { return false; } if(isSdCard(path)) { return false; } else { return true; } } public static CharSequence[] getFileProperties(FileListEntry file, FileListActivity context) { if(Util.isSdCard(file.getPath())) { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); long sdAvailSize = (long)stat.getAvailableBlocks() *(long)stat.getBlockSize(); long totalSize = (long)stat.getBlockCount() *(long)stat.getBlockSize(); return new CharSequence[]{context.getString(R.string.total_capacity, Util.getSizeStr(totalSize)), context.getString(R.string.free_space, Util.getSizeStr(sdAvailSize))}; } else if(file.getPath().isFile()) return new CharSequence[]{context.getString(R.string.filepath_is, file.getPath().getAbsolutePath()), context.getString(R.string.mtime_is, DateFormat.getDateFormat(context).format(file.getLastModified())), context.getString(R.string.size_is, FileUtils.byteCountToDisplaySize(file.getSize()))}; else { return new CharSequence[]{context.getString(R.string.filepath_is, file.getPath().getAbsolutePath()), context.getString(R.string.mtime_is, DateFormat.getDateFormat(context).format(file.getLastModified()))}; } } private static String getSizeStr(long bytes) { if(bytes >= FileUtils.ONE_GB) { return (double)Math.round((((double)bytes / FileUtils.ONE_GB)*100))/100 + " GB"; } else if(bytes >= FileUtils.ONE_MB) { return (double)Math.round((((double)bytes / FileUtils.ONE_MB)*100))/100 + " MB"; } else if(bytes >= FileUtils.ONE_KB) { return (double)Math.round((((double)bytes / FileUtils.ONE_KB)*100))/100 + " KB"; } return bytes+" bytes"; } public static Map<String, Long> getDirSizes(File dir) { Map<String, Long> sizes = new HashMap<String, Long>(); try { Process du = Runtime.getRuntime().exec("/system/bin/du -b -d1 "+dir.getCanonicalPath(), new String[]{}, Environment.getRootDirectory()); BufferedReader in = new BufferedReader(new InputStreamReader( du.getInputStream())); String line = null; while ((line = in.readLine()) != null) { String[] parts = line.split("\\s+"); String sizeStr = parts[0]; Long size = Long.parseLong(sizeStr); String path = parts[1]; sizes.put(path, size); } } catch (IOException e) { Log.w(TAG, "Could not execute DU command for "+dir.getAbsolutePath(), e); } return sizes; } public static void gotoPath(final String currentPath, final FileListActivity mContext) { gotoPath(currentPath, mContext, null); } public static void gotoPath(final String currentPath, final FileListActivity mContext,final CancellationCallback callback) { final EditText input = new EditText(mContext); input.setInputType(InputType.TYPE_TEXT_VARIATION_URI); input.setSingleLine(); new Builder(mContext) .setTitle(mContext.getString(R.string.goto_path)) .setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { CharSequence toPath = input.getText(); try { File toDir = new File(toPath.toString()); if(toDir.isDirectory() && toDir.exists()) { mContext.listContents(toDir); } else { throw new FileNotFoundException(); } } catch (Exception e) { Log.e(TAG, "Error navigating to path"+toPath, e); new Builder(mContext) .setTitle(mContext.getString(R.string.error)) .setMessage(mContext.getString(R.string.path_not_exist)) .show(); } } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); if(callback != null) callback.onCancel(); } }) .show(); input.setText(currentPath); } public static File getDownloadsFolder() { return new File("/sdcard/"+Environment.DIRECTORY_DOWNLOADS); } public static File getDcimFolder() { return new File("/sdcard/"+Environment.DIRECTORY_DCIM); } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/util/Util.java
Java
gpl3
11,837
package net.appositedesigns.fileexplorer.util; public class AbortionFlag { private boolean aborted = false; public synchronized void abort() { aborted = true; } public synchronized boolean isAborted() { return aborted; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/util/AbortionFlag.java
Java
gpl3
253
package net.appositedesigns.fileexplorer.util; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Instrumentation.ActivityResult; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.net.Uri; import android.os.Environment; import android.util.Log; import android.webkit.MimeTypeMap; import android.widget.EditText; import android.widget.Toast; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.callbacks.CancellationCallback; import net.appositedesigns.fileexplorer.callbacks.OperationCallback; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.workers.Trasher; import net.appositedesigns.fileexplorer.workers.Unzipper; import net.appositedesigns.fileexplorer.workers.Zipper; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; public class FileActionsHelper { protected static final String TAG = FileActionsHelper.class.getName(); public static void copyFile(File file, FileListActivity mContext) { Util.setPasteSrcFile(file,Util.PASTE_MODE_COPY); Toast.makeText(mContext.getApplicationContext(), mContext.getString(R.string.copied_toast, file.getName()), Toast.LENGTH_SHORT).show(); mContext.invalidateOptionsMenu(); } public static void cutFile(final File file, final FileListActivity mContext) { Util.setPasteSrcFile(file,Util.PASTE_MODE_MOVE); Toast.makeText(mContext.getApplicationContext(), mContext.getString(R.string.cut_toast, file.getName()), Toast.LENGTH_SHORT).show(); mContext.invalidateOptionsMenu(); } public static void showProperties(final FileListEntry file, final FileListActivity mContext) { if(mContext!=null) new Builder(mContext) .setTitle(mContext.getString(R.string.properties_for, file.getName())) .setItems(Util.getFileProperties(file, mContext), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }) .show(); } public static void deleteFile(final File file, final FileListActivity mContext,final OperationCallback<Void> callback) { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setCancelable(true); builder.setMessage(mContext.getString(R.string.confirm_delete, file.getName())) .setCancelable(false) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { new Trasher(mContext, callback).execute(file); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setTitle(R.string.confirm); AlertDialog confirm = builder.create(); if(mContext!=null) { confirm.show(); } } public static int[] getContextMenuOptions(File file, FileListActivity caller) { PreferenceHelper prefs = new PreferenceHelper(caller); if(Util.isProtected(file)) { return new int[]{}; } if(Util.isSdCard(file)) { return new int[]{R.id.menu_props}; } else if(file.isDirectory()) { if(prefs.isZipEnabled()) { return new int[]{R.id.menu_copy,R.id.menu_cut, R.id.menu_delete, R.id.menu_rename, R.id.menu_zip, R.id.menu_props}; } return new int[]{R.id.menu_copy, R.id.menu_cut, R.id.menu_delete, R.id.menu_rename, R.id.menu_props}; } else if(Util.isUnzippable(file)) { if(prefs.isZipEnabled()) { return new int[]{R.id.menu_copy,R.id.menu_cut, R.id.menu_delete, R.id.menu_rename, R.id.menu_zip, R.id.menu_unzip, R.id.menu_props}; } return new int[]{R.id.menu_copy, R.id.menu_cut, R.id.menu_delete, R.id.menu_rename, R.id.menu_props}; } else { if(prefs.isZipEnabled()) { return new int[]{R.id.menu_share, R.id.menu_copy, R.id.menu_cut, R.id.menu_delete, R.id.menu_rename, R.id.menu_zip, R.id.menu_props}; } return new int[]{R.id.menu_share, R.id.menu_copy, R.id.menu_cut, R.id.menu_delete, R.id.menu_rename, R.id.menu_props}; } } public static void rename(final File file, final FileListActivity mContext, final OperationCallback<Void> callback) { final EditText input = new EditText(mContext); input.setHint(mContext.getString(R.string.enter_new_name)); input.setSingleLine(); if(mContext!=null) new Builder(mContext) .setTitle(mContext.getString(R.string.rename_dialog_title, file.getName())) .setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { CharSequence newName = input.getText(); try { File parentFolder = file.getParentFile(); if(file.renameTo(new File(parentFolder, newName.toString()))) { if(callback!=null) { callback.onSuccess(); } Toast.makeText(mContext, mContext.getString(R.string.rename_toast, file.getName(), newName), Toast.LENGTH_LONG).show(); mContext.refresh(); } else { if(callback!=null) { callback.onFailure(new Exception()); } if(mContext!=null) new Builder(mContext) .setTitle(mContext.getString(R.string.error)) .setMessage(mContext.getString(R.string.rename_failed, file.getName())) .show(); } } catch (Exception e) { if(callback!=null) { callback.onFailure(e); } Log.e(TAG, "Error occured while renaming path", e); if(mContext!=null) new Builder(mContext) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(mContext.getString(R.string.error)) .setMessage(mContext.getString(R.string.rename_failed, file.getName())) .show(); } } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }) .show(); } public static void zip(final File file, final FileListActivity mContext) { try { final File zipLoc = new PreferenceHelper(mContext).getZipDestinationDir(); if(zipLoc == null) { final EditText zipDestinationInput = new EditText(mContext); zipDestinationInput.setSingleLine(); new Builder(mContext) .setTitle(mContext.getString(R.string.unzip_destination)) .setView(zipDestinationInput) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { CharSequence destinationPath = zipDestinationInput.getText(); try { File destination = new File(destinationPath.toString()); if(destination.isFile() && destination.exists()) { throw new FileNotFoundException(); } else { promptZipFileName(file, mContext, destination); } } catch (Exception e) { Log.e(TAG, "Error zipping to path"+destinationPath, e); new Builder(mContext) .setTitle(mContext.getString(R.string.error)) .setMessage(mContext.getString(R.string.zip_failed)) .show(); } } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }) .show(); zipDestinationInput.setText(mContext.getCurrentDir().getAbsolutePath()); } else { promptZipFileName(file, mContext, zipLoc); } } catch (Exception e) { Log.e(TAG, "Zip destination was invalid", e); mContext.runOnUiThread(new Runnable() { @Override public void run() { new Builder(mContext) .setTitle(mContext.getString(R.string.error)) .setMessage(mContext.getString(R.string.zip_dest_invalid)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } }); } } private static void promptZipFileName(final File file, final FileListActivity mContext,final File zipLoc) { final EditText input = new EditText(mContext); input.setHint(mContext.getString(R.string.enter_zip_file_name)); input.setSingleLine(); new Builder(mContext) .setTitle(mContext.getString(R.string.zip_dialog, zipLoc.getAbsolutePath())) .setView(input).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String zipName = input.getText().toString(); new Zipper(zipName,zipLoc, mContext).execute(file); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).show(); } public static void unzip(final FileListActivity mContext, final List<File> zipFiles, final CancellationCallback callback) { final EditText input = new EditText(mContext); input.setSingleLine(); new Builder(mContext) .setTitle(mContext.getString(R.string.unzip_destination)) .setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { CharSequence destinationPath = input.getText(); try { File destination = new File(destinationPath.toString()); if(destination.isFile() && destination.exists()) { throw new FileNotFoundException(); } else { new Unzipper(mContext, destination).execute((File[])(new ArrayList<File>(zipFiles).toArray(new File[0]))); } } catch (Exception e) { Log.e(TAG, "Error unzipping to path"+destinationPath, e); new Builder(mContext) .setTitle(mContext.getString(R.string.error)) .setMessage(mContext.getString(R.string.unzip_failed_dest_file)) .show(); } } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); if(callback != null) callback.onCancel(); } }) .show(); input.setText(mContext.getCurrentDir().getAbsolutePath()); } public static void doOperation(FileListEntry entry,int action, FileListActivity mContext, OperationCallback<Void> callback) { File file = entry.getPath(); switch (action) { case R.id.menu_cancel: ActivityResult result = new ActivityResult(Activity.RESULT_CANCELED, null); mContext.finish(); break; case R.id.menu_copy: copyFile(file, mContext); break; case R.id.menu_cut: cutFile(file, mContext); break; case R.id.menu_delete: deleteFile(file, mContext, callback); break; case R.id.menu_share: share(file, mContext); break; case R.id.menu_rename: rename(file, mContext, callback); break; case R.id.menu_zip: zip(file, mContext); break; case R.id.menu_unzip: List<File> zipFiles = new ArrayList<File>(); zipFiles.add(file); unzip(mContext, zipFiles, null); break; case R.id.menu_props: showProperties(entry, mContext); break; default: break; } } public static void rescanMedia(Activity mContext) { mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri .parse("file://" + Environment.getExternalStorageDirectory()))); Toast.makeText(mContext, R.string.media_rescan_started, Toast.LENGTH_SHORT).show(); Notification noti = new Notification.Builder(mContext) .setContentTitle(mContext.getString(R.string.media_rescan_started)) .setContentText(mContext.getString(R.string.media_rescan_started_desc)) .setSmallIcon(R.drawable.ic_notif_sdcard_rescan) .setAutoCancel(true) .build(); NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); // Hide the notification after its selected noti.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, noti); } public static void share(File file, Context mContext) { final Intent intent = new Intent(Intent.ACTION_SEND); Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString())); intent.setType(type); intent.setAction(Intent.ACTION_SEND); intent.setType(type==null?"*/*":type); intent.putExtra(Intent.EXTRA_STREAM, uri); mContext.startActivity(Intent.createChooser(intent,mContext.getString(R.string.share_via))); } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/util/FileActionsHelper.java
Java
gpl3
13,797
package net.appositedesigns.fileexplorer.util; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.os.AsyncTask; import net.appositedesigns.fileexplorer.activity.BookmarkListActivity; import net.appositedesigns.fileexplorer.model.FileListEntry; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public final class BookmarksHelper { private Activity mContext; private static List<String> bookmarkedPaths = new ArrayList<String>(); public static final String BOOKMARKS = "bookmarks"; public static final String BOOKMARKS_FILE = "bookmarks_v2.5"; public BookmarksHelper(Activity activity) { mContext = activity; refreshBookmarkCache(); } public void addBookmark(final String path) { new Thread(new Runnable() { @Override public void run() { final String bookmarkCsv = mContext.getSharedPreferences( BOOKMARKS_FILE, Context.MODE_PRIVATE).getString( BOOKMARKS, ""); StringTokenizer tokens = new StringTokenizer(bookmarkCsv, "\n"); boolean found = false; while (tokens.hasMoreTokens()) { String bookmark = tokens.nextToken(); if (bookmark != null && bookmark.equalsIgnoreCase(path)) { found = true; break; } } if (!found) { SharedPreferences.Editor editor = mContext .getSharedPreferences(BOOKMARKS_FILE, Context.MODE_PRIVATE).edit(); editor.putString(BOOKMARKS, bookmarkCsv + "\n" + path); editor.commit(); refreshBookmarkCache(); mContext.runOnUiThread(new Runnable() { @Override public void run() { if(mContext instanceof BookmarkListActivity) { BookmarkListActivity bookmarkListActivity = (BookmarkListActivity)mContext; bookmarkListActivity.refresh(); } } }); } } }).start(); } public List<FileListEntry> getBookmarks() { String bookmarkCsv = mContext.getSharedPreferences(BOOKMARKS_FILE, Context.MODE_PRIVATE).getString(BOOKMARKS, ""); StringTokenizer tokens = new StringTokenizer(bookmarkCsv, "\n"); List<FileListEntry> files = new ArrayList<FileListEntry>(); while (tokens.hasMoreTokens()) { String bookmark = tokens.nextToken(); File dir = new File(bookmark); if (dir.exists() && dir.isDirectory()) { FileListEntry entry = new FileListEntry(bookmark); files.add(entry); } } return files; } public boolean isBookmarked(String path) { return bookmarkedPaths.contains(path); } private void refreshBookmarkCache() { String bookmarkCsv = mContext.getSharedPreferences(BOOKMARKS_FILE, Context.MODE_PRIVATE).getString(BOOKMARKS, ""); StringTokenizer tokens = new StringTokenizer(bookmarkCsv, "\n"); bookmarkedPaths.clear(); while (tokens.hasMoreTokens()) { String bookmark = tokens.nextToken(); File dir = new File(bookmark); if (dir.exists() && dir.isDirectory()) { synchronized (bookmarkedPaths) { bookmarkedPaths.add(bookmark); } } } } public void removeBookmark(final String path) { AsyncTask<String, String, String> task = new AsyncTask<String, String, String>(){ @Override protected String doInBackground(String... strings) { String bookmarkCsv = mContext.getSharedPreferences( BOOKMARKS_FILE, Context.MODE_PRIVATE).getString( BOOKMARKS, ""); StringTokenizer tokens = new StringTokenizer(bookmarkCsv, "\n"); final StringBuffer buffer = new StringBuffer(); while (tokens.hasMoreTokens()) { String bookmark = tokens.nextToken(); if (bookmark != null && !bookmark.equals(path)) { buffer.append("\n"); buffer.append(bookmark); } } SharedPreferences.Editor editor = mContext .getSharedPreferences(BOOKMARKS_FILE, Context.MODE_PRIVATE).edit(); editor.putString(BOOKMARKS, buffer.toString()); editor.commit(); refreshBookmarkCache(); mContext.runOnUiThread(new Runnable() { @Override public void run() { if(mContext instanceof BookmarkListActivity) { BookmarkListActivity bookmarkListActivity = (BookmarkListActivity)mContext; bookmarkListActivity.refresh(); } } }); return null; } }.execute(); } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/util/BookmarksHelper.java
Java
gpl3
5,004
package net.appositedesigns.fileexplorer.util; import java.util.Comparator; import net.appositedesigns.fileexplorer.activity.BaseFileListActivity; import net.appositedesigns.fileexplorer.activity.FileListActivity; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.util.PreferenceHelper.SortField; public class FileListSorter implements Comparator<FileListEntry> { private BaseFileListActivity mContext; private boolean dirsOnTop = false; private SortField sortField; private int dir; public FileListSorter(BaseFileListActivity context){ mContext = context; PreferenceHelper util = new PreferenceHelper(mContext); dirsOnTop = util.isShowDirsOnTop(); sortField = util.getSortField(); dir = util.getSortDir(); } @Override public int compare(FileListEntry file1, FileListEntry file2) { if(dirsOnTop) { if(file1.getPath().isDirectory() && file2.getPath().isFile()) { return -1; } else if(file2.getPath().isDirectory() && file1.getPath().isFile()) { return 1; } } switch (sortField) { case NAME: return dir * file1.getName().compareToIgnoreCase(file2.getName()); case MTIME: return dir * file1.getLastModified().compareTo(file2.getLastModified()); case SIZE: return dir * Long.valueOf(file1.getSize()).compareTo(file2.getSize()); default: break; } return 0; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/util/FileListSorter.java
Java
gpl3
1,484
package net.appositedesigns.fileexplorer.util; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; import net.appositedesigns.fileexplorer.FileExplorerApp; import net.appositedesigns.fileexplorer.exception.LocationInvalidException; import java.io.File; public final class PreferenceHelper { public enum SortField { NAME, MTIME, SIZE } private Activity mContext; public static final String EULA_ACCEPTED = "eula_accepted_v2.5"; public static final String EULA_MARKER = "eula_marker_file_v2.5"; public static final String PREF_HOME_DIR = "homeDir"; public static final String PREF_SDCARD_OPTIONS = "sdCardOptions"; public static final String PREF_SHOW_DIR_SIZES = "showDirSizes"; public static final String PREF_SHOW_DIRS_FIRST = "showDirsFirst"; public static final String PREF_SHOW_HIDDEN = "showHidden"; public static final String PREF_SHOW_SYSFILES = "showSysFiles"; public static final String PREF_SORT_DIR = "sort.dir"; public static final String PREF_SORT_FIELD = "sort.field"; public static final String PREF_THEME = "theme"; public static final String PREF_USE_BACK_BUTTON = "useBackButton"; private static final String PREF_NAVIGATE_FOCUS_ON_PARENT = "focusOnParent"; public static final String PREF_USE_QUICKACTIONS = "useQuickActions"; public static final String PREF_ZIP_ENABLE = "zipEnable"; public static final String PREF_ZIP_USE_ZIP_FOLDER = "useZipFolder"; public static final String PREF_ZIP_LOCATION = "zipLocation"; public static final String PREF_MEDIA_EXCLUSIONS = "media_exclusions"; public static final String VALUE_SORT_DIR_ASC = "asc"; public static final String VALUE_SORT_DIR_DESC = "desc"; public static final String VALUE_SORT_FIELD_M_TIME = "mtime"; public static final String VALUE_SORT_FIELD_NAME = "name"; public static final String VALUE_SORT_FIELD_SIZE = "size"; public static final String VALUE_THEME_BLACK = "theme_black"; public static final String VALUE_THEME_WHITE = "theme_white"; public static final String VALUE_THEME_WHITE_BLACK = "theme_white_black"; public PreferenceHelper(Activity context) { mContext = context; } public boolean isShowDirsOnTop() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_SHOW_DIRS_FIRST, true); } public boolean isShowHidden() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_SHOW_HIDDEN, false); } public boolean useBackNavigation() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_USE_BACK_BUTTON, false); } public boolean useQuickActions() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_USE_QUICKACTIONS, true); } public SortField getSortField() { String field = PreferenceManager.getDefaultSharedPreferences(mContext) .getString(PREF_SORT_FIELD, VALUE_SORT_FIELD_NAME); if (VALUE_SORT_FIELD_NAME.equalsIgnoreCase(field)) { return SortField.NAME; } else if (VALUE_SORT_FIELD_M_TIME.equalsIgnoreCase(field)) { return SortField.MTIME; } else if (VALUE_SORT_FIELD_SIZE.equalsIgnoreCase(field)) { return SortField.SIZE; } else { return SortField.NAME; } } public int getSortDir() { String field = PreferenceManager.getDefaultSharedPreferences(mContext) .getString(PREF_SORT_DIR, "asc"); if (VALUE_SORT_DIR_ASC.equalsIgnoreCase(field)) { return 1; } else { return -1; } } public File getStartDir() { String dirPath = PreferenceManager .getDefaultSharedPreferences(mContext).getString(PREF_HOME_DIR, "/"); File homeDir = new File(dirPath); if (homeDir.exists() && homeDir.isDirectory()) { return homeDir; } else { return new File("/"); } } public boolean isShowSystemFiles() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_SHOW_SYSFILES, true); } public File getZipDestinationDir() throws LocationInvalidException { String dirPath = PreferenceManager .getDefaultSharedPreferences(mContext).getString( PREF_ZIP_LOCATION, "/sdcard/zipped"); Boolean useZipFolder = PreferenceManager.getDefaultSharedPreferences( mContext).getBoolean(PREF_ZIP_USE_ZIP_FOLDER, false); if (!useZipFolder) { return null; } File dir = new File(dirPath); if (dir.exists() && dir.isDirectory()) { return dir; } else if (!dir.exists()) { dir.mkdirs(); return dir; } else { throw new LocationInvalidException(dirPath); } } public boolean isEnableSdCardOptions() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_SDCARD_OPTIONS, true); } public boolean focusOnParent() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_NAVIGATE_FOCUS_ON_PARENT, true); } public boolean isZipEnabled() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_ZIP_ENABLE, false); } public boolean isMediaExclusionEnabled() { return PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(PREF_MEDIA_EXCLUSIONS, false); } public boolean isEulaAccepted() { return mContext.getSharedPreferences(EULA_MARKER, Context.MODE_PRIVATE) .getBoolean(EULA_ACCEPTED, false); } public void markEulaAccepted() { SharedPreferences.Editor editor = mContext.getSharedPreferences( EULA_MARKER, Context.MODE_PRIVATE).edit(); editor.putBoolean(EULA_ACCEPTED, true); editor.commit(); } public int getTheme() { return FileExplorerApp.THEME_WHITE; /* String theme = PreferenceManager.getDefaultSharedPreferences(mContext) .getString(PREF_THEME, VALUE_THEME_WHITE); if (VALUE_THEME_BLACK.equalsIgnoreCase(theme)) { return FileExplorerApp.THEME_BLACK; } else if (VALUE_THEME_WHITE_BLACK.equalsIgnoreCase(theme)) { return FileExplorerApp.THEME_WHITE_BLACK; } else { return FileExplorerApp.THEME_WHITE; } */ } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/util/PreferenceHelper.java
Java
gpl3
6,190
package net.appositedesigns.fileexplorer.util; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; /** * The class provides the utility method to zip files or folders uses * java.util.zip package underneath */ public class ZipUtil { static public void zipFolder(String srcFolder, String destZipFile, AbortionFlag flag) throws Exception { if (flag.isAborted()) { return; } ZipOutputStream zip = null; FileOutputStream fileWriter = null; try { fileWriter = new FileOutputStream(destZipFile); zip = new ZipOutputStream(fileWriter); addFolderToZip("", srcFolder, flag, zip); } finally { zip.flush(); zip.close(); } } static public void zipFile(String srcFile, String destZipFile, AbortionFlag flag) throws Exception { if (flag.isAborted()) { return; } ZipOutputStream zip = null; FileOutputStream fileWriter = null; try { fileWriter = new FileOutputStream(destZipFile); zip = new ZipOutputStream(fileWriter); addFileToZip("", srcFile, flag, zip); } finally { zip.flush(); zip.close(); } } static private void addFileToZip(String path, String srcFile, AbortionFlag flag, ZipOutputStream zip) throws Exception { if (flag.isAborted()) { return; } File folder = new File(srcFile); if (folder.isDirectory()) { addFolderToZip(path, srcFile, flag, zip); } else { byte[] buf = new byte[1024]; int len; FileInputStream in = new FileInputStream(srcFile); zip.putNextEntry(new ZipEntry(path + "/" + folder.getName())); while ((len = in.read(buf)) > 0) { zip.write(buf, 0, len); } } } static private void addFolderToZip(String path, String srcFolder, AbortionFlag flag, ZipOutputStream zip) throws Exception { if (flag.isAborted()) { return; } File folder = new File(srcFolder); for (String fileName : folder.list()) { if (path.equals("")) { addFileToZip(folder.getName(), srcFolder + "/" + fileName, flag, zip); } else { addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, flag, zip); } } } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/util/ZipUtil.java
Java
gpl3
2,306
package net.appositedesigns.fileexplorer.model; import java.util.List; public class FileListing { private List<FileListEntry> children; private boolean isExcludeFromMedia = false; public List<FileListEntry> getChildren() { return children; } public void setChildren(List<FileListEntry> children) { this.children = children; } public boolean isExcludeFromMedia() { return isExcludeFromMedia; } public void setExcludeFromMedia(boolean isExcludeFromMedia) { this.isExcludeFromMedia = isExcludeFromMedia; } public FileListing(List<FileListEntry> children) { super(); this.children = children; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/model/FileListing.java
Java
gpl3
654
package net.appositedesigns.fileexplorer.activity; import android.app.ActionBar; import android.app.ActionBar.OnNavigationListener; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.ActionMode; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.webkit.MimeTypeMap; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import net.appositedesigns.fileexplorer.FileExplorerApp; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.adapters.FileListAdapter; import net.appositedesigns.fileexplorer.callbacks.CancellationCallback; import net.appositedesigns.fileexplorer.callbacks.FileActionsCallback; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.model.FileListing; import net.appositedesigns.fileexplorer.util.FileActionsHelper; import net.appositedesigns.fileexplorer.util.Util; import net.appositedesigns.fileexplorer.workers.FileMover; import net.appositedesigns.fileexplorer.workers.Finder; import org.apache.commons.io.FileUtils; import java.io.File; import java.util.ArrayList; import java.util.List; public class FileListActivity extends BaseFileListActivity { private static final String TAG = FileListActivity.class.getName(); private static final String CURRENT_DIR_DIR = "current-dir"; private ListView explorerListView; private File currentDir; private List<FileListEntry> files; private FileListAdapter adapter; protected Object mCurrentActionMode; private ArrayAdapter<CharSequence> mSpinnerAdapter; private CharSequence[] gotoLocations; private boolean isPicker = false; private FileExplorerApp app; private File previousOpenDirChild; private boolean focusOnParent; private boolean excludeFromMedia = false; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { app = (FileExplorerApp)getApplication(); isPicker = getIntent().getBooleanExtra(FileExplorerApp.EXTRA_IS_PICKER, false); if(Intent.ACTION_GET_CONTENT.equals(getIntent().getAction())) { isPicker = true; app.setFileAttachIntent(getIntent()); } initUi(); initGotoLocations(); super.onCreate(savedInstanceState); setContentView(R.layout.main); prepareActionBar(); initRootDir(savedInstanceState); files = new ArrayList<FileListEntry>(); initFileListView(); focusOnParent = getPreferenceHelper().focusOnParent(); if (getPreferenceHelper().isEulaAccepted()) { listContents(currentDir); } else { EulaPopupBuilder.create(this).show(); } } private void initUi() { if(isPicker) { getWindow().setUiOptions(0); } } private void initGotoLocations() { gotoLocations = getResources().getStringArray(R.array.goto_locations); } private void initFileListView() { explorerListView = (ListView) getListView(); adapter = new FileListAdapter(this, files); explorerListView.setAdapter(adapter); explorerListView.setTextFilterEnabled(true); explorerListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (explorerListView.isClickable()) { FileListEntry file = (FileListEntry) explorerListView .getAdapter().getItem(position); select(file.getPath()); } } }); explorerListView.setOnItemLongClickListener(getLongPressListener()); registerForContextMenu(explorerListView); } private OnItemLongClickListener getLongPressListener() { return new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, final View view, int arg2, long arg3) { if(!explorerListView.isLongClickable()) return true; if(isPicker) { return false; } view.setSelected(true); final FileListEntry fileListEntry = (FileListEntry) adapter .getItem(arg2); if (mCurrentActionMode != null) { return false; } if (Util.isProtected(fileListEntry .getPath())) { return false; } explorerListView.setEnabled(false); mCurrentActionMode = FileListActivity.this .startActionMode(new FileActionsCallback( FileListActivity.this, fileListEntry) { @Override public void onDestroyActionMode( ActionMode mode) { view.setSelected(false); mCurrentActionMode = null; explorerListView.setEnabled(true); } }); view.setSelected(true); return true; } }; } private void initRootDir(Bundle savedInstanceState) { // If app was restarted programmatically, find where the user last left // it String restartDirPath = getIntent().getStringExtra(FileExplorerApp.EXTRA_FOLDER); if (restartDirPath != null) { File restartDir = new File(restartDirPath); if (restartDir.exists() && restartDir.isDirectory()) { currentDir = restartDir; getIntent().removeExtra(FileExplorerApp.EXTRA_FOLDER); } } else if (savedInstanceState!=null && savedInstanceState.getSerializable(CURRENT_DIR_DIR) != null) { currentDir = new File(savedInstanceState .getSerializable(CURRENT_DIR_DIR).toString()); } else { currentDir = getPreferenceHelper().getStartDir(); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(CURRENT_DIR_DIR, currentDir.getAbsolutePath()); } private void prepareActionBar() { final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mSpinnerAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_dropdown_item, gotoLocations); actionBar.setListNavigationCallbacks(mSpinnerAdapter, getActionbarListener(actionBar)); } private OnNavigationListener getActionbarListener(final ActionBar actionBar) { return new OnNavigationListener() { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { int selectedIndex = actionBar.getSelectedNavigationIndex(); if(selectedIndex == 0) { return false; } switch (selectedIndex) { case 1: listContents(getPreferenceHelper().getStartDir()); break; case 2: listContents(new File("/sdcard")); break; case 3: listContents(Util.getDownloadsFolder()); break; case 4: listContents(Util.getDcimFolder()); break; case 5: openBookmarks(actionBar); break; case 6: Util.gotoPath(currentDir.getAbsolutePath(), FileListActivity.this, new CancellationCallback() { @Override public void onCancel() { actionBar.setSelectedNavigationItem(0); } }); break; default: break; } return true; } }; } private void openBookmarks(final ActionBar actionBar) { Intent intent = new Intent(); intent.setAction(FileExplorerApp.ACTION_OPEN_BOOKMARK); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(FileExplorerApp.EXTRA_IS_PICKER, isPicker); actionBar.setSelectedNavigationItem(0); startActivityForResult(intent, FileExplorerApp.REQ_PICK_BOOKMARK); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case FileExplorerApp.REQ_PICK_BOOKMARK: if(resultCode == RESULT_OK) { String selectedBookmark = data.getStringExtra(FileExplorerApp.EXTRA_SELECTED_BOOKMARK); listContents(new File(selectedBookmark)); } break; default: break; } } @Override protected void onResume() { super.onResume(); if (shouldRestartApp) { shouldRestartApp = false; restartApp(); } } @Override public void onBackPressed() { if(isPicker) { super.onBackPressed(); return; } if (getPreferenceHelper().useBackNavigation()) { if (Util.isRoot(currentDir)) { finish(); } else { gotoParent(); } } else { super.onBackPressed(); } } void select(File file) { if (Util.isProtected(file)){ new Builder(this) .setTitle(getString(R.string.access_denied)) .setMessage( getString(R.string.cant_open_dir, file.getName())) .show(); } else if (file.isDirectory()) { listContents(file); } else { doFileAction(file); } } private void doFileAction(File file) { if (Util.isProtected(file) || file.isDirectory()) { return; } if(isPicker) { pickFile(file); return; } else { openFile(file); return; } } private void openFile(File file) { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension( MimeTypeMap.getFileExtensionFromUrl(uri.toString())); intent.setDataAndType(uri, type == null ? "*/*" : type); startActivity((Intent.createChooser(intent, getString(R.string.open_using)))); } private void pickFile(File file) { Intent fileAttachIntent = app.getFileAttachIntent(); fileAttachIntent.setData(Uri.fromFile(file)); setResult(Activity.RESULT_OK, fileAttachIntent); finish(); return; } public void listContents(File dir) { listContents(dir, null); } public void listContents(File dir, File previousOpenDirChild) { if (!dir.isDirectory() || Util.isProtected(dir)) { return; } if(previousOpenDirChild!=null) { this.previousOpenDirChild = new File(previousOpenDirChild.getAbsolutePath()); } else { this.previousOpenDirChild = null; } new Finder(this).execute(dir); } private void gotoParent() { if (Util.isRoot(currentDir)) { // Do nothing finish(); } else { listContents(currentDir.getParentFile(), currentDir); } } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); if(isPicker) { inflater.inflate(R.menu.picker_options_menu, menu); } else { inflater.inflate(R.menu.options_menu, menu); } return true; } @Override public boolean onPrepareOptionsMenu(Menu menu) { if(!isPicker) { if(getPreferenceHelper().isMediaExclusionEnabled()) { menu.findItem(R.id.menu_media_exclusion).setVisible(true); menu.findItem(R.id.menu_media_exclusion).setChecked(excludeFromMedia); } else { menu.findItem(R.id.menu_media_exclusion).setVisible(false); } menu.findItem(R.id.menu_bookmark_toggle).setChecked(bookmarker.isBookmarked(currentDir.getAbsolutePath())); if (Util.canPaste(currentDir)) { menu.findItem(R.id.menu_paste).setVisible(true); } else { menu.findItem(R.id.menu_paste).setVisible(false); } } return super.onPrepareOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case android.R.id.home: gotoParent(); return true; case R.id.menu_cancel: setResult(RESULT_CANCELED); finish(); return true; case R.id.menu_bookmark_toggle: boolean setBookmark = item.isChecked(); item.setChecked(!setBookmark); if(!setBookmark) { bookmarker.addBookmark(currentDir.getAbsolutePath()); } else { bookmarker.removeBookmark(currentDir.getAbsolutePath()); } return true; case R.id.menu_media_exclusion: item.setChecked(!excludeFromMedia); setMediaExclusionForFolder(); return true; case R.id.menu_goto: Util.gotoPath(currentDir.getAbsolutePath(), this); return true; case R.id.menu_paste: confirmPaste(); return true; case R.id.menu_refresh: refresh(); return true; case R.id.menu_newfolder: confirmCreateFolder(); return true; case R.id.menu_settings: Intent prefsIntent = new Intent(FileListActivity.this, SettingsActivity.class); startActivity(prefsIntent); return true; default: super.onOptionsItemSelected(item); break; } return true; } private void setMediaExclusionForFolder() { if(excludeFromMedia) { //Now include folder in media FileUtils.deleteQuietly(new File(currentDir, ".nomedia")); excludeFromMedia = false; } else { try { FileUtils.touch(new File(currentDir, ".nomedia")); excludeFromMedia = true; } catch(Exception e) { Log.e(TAG, "Error occurred while creating .nomedia file", e); } } FileActionsHelper.rescanMedia(this); refresh(); } private void confirmPaste() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getString(R.string.confirm)); alert.setMessage(getString(R.string.confirm_paste_text, Util.getFileToPaste().getName())); alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); new FileMover(FileListActivity.this, Util .getPasteMode()).execute(currentDir); } }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); alert.show(); } private void confirmCreateFolder() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getString(R.string.create_folder)); // Set an EditText view to get user input final EditText input = new EditText(this); input.setHint(getString(R.string.enter_folder_name)); input.setSingleLine(); alert.setView(input); alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { CharSequence newDir = input.getText(); if (Util.mkDir( currentDir.getAbsolutePath(), newDir)) { listContents(currentDir); } } }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); alert.show(); } public synchronized void setCurrentDirAndChilren(File dir, FileListing folderListing) { currentDir = dir; List<FileListEntry> children = folderListing.getChildren(); excludeFromMedia = folderListing.isExcludeFromMedia(); TextView emptyText = (TextView) findViewById(android.R.id.empty); if (emptyText != null) { emptyText.setText(R.string.empty_folder); } files.clear(); files.addAll(children); adapter.notifyDataSetChanged(); getActionBar().setSelectedNavigationItem(0); if(Util.isRoot(currentDir)) { gotoLocations[0] = getString(R.string.filesystem); } else { gotoLocations[0] = currentDir.getName(); } if(previousOpenDirChild!=null && focusOnParent) { int position = files.indexOf(new FileListEntry(previousOpenDirChild.getAbsolutePath())); if(position>=0) explorerListView.setSelection(position); } else { explorerListView.setSelection(0); } mSpinnerAdapter.notifyDataSetChanged(); ActionBar ab = getActionBar(); ab.setSelectedNavigationItem(0); ab.setSubtitle(getString(R.string.item_count_subtitle, children.size())); if(Util.isRoot(currentDir) || currentDir.getParentFile()==null) { ab.setDisplayHomeAsUpEnabled(false); ab.setTitle(getString(R.string.filesystem)); } else { ab.setTitle(currentDir.getName()); ab.setDisplayHomeAsUpEnabled(true); } } public void refresh() { listContents(currentDir); } private void restartApp() { Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.putExtra(FileExplorerApp.EXTRA_FOLDER, currentDir.getAbsolutePath()); startActivity(i); } public boolean isInPickMode() { return isPicker; } public File getCurrentDir() { return currentDir; } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/activity/FileListActivity.java
Java
gpl3
16,569
package net.appositedesigns.fileexplorer.activity; import android.content.Intent; import android.os.Bundle; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.view.MenuItem; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.util.FileActionsHelper; import net.appositedesigns.fileexplorer.util.PreferenceHelper; import java.util.List; public class SettingsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { setTheme(new PreferenceHelper(this).getTheme()); super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); } @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()== android.R.id.home) { onBackPressed(); return true; } else { return false; } } /** * Populate the activity with the top-level headers. */ @Override public void onBuildHeaders(List<Header> target) { loadHeadersFromResource(R.xml.prefs, target); } public static class NavigationPreferences extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.nav_prefs); } } public static class GeekyPreferences extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.geeky_prefs); Preference rescan = findPreference("pref_opt_rescan"); rescan.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { FileActionsHelper.rescanMedia(GeekyPreferences.this.getActivity()); return true; } }); } } public static class ViewPreferences extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.view_prefs); } } public static class AboutPreferences extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.about_prefs); Preference share = (Preference)findPreference("pref_opt_share"); share.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); String text = getString(R.string.share_text); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_SUBJECT, "FileExplorer"); startActivity(Intent.createChooser(intent, getString(R.string.share_via))); return true; } }); } } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/activity/SettingsActivity.java
Java
gpl3
3,276
package net.appositedesigns.fileexplorer.activity; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import net.appositedesigns.fileexplorer.FileExplorerApp; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.adapters.BookmarkListAdapter; import net.appositedesigns.fileexplorer.model.FileListEntry; import net.appositedesigns.fileexplorer.util.PreferenceHelper; import net.appositedesigns.fileexplorer.workers.BookmarkLoader; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.InputType; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; public class BookmarkListActivity extends BaseFileListActivity { protected static final String TAG = BookmarkListActivity.class.getName(); private BookmarkListAdapter adapter; private ArrayList<FileListEntry> bookmarks; private ListView bookmarkListView; private boolean isPicker = false; @Override protected void onCreate(Bundle savedInstanceState) { setTheme(new PreferenceHelper(this).getTheme()); super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.main); isPicker = getIntent().getBooleanExtra(FileExplorerApp.EXTRA_IS_PICKER, false); bookmarks = new ArrayList<FileListEntry>(); initBookmarksList(); refresh(); bookmarkListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub return false; } }); bookmarkListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long id) { if(!isPicker) { FileListEntry bookmark = (FileListEntry)bookmarkListView.getAdapter().getItem(position); removeBookmark(bookmark); return true; } return false; } }); registerForContextMenu(bookmarkListView); } protected void removeBookmark(final FileListEntry bookmark) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true); builder.setMessage(getString(R.string.confirm_remove_bookmark, bookmark.getName())) .setCancelable(false) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { bookmarker.removeBookmark(bookmark.getPath().getAbsolutePath()); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setTitle(R.string.confirm); AlertDialog confirm = builder.create(); confirm.show(); } @Override public boolean onCreateOptionsMenu(Menu menu) { if(!isPicker) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.bookmarks_options_menu, menu); return true; } return false; } private void initBookmarksList() { bookmarkListView = (ListView) getListView(); adapter = new BookmarkListAdapter(this, bookmarks); bookmarkListView.setAdapter(adapter); bookmarkListView.setTextFilterEnabled(true); bookmarkListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (bookmarkListView.isClickable()) { FileListEntry file = (FileListEntry) bookmarkListView .getAdapter().getItem(position); select(file.getPath()); } } }); } protected void select(File path) { Intent intent = new Intent(); intent.putExtra(FileExplorerApp.EXTRA_SELECTED_BOOKMARK, path.getAbsolutePath()); intent.putExtra(FileExplorerApp.EXTRA_IS_PICKER, isPicker); setResult(Activity.RESULT_OK, intent); finish(); } @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()== android.R.id.home) { onBackPressed(); return true; } else if(R.id.menu_settings == item.getItemId()) { Intent prefsIntent = new Intent(this, SettingsActivity.class); startActivity(prefsIntent); return true; } else if(R.id.menu_add_bookmark == item.getItemId()) { promptBookmarkPath(); return true; } return false; } private void promptBookmarkPath() { final EditText input = new EditText(this); input.setSingleLine(); input.setHint(getString(R.string.add_bookmark_prompt_hint)); input.setInputType(InputType.TYPE_TEXT_VARIATION_URI); new Builder(this) .setTitle(getString(R.string.add_bookmark_prompt)) .setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { CharSequence bookmarkPath = input.getText(); try { File toDir = new File(bookmarkPath.toString()); if(toDir.isDirectory() && toDir.exists()) { bookmarker.addBookmark(bookmarkPath.toString()); } else { throw new FileNotFoundException(); } } catch (Exception e) { Log.e(TAG, "Error bookmarking path"+bookmarkPath, e); new Builder(BookmarkListActivity.this) .setTitle(getString(R.string.error)) .setMessage(getString(R.string.path_not_exist)) .show(); } } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }) .show(); } public void setBookmarks(List<FileListEntry> childFiles) { TextView emptyText = (TextView) findViewById(android.R.id.empty); if (emptyText != null) { emptyText.setText(R.string.no_bookmarks); } bookmarks.clear(); bookmarks.addAll(childFiles); adapter.notifyDataSetChanged(); } public void refresh() { new BookmarkLoader(this).execute(); } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/activity/BookmarkListActivity.java
Java
gpl3
6,757
package net.appositedesigns.fileexplorer.activity; import net.appositedesigns.fileexplorer.util.BookmarksHelper; import net.appositedesigns.fileexplorer.util.PreferenceHelper; import android.app.ListActivity; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.preference.PreferenceManager; public abstract class BaseFileListActivity extends ListActivity { protected PreferenceHelper prefs; protected BookmarksHelper bookmarker; private OnSharedPreferenceChangeListener listener; protected boolean shouldRestartApp = false; @Override protected void onCreate(Bundle savedInstanceState) { prefs = new PreferenceHelper(this); bookmarker = new BookmarksHelper(this); setTheme(prefs.getTheme()); super.onCreate(savedInstanceState); listenToThemeChange(); } private void listenToThemeChange() { listener = new OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged( SharedPreferences sharedPreferences, String key) { if (PreferenceHelper.PREF_THEME.equals(key)) { shouldRestartApp = true; } if (PreferenceHelper.PREF_USE_QUICKACTIONS.equals(key)) { shouldRestartApp = true; } } }; PreferenceManager.getDefaultSharedPreferences(this) .registerOnSharedPreferenceChangeListener(listener); } public synchronized PreferenceHelper getPreferenceHelper() { return prefs; } public BookmarksHelper getBookmarker() { return bookmarker; } @Override protected void onDestroy() { super.onDestroy(); PreferenceManager.getDefaultSharedPreferences(this) .unregisterOnSharedPreferenceChangeListener(listener); } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/activity/BaseFileListActivity.java
Java
gpl3
1,804
package net.appositedesigns.fileexplorer.activity; import net.appositedesigns.fileexplorer.R; import net.appositedesigns.fileexplorer.R.string; import net.appositedesigns.fileexplorer.util.PreferenceHelper; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.text.SpannableString; import android.text.method.LinkMovementMethod; import android.text.util.Linkify; import android.widget.TextView; public class EulaPopupBuilder { public static AlertDialog create(final FileListActivity context) { final TextView message = new TextView(context); final SpannableString s = new SpannableString( context.getText(R.string.eula_popup_text)); Linkify.addLinks(s, Linkify.WEB_URLS); message.setText(s); message.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(context) .setTitle(R.string.eula_popup_title).setCancelable(false) .setPositiveButton(R.string.eula_accept, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new PreferenceHelper(context).markEulaAccepted(); dialog.dismiss(); context.refresh(); } }) .setNegativeButton(R.string.eula_decline, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { context.finish(); } }) .setView(message).create(); } }
10130088-thanhthuy
src/net/appositedesigns/fileexplorer/activity/EulaPopupBuilder.java
Java
gpl3
1,520
@{ Layout = "~/Views/Shared/_Layout.cshtml"; }
08102013project
trunk/FrontEnd/Views/_ViewStart.cshtml
HTML+Razor
oos
55
@{ ViewBag.Title = "About Us"; } <h2>About</h2> <p> Put content here. </p>
08102013project
trunk/FrontEnd/Views/Home/About.cshtml
HTML+Razor
oos
96
@{ ViewBag.Title = "Home Page"; } <h2>@ViewBag.Message</h2> <p> To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>. </p>
08102013project
trunk/FrontEnd/Views/Home/Index.cshtml
HTML+Razor
oos
208
<!DOCTYPE html> <html> <head> <title>@ViewBag.Title</title> <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/jquery-1.8.3.min.js")" type="text/javascript"></script> </head> <body> <div class="page"> <div id="header"> <div id="title"> <h1>My MVC Application</h1> </div> <div id="logindisplay"> @*@Html.Partial("_LogOnPartial")*@ </div> <div id="menucontainer"> <ul id="menu"> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("About", "About", "Home")</li> </ul> </div> </div> <div id="main"> @RenderBody() </div> <div id="footer"> </div> </div> </body> </html>
08102013project
trunk/FrontEnd/Views/Shared/_Layout.cshtml
HTML+Razor
oos
945
@if(Request.IsAuthenticated) { <text>Welcome <strong>@User.Identity.Name</strong>! [ @Html.ActionLink("Log Off", "LogOff", "Account") ]</text> } else { @:[ @Html.ActionLink("Log On", "LogOn", "Account") ] }
08102013project
trunk/FrontEnd/Views/Shared/_LogOnPartial.cshtml
HTML+Razor
oos
229
@model System.Web.Mvc.HandleErrorInfo @{ ViewBag.Title = "Error"; } <h2> Sorry, an error occurred while processing your request. </h2>
08102013project
trunk/FrontEnd/Views/Shared/Error.cshtml
HTML+Razor
oos
157
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace ECommerceMvcApplication.Controllers { public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; return View(); } public ActionResult About() { return View(); } } }
08102013project
trunk/FrontEnd/Controllers/HomeController.cs
C#
oos
466
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Web.Mvc; using System.Web.Security; namespace ECommerceMvcApplication.Models { public class ChangePasswordModel { [Required] [DataType(DataType.Password)] [Display(Name = "Current password")] public string OldPassword { get; set; } [Required] [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] [DataType(DataType.Password)] [Display(Name = "New password")] public string NewPassword { get; set; } [DataType(DataType.Password)] [Display(Name = "Confirm new password")] [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] public string ConfirmPassword { get; set; } } public class LogOnModel { [Required] [Display(Name = "User name")] public string UserName { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [Display(Name = "Remember me?")] public bool RememberMe { get; set; } } public class RegisterModel { [Required] [Display(Name = "User name")] public string UserName { get; set; } [Required] [DataType(DataType.EmailAddress)] [Display(Name = "Email address")] public string Email { get; set; } [Required] [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [DataType(DataType.Password)] [Display(Name = "Confirm password")] [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] public string ConfirmPassword { get; set; } } }
08102013project
trunk/FrontEnd/Models/AccountModels.cs
C#
oos
2,142
<%@ Application Codebehind="Global.asax.cs" Inherits="ECommerceMvcApplication.MvcApplication" Language="C#" %>
08102013project
trunk/FrontEnd/Global.asax
ASP.NET
oos
115
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("ECommerceMvcApplication")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("ECommerceMvcApplication")] [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("e2090cc6-1c2f-464f-aa49-a3dbc9031d65")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
08102013project
trunk/FrontEnd/Properties/AssemblyInfo.cs
C#
oos
1,435
/*---------------------------------------------------------- The base color for this template is #5c87b2. If you'd like to use a different color start by replacing all instances of #5c87b2 with your new color. ----------------------------------------------------------*/ body { background-color: #5c87b2; font-size: .85em; font-family: "Trebuchet MS", Verdana, Helvetica, Sans-Serif; margin: 0; padding: 0; color: #696969; } a:link { color: #034af3; text-decoration: underline; } a:visited { color: #505abc; } a:hover { color: #1d60ff; text-decoration: none; } a:active { color: #12eb87; } p, ul { margin-bottom: 20px; line-height: 1.6em; } header, footer, nav, section { display: block; } /* HEADINGS ----------------------------------------------------------*/ h1, h2, h3, h4, h5, h6 { font-size: 1.5em; color: #000; } h1 { font-size: 2em; padding-bottom: 0; margin-bottom: 0; } h2 { padding: 0 0 10px 0; } h3 { font-size: 1.2em; } h4 { font-size: 1.1em; } h5, h6 { font-size: 1em; } /* PRIMARY LAYOUT ELEMENTS ----------------------------------------------------------*/ /* you can specify a greater or lesser percentage for the page width. Or, you can specify an exact pixel width. */ .page { width: 90%; margin-left: auto; margin-right: auto; } header, #header { position: relative; margin-bottom: 0px; color: #000; padding: 0; } header h1, #header h1 { font-weight: bold; padding: 5px 0; margin: 0; color: #fff; border: none; line-height: 2em; font-size: 32px !important; text-shadow: 1px 1px 2px #111; } #main { padding: 30px 30px 15px 30px; background-color: #fff; border-radius: 4px 0 0 0; -webkit-border-radius: 4px 0 0 0; -moz-border-radius: 4px 0 0 0; } footer, #footer { background-color: #fff; color: #999; padding: 10px 0; text-align: center; line-height: normal; margin: 0 0 30px 0; font-size: .9em; border-radius: 0 0 4px 4px; -webkit-border-radius: 0 0 4px 4px; -moz-border-radius: 0 0 4px 4px; } /* TAB MENU ----------------------------------------------------------*/ ul#menu { border-bottom: 1px #5C87B2 solid; padding: 0 0 2px; position: relative; margin: 0; text-align: right; } ul#menu li { display: inline; list-style: none; } ul#menu li#greeting { padding: 10px 20px; font-weight: bold; text-decoration: none; line-height: 2.8em; color: #fff; } ul#menu li a { padding: 10px 20px; font-weight: bold; text-decoration: none; line-height: 2.8em; background-color: #e8eef4; color: #034af3; border-radius: 4px 4px 0 0; -webkit-border-radius: 4px 4px 0 0; -moz-border-radius: 4px 4px 0 0; } ul#menu li a:hover { background-color: #fff; text-decoration: none; } ul#menu li a:active { background-color: #a6e2a6; text-decoration: none; } ul#menu li.selected a { background-color: #fff; color: #000; } /* FORM LAYOUT ELEMENTS ----------------------------------------------------------*/ fieldset { border: 1px solid #ddd; padding: 0 1.4em 1.4em 1.4em; margin: 0 0 1.5em 0; } legend { font-size: 1.2em; font-weight: bold; } textarea { min-height: 75px; } input[type="text"], input[type="password"] { border: 1px solid #ccc; padding: 2px; font-size: 1.2em; color: #444; width: 200px; } select { border: 1px solid #ccc; padding: 2px; font-size: 1.2em; color: #444; } input[type="submit"] { font-size: 1.2em; padding: 5px; } /* TABLE ----------------------------------------------------------*/ table { border: solid 1px #e8eef4; border-collapse: collapse; } table td { padding: 5px; border: solid 1px #e8eef4; } table th { padding: 6px 5px; text-align: left; background-color: #e8eef4; border: solid 1px #e8eef4; } /* MISC ----------------------------------------------------------*/ .clear { clear: both; } .error { color: Red; } nav, #menucontainer { margin-top: 40px; } div#title { display: block; float: left; text-align: left; } #logindisplay { font-size: 1.1em; display: block; text-align: right; margin: 10px; color: White; } #logindisplay a:link { color: white; text-decoration: underline; } #logindisplay a:visited { color: white; text-decoration: underline; } #logindisplay a:hover { color: white; text-decoration: none; } /* Styles for validation helpers -----------------------------------------------------------*/ .field-validation-error { color: #ff0000; } .field-validation-valid { display: none; } .input-validation-error { border: 1px solid #ff0000; background-color: #ffeeee; } .validation-summary-errors { font-weight: bold; color: #ff0000; } .validation-summary-valid { display: none; } /* Styles for editor and display helpers ----------------------------------------------------------*/ .display-label, .editor-label { margin: 1em 0 0 0; } .display-field, .editor-field { margin: 0.5em 0 0 0; } .text-box { width: 30em; } .text-box.multi-line { height: 6.5em; } .tri-state { width: 6em; }
08102013project
trunk/FrontEnd/Content/Site.css
CSS
oos
5,665
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace ECommerceMvcApplication { // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit http://go.microsoft.com/?LinkId=9394801 public class MvcApplication : System.Web.HttpApplication { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); } } }
08102013project
trunk/FrontEnd/Global.asax.cs
C#
oos
1,200
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Web.Security; using BusinessLayer.Repository; namespace BusinessLayer.Security { public class CustomMembershipProvider : MembershipProvider { public override string ApplicationName { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public override bool ChangePassword(string username, string oldPassword, string newPassword) { throw new NotImplementedException(); } public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { var args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return null; } if (RequiresUniqueEmail && GetUserNameByEmail(email) != string.Empty) { status = MembershipCreateStatus.DuplicateEmail; return null; } var user = UserRepository.GetUserByUserName(username); if (user == null) { bool rs = UserRepository.InsertUser(username,Encryption.GetMd5Hash(password),email); if (rs) { status = MembershipCreateStatus.Success; return GetUser(username, true); } else { status = MembershipCreateStatus.ProviderError; return null; } } status = MembershipCreateStatus.DuplicateUserName; return null; } public override bool DeleteUser(string username, bool deleteAllRelatedData) { throw new NotImplementedException(); } public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) { throw new NotImplementedException(); } public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { throw new NotImplementedException(); } public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) { throw new NotImplementedException(); } public override int GetNumberOfUsersOnline() { throw new NotImplementedException(); } public override MembershipUser GetUser(string username, bool userIsOnline) { var user = UserRepository.GetUserByUserName(username); if (user != null) { var memUser = new MembershipUser("CustomMembershipProvider", username, user.ID, user.Email, string.Empty, string.Empty, true, false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.Now, DateTime.Now); return memUser; } return null; } public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) { throw new NotImplementedException(); } public override string GetUserNameByEmail(string email) { var requiredUser = UserRepository.GetUserByEmail(email); if (requiredUser != null) return requiredUser.UserName; else return string.Empty; } public override bool RequiresUniqueEmail { get { return true; } } public override string ResetPassword(string username, string answer) { throw new NotImplementedException(); } public override void UpdateUser(MembershipUser user) { throw new NotImplementedException(); } public override bool ValidateUser(string username, string password) { var md5Hash = Encryption.GetMd5Hash(password); var requiredUser = UserRepository.GetUser(username, md5Hash); return requiredUser != null; } public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) { throw new NotImplementedException(); } public override bool EnablePasswordReset { get { throw new NotImplementedException(); } } public override bool EnablePasswordRetrieval { get { throw new NotImplementedException(); } } public override string GetPassword(string username, string answer) { throw new NotImplementedException(); } public override int MaxInvalidPasswordAttempts { get { return 5; } } public override int MinRequiredNonAlphanumericCharacters { get { return 1; } } public override int MinRequiredPasswordLength { get { return 6; } } public override int PasswordAttemptWindow { get { throw new NotImplementedException(); } } public override MembershipPasswordFormat PasswordFormat { get { throw new NotImplementedException(); } } public override string PasswordStrengthRegularExpression { get { throw new NotImplementedException(); } } public override bool RequiresQuestionAndAnswer { get { throw new NotImplementedException(); } } public override bool UnlockUser(string userName) { throw new NotImplementedException(); } } }
08102013project
trunk/BusinessLayer/Security/CustomMembershipProvider.cs
C#
oos
6,717
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security.Cryptography; namespace BusinessLayer.Security { public class Encryption { public static string GetMd5Hash(string value) { var md5Hasher = MD5.Create(); var data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(value)); var sBuilder = new StringBuilder(); for (var i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); } return sBuilder.ToString(); } /// <summary> /// Generates a hash for the given plain text value and returns a /// base64-encoded result. Before the hash is computed, a random salt /// is generated and appended to the plain text. This salt is stored at /// the end of the hash value, so it can be used later for hash /// verification. /// </summary> /// <param name="plainText"> /// Plaintext value to be hashed. The function does not check whether /// this parameter is null. /// </param> /// <param name="hashAlgorithm"> /// Name of the hash algorithm. Allowed values are: "MD5", "SHA1", /// "SHA256", "SHA384", and "SHA512" (if any other value is specified /// MD5 hashing algorithm will be used). This value is case-insensitive. /// </param> /// <param name="saltBytes"> /// Salt bytes. This parameter can be null, in which case a random salt /// value will be generated. /// </param> /// <returns> /// Hash value formatted as a base64-encoded string. /// </returns> public static string ComputeHash(string plainText, string hashAlgorithm, byte[] saltBytes) { // If salt is not specified, generate it on the fly. if (saltBytes == null) { // Define min and max salt sizes. int minSaltSize = 4; int maxSaltSize = 8; // Generate a random number for the size of the salt. Random random = new Random(); int saltSize = random.Next(minSaltSize, maxSaltSize); // Allocate a byte array, which will hold the salt. saltBytes = new byte[saltSize]; // Initialize a random number generator. RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); // Fill the salt with cryptographically strong byte values. rng.GetNonZeroBytes(saltBytes); } // Convert plain text into a byte array. byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText); // Allocate array, which will hold plain text and salt. byte[] plainTextWithSaltBytes = new byte[plainTextBytes.Length + saltBytes.Length]; // Copy plain text bytes into resulting array. for (int i = 0; i < plainTextBytes.Length; i++) plainTextWithSaltBytes[i] = plainTextBytes[i]; // Append salt bytes to the resulting array. for (int i = 0; i < saltBytes.Length; i++) plainTextWithSaltBytes[plainTextBytes.Length + i] = saltBytes[i]; // Because we support multiple hashing algorithms, we must define // hash object as a common (abstract) base class. We will specify the // actual hashing algorithm class later during object creation. HashAlgorithm hash; // Make sure hashing algorithm name is specified. if (hashAlgorithm == null) hashAlgorithm = ""; // Initialize appropriate hashing algorithm class. switch (hashAlgorithm.ToUpper()) { case "SHA1": hash = new SHA1Managed(); break; case "SHA256": hash = new SHA256Managed(); break; case "SHA384": hash = new SHA384Managed(); break; case "SHA512": hash = new SHA512Managed(); break; default: hash = new MD5CryptoServiceProvider(); break; } // Compute hash value of our plain text with appended salt. byte[] hashBytes = hash.ComputeHash(plainTextWithSaltBytes); // Create array which will hold hash and original salt bytes. byte[] hashWithSaltBytes = new byte[hashBytes.Length + saltBytes.Length]; // Copy hash bytes into resulting array. for (int i = 0; i < hashBytes.Length; i++) hashWithSaltBytes[i] = hashBytes[i]; // Append salt bytes to the result. for (int i = 0; i < saltBytes.Length; i++) hashWithSaltBytes[hashBytes.Length + i] = saltBytes[i]; // Convert result into a base64-encoded string. string hashValue = Convert.ToBase64String(hashWithSaltBytes); // Return the result. return hashValue; } /// <summary> /// Compares a hash of the specified plain text value to a given hash /// value. Plain text is hashed with the same salt value as the original /// hash. /// </summary> /// <param name="plainText"> /// Plain text to be verified against the specified hash. The function /// does not check whether this parameter is null. /// </param> /// <param name="hashAlgorithm"> /// Name of the hash algorithm. Allowed values are: "MD5", "SHA1", /// "SHA256", "SHA384", and "SHA512" (if any other value is specified, /// MD5 hashing algorithm will be used). This value is case-insensitive. /// </param> /// <param name="hashValue"> /// Base64-encoded hash value produced by ComputeHash function. This value /// includes the original salt appended to it. /// </param> /// <returns> /// If computed hash mathes the specified hash the function the return /// value is true; otherwise, the function returns false. /// </returns> public static bool VerifyHash(string plainText, string hashAlgorithm, string hashValue) { // Convert base64-encoded hash value into a byte array. byte[] hashWithSaltBytes = Convert.FromBase64String(hashValue); // We must know size of hash (without salt). int hashSizeInBits, hashSizeInBytes; // Make sure that hashing algorithm name is specified. if (hashAlgorithm == null) hashAlgorithm = ""; // Size of hash is based on the specified algorithm. switch (hashAlgorithm.ToUpper()) { case "SHA1": hashSizeInBits = 160; break; case "SHA256": hashSizeInBits = 256; break; case "SHA384": hashSizeInBits = 384; break; case "SHA512": hashSizeInBits = 512; break; default: // Must be MD5 hashSizeInBits = 128; break; } // Convert size of hash from bits to bytes. hashSizeInBytes = hashSizeInBits / 8; // Make sure that the specified hash value is long enough. if (hashWithSaltBytes.Length < hashSizeInBytes) return false; // Allocate array to hold original salt bytes retrieved from hash. byte[] saltBytes = new byte[hashWithSaltBytes.Length - hashSizeInBytes]; // Copy salt from the end of the hash to the new array. for (int i = 0; i < saltBytes.Length; i++) saltBytes[i] = hashWithSaltBytes[hashSizeInBytes + i]; // Compute a new hash string. string expectedHashString = ComputeHash(plainText, hashAlgorithm, saltBytes); // If the computed hash matches the specified hash, // the plain text value must be correct. return (hashValue == expectedHashString); } } }
08102013project
trunk/BusinessLayer/Security/Encryption.cs
C#
oos
8,988
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("BusinessLayer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("BusinessLayer")] [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("146aaef0-af3d-4632-848b-9b754a6bdcea")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
08102013project
trunk/BusinessLayer/Properties/AssemblyInfo.cs
C#
oos
1,456
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BusinessLayer { public class Constant { } }
08102013project
trunk/BusinessLayer/Utils/Constant.cs
C#
oos
167
using System; using System.Collections.Generic; using System.Linq; using System.Text; using BusinessLayer.DataContext; namespace BusinessLayer.Repository { public class UserRepository { public static User GetUserByEmail(string email) { using (ShoppingCartDataContext context = new ShoppingCartDataContext()) { return context.Users.FirstOrDefault(obj => obj.Email.Equals(email)); } } public static User GetUserByUserName(string userName) { using (ShoppingCartDataContext context = new ShoppingCartDataContext()) { return context.Users.FirstOrDefault(obj => obj.UserName.Equals(userName)); } } public static User GetUser(string userName, string password) { using (ShoppingCartDataContext context = new ShoppingCartDataContext()) { return context.Users.FirstOrDefault(obj => obj.UserName.Equals(userName) && obj.Password.Equals(password)); } } public static bool ChangePassword(string username, string oldPassword, string newPassword) { var user = GetUser(username, oldPassword); if (user != null) { user.Password = newPassword; return true; } return false; } public static bool InsertUser(string username, string password, string email) { try { using (ShoppingCartDataContext ct = new ShoppingCartDataContext()) { User user = new User(); user.UserName = username; user.Password = password; user.Email = email; ct.Users.InsertOnSubmit(user); ct.SubmitChanges(); return true; } } catch { return false; } } public static bool DeleteUser(int id) { try { using (ShoppingCartDataContext context = new ShoppingCartDataContext()) { User original = context.Users.FirstOrDefault(obj => obj.ID == id); context.Users.DeleteOnSubmit(original); context.SubmitChanges(); return true; } } catch { return false; } } } }
08102013project
trunk/BusinessLayer/Repository/UserRepository.cs
C#
oos
2,699
@{ Layout = "~/Views/Shared/_MainLayout.cshtml"; }
08102013project
trunk/CMS/Views/_ViewStart.cshtml
HTML+Razor
oos
59
@model CMS.Models.RegisterModel @{ ViewBag.Title = "Register"; Layout = "~/Views/Shared/_LogOnLayout.cshtml"; } <p> Passwords are required to be a minimum of @Membership.MinRequiredPasswordLength characters in length. </p> <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> @using (Html.BeginForm()) { @Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") <fieldset> <legend>Account Information</legend> <section> @Html.LabelFor(m => m.UserName) <div> @Html.TextBoxFor(m => m.UserName) @Html.ValidationMessageFor(m => m.UserName) </div> </section> <section> @Html.LabelFor(m => m.Email) <div> @Html.TextBoxFor(m => m.Email) @Html.ValidationMessageFor(m => m.Email) </div> </section> <section> @Html.LabelFor(m => m.Password) <div> @Html.PasswordFor(m => m.Password) @Html.ValidationMessageFor(m => m.Password) </div> </section> <section> @Html.LabelFor(m => m.ConfirmPassword) <div> @Html.PasswordFor(m => m.ConfirmPassword) @Html.ValidationMessageFor(m => m.ConfirmPassword) </div> </section> <section> <div><button type="submit">Register</button></div> </section> </fieldset> }
08102013project
trunk/CMS/Views/Account/Register.cshtml
HTML+Razor
oos
1,762
@model CMS.Models.LogOnModel @{ ViewBag.Title = "Log On"; Layout = "~/Views/Shared/_LogOnLayout.cshtml"; } <script src="@Url.Content("~/Scripts/plugins/login.js")"></script> @using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { id = "loginform" })) { <fieldset> <section> @Html.LabelFor(m => m.UserName) <div>@Html.TextBoxFor(m => m.UserName)</div> </section> <section> @Html.LabelFor(m => m.Password) <div>@Html.PasswordFor(m => m.Password)</div> <div>@Html.CheckBoxFor(m => m.RememberMe)@Html.LabelFor(m => m.RememberMe)</div> <div><a href="#">Lost password?</a></div> </section> <section> <div><button class="fr submit">Login</button></div> </section> </fieldset> }
08102013project
trunk/CMS/Views/Account/LogOn.cshtml
HTML+Razor
oos
769
@model CMS.Models.ChangePasswordModel @{ ViewBag.Title = "Change Password"; } <h2>Change Password</h2> <p> Use the form below to change your password. </p> <p> New passwords are required to be a minimum of @Membership.MinRequiredPasswordLength characters in length. </p> <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> @using (Html.BeginForm()) { @Html.ValidationSummary(true, "Password change was unsuccessful. Please correct the errors and try again.") <div> <fieldset> <legend>Account Information</legend> <div class="editor-label"> @Html.LabelFor(m => m.OldPassword) </div> <div class="editor-field"> @Html.PasswordFor(m => m.OldPassword) @Html.ValidationMessageFor(m => m.OldPassword) </div> <div class="editor-label"> @Html.LabelFor(m => m.NewPassword) </div> <div class="editor-field"> @Html.PasswordFor(m => m.NewPassword) @Html.ValidationMessageFor(m => m.NewPassword) </div> <div class="editor-label"> @Html.LabelFor(m => m.ConfirmPassword) </div> <div class="editor-field"> @Html.PasswordFor(m => m.ConfirmPassword) @Html.ValidationMessageFor(m => m.ConfirmPassword) </div> <p> <input type="submit" value="Change Password" /> </p> </fieldset> </div> }
08102013project
trunk/CMS/Views/Account/ChangePassword.cshtml
HTML+Razor
oos
1,764
@{ ViewBag.Title = "Change Password"; } <h2>Change Password</h2> <p> Your password has been changed successfully. </p>
08102013project
trunk/CMS/Views/Account/ChangePasswordSuccess.cshtml
HTML+Razor
oos
139
@{ ViewBag.Title = "Dashboard"; } <div class="g12 nodrop"> <h1> Dashboard</h1> <p> This is a quick overview of some features</p> </div> <div class="g6 widgets"> <div class="widget" id="calendar_widget" data-icon="calendar"> <h3 class="handle"> Calendar</h3> <div> <div class="calendar" data-header="small"> </div> <p> <a class="btn" href="calendar.html">Check out the Calendar section</a> </p> </div> </div> <div class="widget" id="widget_tabs"> <h3 class="handle"> Tabs</h3> <div class="tab"> <ul> <li><a href="#tabs-1">Nunc tincidunt</a></li> <li><a href="#tabs-2">Proin dolor</a></li> <li><a href="#tabs-3">Aenean lacinia</a></li> </ul> <div id="tabs-1"> <p> Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus. </p> </div> <div id="tabs-2"> <p> Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus. </p> </div> <div id="tabs-3"> <p> Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus. </p> <p> Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit. </p> </div> </div> </div> <div class="widget number-widget" id="widget_number"> <h3 class="handle"> Number</h3> <div> <ul> <li><a href=""><span>7423</span> Total Visits</a></li> <li><a href=""><span>392</span> Today Visits</a></li> <li><a href=""><span>153</span> Unique Visits</a></li> <li><a href=""><span>14</span> Support Tickets</a></li> <li><a href=""><span>253</span> Comments</a></li> </ul> </div> </div> </div> <div class="g6 widgets"> <div class="widget" id="widget_charts" data-icon="graph"> <h3 class="handle"> Charts</h3> <div> <table class="chart" data-fill="true" data-tooltip-pattern="%1 %2 on the 2011-03-%3"> <thead> <tr> <th> </th> <th> 01 </th> <th> 02 </th> <th> 03 </th> <th> 04 </th> <th> 05 </th> <th> 06 </th> <th> 07 </th> <th> 08 </th> <th> 09 </th> <th> 10 </th> <th> 11 </th> <th> 12 </th> <th> 13 </th> <th> 14 </th> <th> 15 </th> <th> 16 </th> <th> 17 </th> <th> 18 </th> <th> 19 </th> <th> 20 </th> <th> 21 </th> <th> 22 </th> <th> 23 </th> <th> 24 </th> <th> 25 </th> <th> 26 </th> <th> 27 </th> <th> 28 </th> <th> 29 </th> <th> 30 </th> <th> 31 </th> </tr> </thead> <tbody> <tr> <th> Total Visitors </th> <td> 331 </td> <td> 306 </td> <td> 337 </td> <td> 340 </td> <td> 332 </td> <td> 330 </td> <td> 307 </td> <td> 343 </td> <td> 307 </td> <td> 322 </td> <td> 319 </td> <td> 314 </td> <td> 326 </td> <td> 317 </td> <td> 323 </td> <td> 347 </td> <td> 317 </td> <td> 341 </td> <td> 328 </td> <td> 307 </td> <td> 350 </td> <td> 330 </td> <td> 313 </td> <td> 314 </td> <td> 332 </td> <td> 330 </td> <td> 317 </td> <td> 346 </td> <td> 328 </td> <td> 312 </td> <td> 311 </td> </tr> <tr> <th> Unique Visitors </th> <td> 113 </td> <td> 126 </td> <td> 143 </td> <td> 126 </td> <td> 147 </td> <td> 131 </td> <td> 150 </td> <td> 112 </td> <td> 110 </td> <td> 130 </td> <td> 109 </td> <td> 115 </td> <td> 146 </td> <td> 129 </td> <td> 138 </td> <td> 122 </td> <td> 114 </td> <td> 112 </td> <td> 128 </td> <td> 111 </td> <td> 122 </td> <td> 136 </td> <td> 109 </td> <td> 106 </td> <td> 104 </td> <td> 146 </td> <td> 123 </td> <td> 139 </td> <td> 117 </td> <td> 116 </td> <td> 143 </td> </tr> </tbody> </table> <p> <a class="btn" href="charts.html">Check out the Charts section</a> </p> </div> </div> <div class="widget" id="widget_accordion"> <h3 class="handle"> Accordion</h3> <div class="accordion"> <h4> <a href="#">Section 1</a></h4> <div> <p> Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. </p> </div> <h4> <a href="#">Section 2</a></h4> <div> <p> Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p> </div> <h4> <a href="#">Section 3</a></h4> <div> <p> Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p> <ul> <li>List item one</li> <li>List item two</li> <li>List item three</li> </ul> </div> <h4> <a href="#">Section 4</a></h4> <div> <p> Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p> <p> Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p> </div> </div> </div> <div class="widget" id="widget_breadcrumb"> <h3 class="handle"> Breadcrumb</h3> <div> <ul class="breadcrumb" data-numbers="true"> <li><a href="#">Ready</a></li> <li><a href="#">Set</a></li> <li><a href="#">GO!</a></li> </ul> <p> <a class="btn" href="breadcrumb.html">Check out the Breadcrumb section</a> </p> </div> </div> <div class="widget" id="widget_ajax" data-load="Home/About" data-reload="10" data-remove-content="false"> <h3 class="handle"> AJAX Widget with autoreload</h3> <div> This content get replaced </div> </div> <div class="widget" id="widget_info"> <h3 class="handle"> Do What you like!</h3> <div> <h3> Widgets can contain everything</h3> <p> Widgets are flexible, dragg-, sort-, and collapseable content boxes. Fill them with some html! </p> <p> <a class="btn" href="widgets.html">Check out the Widget section</a> </p> </div> </div> </div>
08102013project
trunk/CMS/Views/Home/Index.cshtml
HTML+Razor
oos
18,183