diff --git a/UyTube_aplicacion/dist/UyTube.jar b/UyTube_aplicacion/dist/UyTube.jar deleted file mode 100644 index 2dc55b63afebd007fb2ed70f044c854ba9d8235a..0000000000000000000000000000000000000000 Binary files a/UyTube_aplicacion/dist/UyTube.jar and /dev/null differ diff --git a/UyTube_aplicacion/src/Imagenes/nerd.gif b/UyTube_aplicacion/src/Imagenes/nerd.gif deleted file mode 100644 index 0dfb65645f02346220264978edfc7740103b5137..0000000000000000000000000000000000000000 Binary files a/UyTube_aplicacion/src/Imagenes/nerd.gif and /dev/null differ diff --git a/UyTube_aplicacion/Imagenes/about.png b/UyTube_estacion_de_trabajo/Imagenes/about.png similarity index 100% rename from UyTube_aplicacion/Imagenes/about.png rename to UyTube_estacion_de_trabajo/Imagenes/about.png diff --git a/UyTube_aplicacion/Imagenes/des.jpeg b/UyTube_estacion_de_trabajo/Imagenes/des.jpeg similarity index 100% rename from UyTube_aplicacion/Imagenes/des.jpeg rename to UyTube_estacion_de_trabajo/Imagenes/des.jpeg diff --git a/UyTube_aplicacion/Imagenes/icono.jpg b/UyTube_estacion_de_trabajo/Imagenes/icono.jpg similarity index 100% rename from UyTube_aplicacion/Imagenes/icono.jpg rename to UyTube_estacion_de_trabajo/Imagenes/icono.jpg diff --git a/UyTube_aplicacion/Imagenes/perfiles/JotaJota96.JPG b/UyTube_estacion_de_trabajo/Imagenes/perfiles/JotaJota96.JPG similarity index 100% rename from UyTube_aplicacion/Imagenes/perfiles/JotaJota96.JPG rename to UyTube_estacion_de_trabajo/Imagenes/perfiles/JotaJota96.JPG diff --git a/UyTube_aplicacion/Imagenes/perfiles/LuC31G.jpg b/UyTube_estacion_de_trabajo/Imagenes/perfiles/LuC31G.jpg similarity index 100% rename from UyTube_aplicacion/Imagenes/perfiles/LuC31G.jpg rename to UyTube_estacion_de_trabajo/Imagenes/perfiles/LuC31G.jpg diff --git a/UyTube_aplicacion/Imagenes/perfiles/MCBolso.jpg b/UyTube_estacion_de_trabajo/Imagenes/perfiles/MCBolso.jpg similarity index 100% rename from UyTube_aplicacion/Imagenes/perfiles/MCBolso.jpg rename to UyTube_estacion_de_trabajo/Imagenes/perfiles/MCBolso.jpg diff --git a/UyTube_aplicacion/Imagenes/perfiles/camilillo15.jpg b/UyTube_estacion_de_trabajo/Imagenes/perfiles/camilillo15.jpg similarity index 100% rename from UyTube_aplicacion/Imagenes/perfiles/camilillo15.jpg rename to UyTube_estacion_de_trabajo/Imagenes/perfiles/camilillo15.jpg diff --git a/UyTube_aplicacion/Imagenes/perfiles/jarrieta31.jpg b/UyTube_estacion_de_trabajo/Imagenes/perfiles/jarrieta31.jpg similarity index 100% rename from UyTube_aplicacion/Imagenes/perfiles/jarrieta31.jpg rename to UyTube_estacion_de_trabajo/Imagenes/perfiles/jarrieta31.jpg diff --git a/UyTube_aplicacion/Imagenes/ukp.png b/UyTube_estacion_de_trabajo/Imagenes/ukp.png similarity index 100% rename from UyTube_aplicacion/Imagenes/ukp.png rename to UyTube_estacion_de_trabajo/Imagenes/ukp.png diff --git a/UyTube_estacion_de_trabajo/build.xml b/UyTube_estacion_de_trabajo/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..eb4bc0ec665b140abc593e77d33611560329528a --- /dev/null +++ b/UyTube_estacion_de_trabajo/build.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- You may freely edit this file. See commented blocks below for --> +<!-- some examples of how to customize the build. --> +<!-- (If you delete it and reopen the project it will be recreated.) --> +<!-- By default, only the Clean and Build commands use this build script. --> +<!-- Commands such as Run, Debug, and Test only use this build script if --> +<!-- the Compile on Save feature is turned off for the project. --> +<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> +<!-- in the project's Project Properties dialog box.--> +<project name="UyTube_estacion_de_trabajo" default="default" basedir="."> + <description>Builds, tests, and runs the project UyTube_estacion_de_trabajo.</description> + <import file="nbproject/build-impl.xml"/> + <!-- + + There exist several targets which are by default empty and which can be + used for execution of your tasks. These targets are usually executed + before and after some main targets. They are: + + -pre-init: called before initialization of project properties + -post-init: called after initialization of project properties + -pre-compile: called before javac compilation + -post-compile: called after javac compilation + -pre-compile-single: called before javac compilation of single file + -post-compile-single: called after javac compilation of single file + -pre-compile-test: called before javac compilation of JUnit tests + -post-compile-test: called after javac compilation of JUnit tests + -pre-compile-test-single: called before javac compilation of single JUnit test + -post-compile-test-single: called after javac compilation of single JUunit test + -pre-jar: called before JAR building + -post-jar: called after JAR building + -post-clean: called after cleaning build products + + (Targets beginning with '-' are not intended to be called on their own.) + + Example of inserting an obfuscator after compilation could look like this: + + <target name="-post-compile"> + <obfuscate> + <fileset dir="${build.classes.dir}"/> + </obfuscate> + </target> + + For list of available properties check the imported + nbproject/build-impl.xml file. + + + Another way to customize the build is by overriding existing main targets. + The targets of interest are: + + -init-macrodef-javac: defines macro for javac compilation + -init-macrodef-junit: defines macro for junit execution + -init-macrodef-debug: defines macro for class debugging + -init-macrodef-java: defines macro for class execution + -do-jar: JAR building + run: execution of project + -javadoc-build: Javadoc generation + test-report: JUnit report generation + + An example of overriding the target for project execution could look like this: + + <target name="run" depends="UyTube_estacion_de_trabajo-impl.jar"> + <exec dir="bin" executable="launcher.exe"> + <arg file="${dist.jar}"/> + </exec> + </target> + + Notice that the overridden target depends on the jar target and not only on + the compile target as the regular run target does. Again, for a list of available + properties which you can use, check the target you are overriding in the + nbproject/build-impl.xml file. + + --> +</project> diff --git a/UyTube_aplicacion/dist/README.TXT b/UyTube_estacion_de_trabajo/dist/README.TXT similarity index 96% rename from UyTube_aplicacion/dist/README.TXT rename to UyTube_estacion_de_trabajo/dist/README.TXT index 0f7d0469dc9ed1c041382b9c1575004f82ce3830..129f1444c548a0a7128e58bfdeb8e91da3695677 100644 --- a/UyTube_aplicacion/dist/README.TXT +++ b/UyTube_estacion_de_trabajo/dist/README.TXT @@ -11,7 +11,7 @@ JAR files manifest file (MANIFEST.MF). To run the project from the command line, go to the dist folder and type the following: -java -jar "UyTube.jar" +java -jar "UyTube_estacion_de_trabajo.jar" To distribute this project, zip up the dist folder (including the lib folder) and distribute the ZIP file. diff --git a/UyTube_aplicacion/dist/lib/AbsoluteLayout.jar b/UyTube_estacion_de_trabajo/dist/lib/AbsoluteLayout.jar similarity index 100% rename from UyTube_aplicacion/dist/lib/AbsoluteLayout.jar rename to UyTube_estacion_de_trabajo/dist/lib/AbsoluteLayout.jar diff --git a/Librerias/JCalendar_1.4.jar b/UyTube_estacion_de_trabajo/dist/lib/JCalendar_1.4.jar similarity index 100% rename from Librerias/JCalendar_1.4.jar rename to UyTube_estacion_de_trabajo/dist/lib/JCalendar_1.4.jar diff --git a/UyTube_aplicacion/dist/lib/UyTube_logica.jar b/UyTube_estacion_de_trabajo/dist/lib/UyTube_logica.jar similarity index 100% rename from UyTube_aplicacion/dist/lib/UyTube_logica.jar rename to UyTube_estacion_de_trabajo/dist/lib/UyTube_logica.jar diff --git a/UyTube_aplicacion/dist/lib/eclipselink.jar b/UyTube_estacion_de_trabajo/dist/lib/eclipselink.jar similarity index 100% rename from UyTube_aplicacion/dist/lib/eclipselink.jar rename to UyTube_estacion_de_trabajo/dist/lib/eclipselink.jar diff --git a/UyTube_aplicacion/dist/lib/javax.persistence_2.1.0.v201304241213.jar b/UyTube_estacion_de_trabajo/dist/lib/javax.persistence_2.1.0.v201304241213.jar similarity index 100% rename from UyTube_aplicacion/dist/lib/javax.persistence_2.1.0.v201304241213.jar rename to UyTube_estacion_de_trabajo/dist/lib/javax.persistence_2.1.0.v201304241213.jar diff --git a/UyTube_aplicacion/dist/lib/org.eclipse.persistence.jpa.jpql_2.5.2.v20140319-9ad6abd.jar b/UyTube_estacion_de_trabajo/dist/lib/org.eclipse.persistence.jpa.jpql_2.5.2.v20140319-9ad6abd.jar similarity index 100% rename from UyTube_aplicacion/dist/lib/org.eclipse.persistence.jpa.jpql_2.5.2.v20140319-9ad6abd.jar rename to UyTube_estacion_de_trabajo/dist/lib/org.eclipse.persistence.jpa.jpql_2.5.2.v20140319-9ad6abd.jar diff --git a/UyTube_aplicacion/dist/lib/postgresql-9.4.1209.jar b/UyTube_estacion_de_trabajo/dist/lib/postgresql-9.4.1209.jar similarity index 100% rename from UyTube_aplicacion/dist/lib/postgresql-9.4.1209.jar rename to UyTube_estacion_de_trabajo/dist/lib/postgresql-9.4.1209.jar diff --git a/UyTube_aplicacion/dist/lib/JCalendar_1.4.jar b/UyTube_estacion_de_trabajo/librerias/JCalendar_1.4.jar similarity index 100% rename from UyTube_aplicacion/dist/lib/JCalendar_1.4.jar rename to UyTube_estacion_de_trabajo/librerias/JCalendar_1.4.jar diff --git a/Librerias/UyTube_logica.jar b/UyTube_estacion_de_trabajo/librerias/UyTube_logica.jar similarity index 100% rename from Librerias/UyTube_logica.jar rename to UyTube_estacion_de_trabajo/librerias/UyTube_logica.jar diff --git a/UyTube_aplicacion/manifest.mf b/UyTube_estacion_de_trabajo/manifest.mf similarity index 100% rename from UyTube_aplicacion/manifest.mf rename to UyTube_estacion_de_trabajo/manifest.mf diff --git a/UyTube_estacion_de_trabajo/nbproject/build-impl.xml b/UyTube_estacion_de_trabajo/nbproject/build-impl.xml new file mode 100644 index 0000000000000000000000000000000000000000..675236aa1edc9f6634892ef0191b4e191329ad45 --- /dev/null +++ b/UyTube_estacion_de_trabajo/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +*** GENERATED FROM project.xml - DO NOT EDIT *** +*** EDIT ../build.xml INSTEAD *** + +For the purpose of easier reading the script +is divided into following sections: + + - initialization + - compilation + - jar + - execution + - debugging + - javadoc + - test compilation + - test execution + - test debugging + - applet + - cleanup + + --> +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="UyTube_estacion_de_trabajo-impl"> + <fail message="Please build using Ant 1.8.0 or higher."> + <condition> + <not> + <antversion atleast="1.8.0"/> + </not> + </condition> + </fail> + <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/> + <!-- + ====================== + INITIALIZATION SECTION + ====================== + --> + <target name="-pre-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="-pre-init" name="-init-private"> + <property file="nbproject/private/config.properties"/> + <property file="nbproject/private/configs/${config}.properties"/> + <property file="nbproject/private/private.properties"/> + </target> + <target depends="-pre-init,-init-private" name="-init-user"> + <property file="${user.properties.file}"/> + <!-- The two properties below are usually overridden --> + <!-- by the active platform. Just a fallback. --> + <property name="default.javac.source" value="1.6"/> + <property name="default.javac.target" value="1.6"/> + </target> + <target depends="-pre-init,-init-private,-init-user" name="-init-project"> + <property file="nbproject/configs/${config}.properties"/> + <property file="nbproject/project.properties"/> + </target> + <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init"> + <property name="platform.java" value="${java.home}/bin/java"/> + <available file="${manifest.file}" property="manifest.available"/> + <condition property="splashscreen.available"> + <and> + <not> + <equals arg1="${application.splash}" arg2="" trim="true"/> + </not> + <available file="${application.splash}"/> + </and> + </condition> + <condition property="main.class.available"> + <and> + <isset property="main.class"/> + <not> + <equals arg1="${main.class}" arg2="" trim="true"/> + </not> + </and> + </condition> + <condition property="profile.available"> + <and> + <isset property="javac.profile"/> + <length length="0" string="${javac.profile}" when="greater"/> + <matches pattern="((1\.[89])|9)(\..*)?" string="${javac.source}"/> + </and> + </condition> + <condition property="do.archive"> + <or> + <not> + <istrue value="${jar.archive.disabled}"/> + </not> + <istrue value="${not.archive.disabled}"/> + </or> + </condition> + <condition property="do.mkdist"> + <and> + <isset property="do.archive"/> + <isset property="libs.CopyLibs.classpath"/> + <not> + <istrue value="${mkdist.disabled}"/> + </not> + </and> + </condition> + <condition property="do.archive+manifest.available"> + <and> + <isset property="manifest.available"/> + <istrue value="${do.archive}"/> + </and> + </condition> + <condition property="do.archive+main.class.available"> + <and> + <isset property="main.class.available"/> + <istrue value="${do.archive}"/> + </and> + </condition> + <condition property="do.archive+splashscreen.available"> + <and> + <isset property="splashscreen.available"/> + <istrue value="${do.archive}"/> + </and> + </condition> + <condition property="do.archive+profile.available"> + <and> + <isset property="profile.available"/> + <istrue value="${do.archive}"/> + </and> + </condition> + <condition property="have.tests"> + <or> + <available file="${test.src.dir}"/> + </or> + </condition> + <condition property="have.sources"> + <or> + <available file="${src.dir}"/> + </or> + </condition> + <condition property="netbeans.home+have.tests"> + <and> + <isset property="netbeans.home"/> + <isset property="have.tests"/> + </and> + </condition> + <condition property="no.javadoc.preview"> + <and> + <isset property="javadoc.preview"/> + <isfalse value="${javadoc.preview}"/> + </and> + </condition> + <property name="run.jvmargs" value=""/> + <property name="run.jvmargs.ide" value=""/> + <property name="javac.compilerargs" value=""/> + <property name="work.dir" value="${basedir}"/> + <condition property="no.deps"> + <and> + <istrue value="${no.dependencies}"/> + </and> + </condition> + <property name="javac.debug" value="true"/> + <property name="javadoc.preview" value="true"/> + <property name="application.args" value=""/> + <property name="source.encoding" value="${file.encoding}"/> + <property name="runtime.encoding" value="${source.encoding}"/> + <property name="manifest.encoding" value="${source.encoding}"/> + <condition property="javadoc.encoding.used" value="${javadoc.encoding}"> + <and> + <isset property="javadoc.encoding"/> + <not> + <equals arg1="${javadoc.encoding}" arg2=""/> + </not> + </and> + </condition> + <property name="javadoc.encoding.used" value="${source.encoding}"/> + <property name="includes" value="**"/> + <property name="excludes" value=""/> + <property name="do.depend" value="false"/> + <condition property="do.depend.true"> + <istrue value="${do.depend}"/> + </condition> + <path id="endorsed.classpath.path" path="${endorsed.classpath}"/> + <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'"> + <and> + <isset property="endorsed.classpath"/> + <not> + <equals arg1="${endorsed.classpath}" arg2="" trim="true"/> + </not> + </and> + </condition> + <condition else="" property="javac.profile.cmd.line.arg" value="-profile ${javac.profile}"> + <isset property="profile.available"/> + </condition> + <condition else="false" property="jdkBug6558476"> + <and> + <matches pattern="1\.[56]" string="${java.specification.version}"/> + <not> + <os family="unix"/> + </not> + </and> + </condition> + <condition else="false" property="javac.fork"> + <or> + <istrue value="${jdkBug6558476}"/> + <istrue value="${javac.external.vm}"/> + </or> + </condition> + <property name="jar.index" value="false"/> + <property name="jar.index.metainf" value="${jar.index}"/> + <property name="copylibs.rebase" value="true"/> + <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/> + <condition property="junit.available"> + <or> + <available classname="org.junit.Test" classpath="${run.test.classpath}"/> + <available classname="junit.framework.Test" classpath="${run.test.classpath}"/> + </or> + </condition> + <condition property="testng.available"> + <available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/> + </condition> + <condition property="junit+testng.available"> + <and> + <istrue value="${junit.available}"/> + <istrue value="${testng.available}"/> + </and> + </condition> + <condition else="testng" property="testng.mode" value="mixed"> + <istrue value="${junit+testng.available}"/> + </condition> + <condition else="" property="testng.debug.mode" value="-mixed"> + <istrue value="${junit+testng.available}"/> + </condition> + <property name="java.failonerror" value="true"/> + </target> + <target name="-post-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check"> + <fail unless="src.dir">Must set src.dir</fail> + <fail unless="test.src.dir">Must set test.src.dir</fail> + <fail unless="build.dir">Must set build.dir</fail> + <fail unless="dist.dir">Must set dist.dir</fail> + <fail unless="build.classes.dir">Must set build.classes.dir</fail> + <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail> + <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail> + <fail unless="build.test.results.dir">Must set build.test.results.dir</fail> + <fail unless="build.classes.excludes">Must set build.classes.excludes</fail> + <fail unless="dist.jar">Must set dist.jar</fail> + </target> + <target name="-init-macrodef-property"> + <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute name="name"/> + <attribute name="value"/> + <sequential> + <property name="@{name}" value="${@{value}}"/> + </sequential> + </macrodef> + </target> + <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors"> + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <attribute default="${javac.processorpath}" name="processorpath"/> + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="${javac.debug}" name="debug"/> + <attribute default="${empty.dir}" name="sourcepath"/> + <attribute default="${empty.dir}" name="gensrcdir"/> + <element name="customize" optional="true"/> + <sequential> + <property location="${build.dir}/empty" name="empty.dir"/> + <mkdir dir="${empty.dir}"/> + <mkdir dir="@{apgeneratedsrcdir}"/> + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}"> + <src> + <dirset dir="@{gensrcdir}" erroronmissingdir="false"> + <include name="*"/> + </dirset> + </src> + <classpath> + <path path="@{classpath}"/> + </classpath> + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/> + <compilerarg line="${javac.profile.cmd.line.arg}"/> + <compilerarg line="${javac.compilerargs}"/> + <compilerarg value="-processorpath"/> + <compilerarg path="@{processorpath}:${empty.dir}"/> + <compilerarg line="${ap.processors.internal}"/> + <compilerarg line="${annotation.processing.processor.options}"/> + <compilerarg value="-s"/> + <compilerarg path="@{apgeneratedsrcdir}"/> + <compilerarg line="${ap.proc.none.internal}"/> + <customize/> + </javac> + </sequential> + </macrodef> + </target> + <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal"> + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <attribute default="${javac.processorpath}" name="processorpath"/> + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="${javac.debug}" name="debug"/> + <attribute default="${empty.dir}" name="sourcepath"/> + <attribute default="${empty.dir}" name="gensrcdir"/> + <element name="customize" optional="true"/> + <sequential> + <property location="${build.dir}/empty" name="empty.dir"/> + <mkdir dir="${empty.dir}"/> + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}"> + <src> + <dirset dir="@{gensrcdir}" erroronmissingdir="false"> + <include name="*"/> + </dirset> + </src> + <classpath> + <path path="@{classpath}"/> + </classpath> + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/> + <compilerarg line="${javac.profile.cmd.line.arg}"/> + <compilerarg line="${javac.compilerargs}"/> + <customize/> + </javac> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac"> + <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <sequential> + <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}"> + <classpath> + <path path="@{classpath}"/> + </classpath> + </depend> + </sequential> + </macrodef> + <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${build.classes.dir}" name="destdir"/> + <sequential> + <fail unless="javac.includes">Must set javac.includes</fail> + <pathconvert pathsep="${line.separator}" property="javac.includes.binary"> + <path> + <filelist dir="@{destdir}" files="${javac.includes}"/> + </path> + <globmapper from="*.java" to="*.class"/> + </pathconvert> + <tempfile deleteonexit="true" property="javac.includesfile.binary"/> + <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/> + <delete> + <files includesfile="${javac.includesfile.binary}"/> + </delete> + <delete> + <fileset file="${javac.includesfile.binary}"/> + </delete> + </sequential> + </macrodef> + </target> + <target if="${junit.available}" name="-init-macrodef-junit-init"> + <condition else="false" property="nb.junit.batch" value="true"> + <and> + <istrue value="${junit.available}"/> + <not> + <isset property="test.method"/> + </not> + </and> + </condition> + <condition else="false" property="nb.junit.single" value="true"> + <and> + <istrue value="${junit.available}"/> + <isset property="test.method"/> + </and> + </condition> + </target> + <target name="-init-test-properties"> + <property name="test.binaryincludes" value="<nothing>"/> + <property name="test.binarytestincludes" value=""/> + <property name="test.binaryexcludes" value=""/> + </target> + <target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}"> + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element name="customize" optional="true"/> + <sequential> + <property name="junit.forkmode" value="perTest"/> + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> + <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <formatter type="brief" usefile="false"/> + <formatter type="xml"/> + <jvmarg value="-ea"/> + <customize/> + </junit> + </sequential> + </macrodef> + </target> + <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}"> + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element name="customize" optional="true"/> + <sequential> + <property name="junit.forkmode" value="perTest"/> + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> + <batchtest todir="${build.test.results.dir}"> + <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> + <filename name="@{testincludes}"/> + </fileset> + <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}"> + <filename name="${test.binarytestincludes}"/> + </fileset> + </batchtest> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <formatter type="brief" usefile="false"/> + <formatter type="xml"/> + <jvmarg value="-ea"/> + <customize/> + </junit> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/> + <target if="${testng.available}" name="-init-macrodef-testng"> + <macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element name="customize" optional="true"/> + <sequential> + <condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}"> + <isset property="test.method"/> + </condition> + <union id="test.set"> + <fileset dir="${test.src.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}"> + <filename name="@{testincludes}"/> + </fileset> + </union> + <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/> + <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="UyTube_estacion_de_trabajo" testname="TestNG tests" workingDir="${work.dir}"> + <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/> + <propertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </propertyset> + <customize/> + </testng> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-test-impl"> + <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element implicit="true" name="customize" optional="true"/> + <sequential> + <echo>No tests executed.</echo> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl"> + <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element implicit="true" name="customize" optional="true"/> + <sequential> + <j2seproject3:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> + <customize/> + </j2seproject3:junit> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl"> + <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element implicit="true" name="customize" optional="true"/> + <sequential> + <j2seproject3:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> + <customize/> + </j2seproject3:testng> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test"> + <macrodef name="test" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <sequential> + <j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> + <customize> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg line="${run.jvmargs}"/> + <jvmarg line="${run.jvmargs.ide}"/> + </customize> + </j2seproject3:test-impl> + </sequential> + </macrodef> + </target> + <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}"> + <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element name="customize" optional="true"/> + <sequential> + <property name="junit.forkmode" value="perTest"/> + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> + <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <formatter type="brief" usefile="false"/> + <formatter type="xml"/> + <jvmarg value="-ea"/> + <jvmarg line="${debug-args-line}"/> + <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/> + <customize/> + </junit> + </sequential> + </macrodef> + </target> + <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch"> + <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element name="customize" optional="true"/> + <sequential> + <property name="junit.forkmode" value="perTest"/> + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> + <batchtest todir="${build.test.results.dir}"> + <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> + <filename name="@{testincludes}"/> + </fileset> + <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}"> + <filename name="${test.binarytestincludes}"/> + </fileset> + </batchtest> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <formatter type="brief" usefile="false"/> + <formatter type="xml"/> + <jvmarg value="-ea"/> + <jvmarg line="${debug-args-line}"/> + <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/> + <customize/> + </junit> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl"> + <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element implicit="true" name="customize" optional="true"/> + <sequential> + <j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> + <customize/> + </j2seproject3:junit-debug> + </sequential> + </macrodef> + </target> + <target if="${testng.available}" name="-init-macrodef-testng-debug"> + <macrodef name="testng-debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${main.class}" name="testClass"/> + <attribute default="" name="testMethod"/> + <element name="customize2" optional="true"/> + <sequential> + <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}"> + <isset property="test.method"/> + </condition> + <condition else="-suitename UyTube_estacion_de_trabajo -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}"> + <matches pattern=".*\.xml" string="@{testClass}"/> + </condition> + <delete dir="${build.test.results.dir}" quiet="true"/> + <mkdir dir="${build.test.results.dir}"/> + <j2seproject3:debug classname="org.testng.TestNG" classpath="${debug.test.classpath}"> + <customize> + <customize2/> + <jvmarg value="-ea"/> + <arg line="${testng.debug.mode}"/> + <arg line="-d ${build.test.results.dir}"/> + <arg line="-listener org.testng.reporters.VerboseReporter"/> + <arg line="${testng.cmd.args}"/> + </customize> + </j2seproject3:debug> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl"> + <macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${main.class}" name="testClass"/> + <attribute default="" name="testMethod"/> + <element implicit="true" name="customize2" optional="true"/> + <sequential> + <j2seproject3:testng-debug testClass="@{testClass}" testMethod="@{testMethod}"> + <customize2/> + </j2seproject3:testng-debug> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit"> + <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <attribute default="${main.class}" name="testClass"/> + <attribute default="" name="testMethod"/> + <sequential> + <j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> + <customize> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg line="${run.jvmargs}"/> + <jvmarg line="${run.jvmargs.ide}"/> + </customize> + </j2seproject3:test-debug-impl> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng"> + <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <attribute default="${main.class}" name="testClass"/> + <attribute default="" name="testMethod"/> + <sequential> + <j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}"> + <customize2> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + </customize2> + </j2seproject3:testng-debug-impl> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/> + <!-- + pre NB7.2 profiling section; consider it deprecated + --> + <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/> + <target if="profiler.info.jvmargs.agent" name="-profile-pre-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target if="profiler.info.jvmargs.agent" name="-profile-post-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target if="profiler.info.jvmargs.agent" name="-profile-init-macrodef-profile"> + <macrodef name="resolve"> + <attribute name="name"/> + <attribute name="value"/> + <sequential> + <property name="@{name}" value="${env.@{value}}"/> + </sequential> + </macrodef> + <macrodef name="profile"> + <attribute default="${main.class}" name="classname"/> + <element name="customize" optional="true"/> + <sequential> + <property environment="env"/> + <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/> + <java classname="@{classname}" dir="${profiler.info.dir}" failonerror="${java.failonerror}" fork="true" jvm="${profiler.info.jvm}"> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg value="${profiler.info.jvmargs.agent}"/> + <jvmarg line="${profiler.info.jvmargs}"/> + <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> + <arg line="${application.args}"/> + <classpath> + <path path="${run.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" if="profiler.info.jvmargs.agent" name="-profile-init-check"> + <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail> + <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail> + </target> + <!-- + end of pre NB7.2 profiling section + --> + <target depends="-init-debug-args" name="-init-macrodef-nbjpda"> + <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${main.class}" name="name"/> + <attribute default="${debug.classpath}" name="classpath"/> + <attribute default="" name="stopclassname"/> + <sequential> + <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}"> + <classpath> + <path path="@{classpath}"/> + </classpath> + </nbjpdastart> + </sequential> + </macrodef> + <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${build.classes.dir}" name="dir"/> + <sequential> + <nbjpdareload> + <fileset dir="@{dir}" includes="${fix.classes}"> + <include name="${fix.includes}*.class"/> + </fileset> + </nbjpdareload> + </sequential> + </macrodef> + </target> + <target name="-init-debug-args"> + <property name="version-output" value="java version "${ant.java.version}"/> + <condition property="have-jdk-older-than-1.4"> + <or> + <contains string="${version-output}" substring="java version "1.0"/> + <contains string="${version-output}" substring="java version "1.1"/> + <contains string="${version-output}" substring="java version "1.2"/> + <contains string="${version-output}" substring="java version "1.3"/> + </or> + </condition> + <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none"> + <istrue value="${have-jdk-older-than-1.4}"/> + </condition> + <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem"> + <os family="windows"/> + </condition> + <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}"> + <isset property="debug.transport"/> + </condition> + </target> + <target depends="-init-debug-args" name="-init-macrodef-debug"> + <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${main.class}" name="classname"/> + <attribute default="${debug.classpath}" name="classpath"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true"> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg line="${debug-args-line}"/> + <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/> + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/> + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/> + <jvmarg line="${run.jvmargs}"/> + <jvmarg line="${run.jvmargs.ide}"/> + <classpath> + <path path="@{classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-java"> + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${main.class}" name="classname"/> + <attribute default="${run.classpath}" name="classpath"/> + <attribute default="jvm" name="jvm"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true"> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/> + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/> + <jvmarg line="${run.jvmargs}"/> + <jvmarg line="${run.jvmargs.ide}"/> + <classpath> + <path path="@{classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-copylibs"> + <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${manifest.file}" name="manifest"/> + <element name="customize" optional="true"/> + <sequential> + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> + <pathconvert property="run.classpath.without.build.classes.dir"> + <path path="${run.classpath}"/> + <map from="${build.classes.dir.resolved}" to=""/> + </pathconvert> + <pathconvert pathsep=" " property="jar.classpath"> + <path path="${run.classpath.without.build.classes.dir}"/> + <chainedmapper> + <flattenmapper/> + <filtermapper> + <replacestring from=" " to="%20"/> + </filtermapper> + <globmapper from="*" to="lib/*"/> + </chainedmapper> + </pathconvert> + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/> + <copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" manifestencoding="UTF-8" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}"> + <fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/> + <manifest> + <attribute name="Class-Path" value="${jar.classpath}"/> + <customize/> + </manifest> + </copylibs> + </sequential> + </macrodef> + </target> + <target name="-init-presetdef-jar"> + <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1"> + <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifestencoding="UTF-8"> + <j2seproject1:fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/> + </jar> + </presetdef> + </target> + <target name="-init-ap-cmdline-properties"> + <property name="annotation.processing.enabled" value="true"/> + <property name="annotation.processing.processors.list" value=""/> + <property name="annotation.processing.processor.options" value=""/> + <property name="annotation.processing.run.all.processors" value="true"/> + <property name="javac.processorpath" value="${javac.classpath}"/> + <property name="javac.test.processorpath" value="${javac.test.classpath}"/> + <condition property="ap.supported.internal" value="true"> + <not> + <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/> + </not> + </condition> + </target> + <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported"> + <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}"> + <isfalse value="${annotation.processing.run.all.processors}"/> + </condition> + <condition else="" property="ap.proc.none.internal" value="-proc:none"> + <isfalse value="${annotation.processing.enabled}"/> + </condition> + </target> + <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline"> + <property name="ap.cmd.line.internal" value=""/> + </target> + <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/> + <!-- + =================== + COMPILATION SECTION + =================== + --> + <target name="-deps-jar-init" unless="built-jar.properties"> + <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/> + <delete file="${built-jar.properties}" quiet="true"/> + </target> + <target if="already.built.jar.${basedir}" name="-warn-already-built-jar"> + <echo level="warn" message="Cycle detected: UyTube_estacion_de_trabajo was already built"/> + </target> + <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps"> + <mkdir dir="${build.dir}"/> + <touch file="${built-jar.properties}" verbose="false"/> + <property file="${built-jar.properties}" prefix="already.built.jar."/> + <antcall target="-warn-already-built-jar"/> + <propertyfile file="${built-jar.properties}"> + <entry key="${basedir}" value=""/> + </propertyfile> + </target> + <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/> + <target depends="init" name="-check-automatic-build"> + <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/> + </target> + <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build"> + <antcall target="clean"/> + </target> + <target depends="init,deps-jar" name="-pre-pre-compile"> + <mkdir dir="${build.classes.dir}"/> + </target> + <target name="-pre-compile"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target if="do.depend.true" name="-compile-depend"> + <pathconvert property="build.generated.subdirs"> + <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false"> + <include name="*"/> + </dirset> + </pathconvert> + <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/> + </target> + <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile"> + <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/> + <copy todir="${build.classes.dir}"> + <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> + </copy> + </target> + <target if="has.persistence.xml" name="-copy-persistence-xml"> + <mkdir dir="${build.classes.dir}/META-INF"/> + <copy todir="${build.classes.dir}/META-INF"> + <fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/> + </copy> + </target> + <target name="-post-compile"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/> + <target name="-pre-compile-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single"> + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> + <j2seproject3:force-recompile/> + <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/> + </target> + <target name="-post-compile-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/> + <!-- + ==================== + JAR BUILDING SECTION + ==================== + --> + <target depends="init" name="-pre-pre-jar"> + <dirname file="${dist.jar}" property="dist.jar.dir"/> + <mkdir dir="${dist.jar.dir}"/> + </target> + <target name="-pre-jar"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init" if="do.archive" name="-do-jar-create-manifest" unless="manifest.available"> + <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> + <touch file="${tmp.manifest.file}" verbose="false"/> + </target> + <target depends="init" if="do.archive+manifest.available" name="-do-jar-copy-manifest"> + <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> + <copy encoding="${manifest.encoding}" file="${manifest.file}" outputencoding="UTF-8" tofile="${tmp.manifest.file}"/> + </target> + <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+main.class.available" name="-do-jar-set-mainclass"> + <manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update"> + <attribute name="Main-Class" value="${main.class}"/> + </manifest> + </target> + <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+profile.available" name="-do-jar-set-profile"> + <manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update"> + <attribute name="Profile" value="${javac.profile}"/> + </manifest> + </target> + <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-set-splashscreen"> + <basename file="${application.splash}" property="splashscreen.basename"/> + <mkdir dir="${build.classes.dir}/META-INF"/> + <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/> + <manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update"> + <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/> + </manifest> + </target> + <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.mkdist" name="-do-jar-copylibs"> + <j2seproject3:copylibs manifest="${tmp.manifest.file}"/> + <echo level="info">To run this application from the command line without Ant, try:</echo> + <property location="${dist.jar}" name="dist.jar.resolved"/> + <echo level="info">java -jar "${dist.jar.resolved}"</echo> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.archive" name="-do-jar-jar" unless="do.mkdist"> + <j2seproject1:jar manifest="${tmp.manifest.file}"/> + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> + <property location="${dist.jar}" name="dist.jar.resolved"/> + <pathconvert property="run.classpath.with.dist.jar"> + <path path="${run.classpath}"/> + <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/> + </pathconvert> + <condition else="" property="jar.usage.message" value="To run this application from the command line without Ant, try:${line.separator}${platform.java} -cp ${run.classpath.with.dist.jar} ${main.class}"> + <isset property="main.class.available"/> + </condition> + <condition else="debug" property="jar.usage.level" value="info"> + <isset property="main.class.available"/> + </condition> + <echo level="${jar.usage.level}" message="${jar.usage.message}"/> + </target> + <target depends="-do-jar-copylibs" if="do.archive" name="-do-jar-delete-manifest"> + <delete> + <fileset file="${tmp.manifest.file}"/> + </delete> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-do-jar-jar,-do-jar-delete-manifest" name="-do-jar-without-libraries"/> + <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-do-jar-copylibs,-do-jar-delete-manifest" name="-do-jar-with-libraries"/> + <target name="-post-jar"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-jar,-do-jar-without-libraries,-do-jar-with-libraries,-post-jar" name="-do-jar"/> + <target depends="init,compile,-pre-jar,-do-jar,-post-jar" description="Build JAR." name="jar"/> + <!-- + ================= + EXECUTION SECTION + ================= + --> + <target depends="init,compile" description="Run a main class." name="run"> + <j2seproject1:java> + <customize> + <arg line="${application.args}"/> + </customize> + </j2seproject1:java> + </target> + <target name="-do-not-recompile"> + <property name="javac.includes.binary" value=""/> + </target> + <target depends="init,compile-single" name="run-single"> + <fail unless="run.class">Must select one file in the IDE or set run.class</fail> + <j2seproject1:java classname="${run.class}"/> + </target> + <target depends="init,compile-test-single" name="run-test-with-main"> + <fail unless="run.class">Must select one file in the IDE or set run.class</fail> + <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/> + </target> + <!-- + ================= + DEBUGGING SECTION + ================= + --> + <target depends="init" if="netbeans.home" name="-debug-start-debugger"> + <j2seproject1:nbjpdastart name="${debug.class}"/> + </target> + <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test"> + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/> + </target> + <target depends="init,compile" name="-debug-start-debuggee"> + <j2seproject3:debug> + <customize> + <arg line="${application.args}"/> + </customize> + </j2seproject3:debug> + </target> + <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/> + <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto"> + <j2seproject1:nbjpdastart stopclassname="${main.class}"/> + </target> + <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/> + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single"> + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail> + <j2seproject3:debug classname="${debug.class}"/> + </target> + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/> + <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test"> + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail> + <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/> + </target> + <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/> + <target depends="init" name="-pre-debug-fix"> + <fail unless="fix.includes">Must set fix.includes</fail> + <property name="javac.includes" value="${fix.includes}.java"/> + </target> + <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix"> + <j2seproject1:nbjpdareload/> + </target> + <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/> + <!-- + ================= + PROFILING SECTION + ================= + --> + <!-- + pre NB7.2 profiler integration + --> + <target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72"> + <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail> + <nbprofiledirect> + <classpath> + <path path="${run.classpath}"/> + </classpath> + </nbprofiledirect> + <profile/> + </target> + <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="profiler.info.jvmargs.agent" name="-profile-single-pre72"> + <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail> + <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail> + <nbprofiledirect> + <classpath> + <path path="${run.classpath}"/> + </classpath> + </nbprofiledirect> + <profile classname="${profile.class}"/> + </target> + <target depends="profile-init,compile-single" if="profiler.info.jvmargs.agent" name="-profile-applet-pre72"> + <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail> + <nbprofiledirect> + <classpath> + <path path="${run.classpath}"/> + </classpath> + </nbprofiledirect> + <profile classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </profile> + </target> + <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72"> + <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail> + <nbprofiledirect> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + </nbprofiledirect> + <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true"> + <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> + <jvmarg value="${profiler.info.jvmargs.agent}"/> + <jvmarg line="${profiler.info.jvmargs}"/> + <test name="${profile.class}"/> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <formatter type="brief" usefile="false"/> + <formatter type="xml"/> + </junit> + </target> + <!-- + end of pre NB72 profiling section + --> + <target if="netbeans.home" name="-profile-check"> + <condition property="profiler.configured"> + <or> + <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/> + <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/> + </or> + </condition> + </target> + <target depends="-profile-check,-profile-pre72" description="Profile a project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent"> + <startprofiler/> + <antcall target="run"/> + </target> + <target depends="-profile-check,-profile-single-pre72" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-single" unless="profiler.info.jvmargs.agent"> + <fail unless="run.class">Must select one file in the IDE or set run.class</fail> + <startprofiler/> + <antcall target="run-single"/> + </target> + <target depends="-profile-test-single-pre72" description="Profile a selected test in the IDE." name="profile-test-single"/> + <target depends="-profile-check" description="Profile a selected test in the IDE." if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs"> + <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail> + <startprofiler/> + <antcall target="test-single"/> + </target> + <target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main"> + <fail unless="run.class">Must select one file in the IDE or set run.class</fail> + <startprofiler/> + <antcall target="run-test-with-main"/> + </target> + <target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <startprofiler/> + <antcall target="run-applet"/> + </target> + <!-- + =============== + JAVADOC SECTION + =============== + --> + <target depends="init" if="have.sources" name="-javadoc-build"> + <mkdir dir="${dist.javadoc.dir}"/> + <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}"> + <and> + <isset property="endorsed.classpath.cmd.line.arg"/> + <not> + <equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/> + </not> + </and> + </condition> + <condition else="" property="bug5101868workaround" value="*.java"> + <matches pattern="1\.[56](\..*)?" string="${java.version}"/> + </condition> + <javadoc additionalparam="-J-Dfile.encoding=${file.encoding} ${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}"> + <classpath> + <path path="${javac.classpath}"/> + </classpath> + <fileset dir="${src.dir}" excludes="${bug5101868workaround},${excludes}" includes="${includes}"> + <filename name="**/*.java"/> + </fileset> + <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false"> + <include name="**/*.java"/> + <exclude name="*.java"/> + </fileset> + <arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/> + </javadoc> + <copy todir="${dist.javadoc.dir}"> + <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}"> + <filename name="**/doc-files/**"/> + </fileset> + <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false"> + <include name="**/doc-files/**"/> + </fileset> + </copy> + </target> + <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview"> + <nbbrowse file="${dist.javadoc.dir}/index.html"/> + </target> + <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/> + <!-- + ========================= + TEST COMPILATION SECTION + ========================= + --> + <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test"> + <mkdir dir="${build.test.classes.dir}"/> + </target> + <target name="-pre-compile-test"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target if="do.depend.true" name="-compile-test-depend"> + <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/> + </target> + <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test"> + <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/> + <copy todir="${build.test.classes.dir}"> + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> + </copy> + </target> + <target name="-post-compile-test"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/> + <target name="-pre-compile-test-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single"> + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> + <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/> + <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/> + <copy todir="${build.test.classes.dir}"> + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> + </copy> + </target> + <target name="-post-compile-test-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/> + <!-- + ======================= + TEST EXECUTION SECTION + ======================= + --> + <target depends="init" if="have.tests" name="-pre-test-run"> + <mkdir dir="${build.test.results.dir}"/> + </target> + <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run"> + <j2seproject3:test includes="${includes}" testincludes="**/*Test.java"/> + </target> + <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run"> + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail> + </target> + <target depends="init" if="have.tests" name="test-report"/> + <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/> + <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/> + <target depends="init" if="have.tests" name="-pre-test-run-single"> + <mkdir dir="${build.test.results.dir}"/> + </target> + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single"> + <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail> + <j2seproject3:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/> + </target> + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single"> + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail> + </target> + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/> + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method"> + <fail unless="test.class">Must select some files in the IDE or set test.class</fail> + <fail unless="test.method">Must select some method in the IDE or set test.method</fail> + <j2seproject3:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/> + </target> + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method"> + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail> + </target> + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/> + <!-- + ======================= + TEST DEBUGGING SECTION + ======================= + --> + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test"> + <fail unless="test.class">Must select one file in the IDE or set test.class</fail> + <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/> + </target> + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method"> + <fail unless="test.class">Must select one file in the IDE or set test.class</fail> + <fail unless="test.method">Must select some method in the IDE or set test.method</fail> + <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/> + </target> + <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test"> + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/> + </target> + <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/> + <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/> + <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test"> + <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/> + </target> + <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/> + <!-- + ========================= + APPLET EXECUTION SECTION + ========================= + --> + <target depends="init,compile-single" name="run-applet"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <j2seproject1:java classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </j2seproject1:java> + </target> + <!-- + ========================= + APPLET DEBUGGING SECTION + ========================= + --> + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <j2seproject3:debug classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </j2seproject3:debug> + </target> + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/> + <!-- + =============== + CLEANUP SECTION + =============== + --> + <target name="-deps-clean-init" unless="built-clean.properties"> + <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/> + <delete file="${built-clean.properties}" quiet="true"/> + </target> + <target if="already.built.clean.${basedir}" name="-warn-already-built-clean"> + <echo level="warn" message="Cycle detected: UyTube_estacion_de_trabajo was already built"/> + </target> + <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps"> + <mkdir dir="${build.dir}"/> + <touch file="${built-clean.properties}" verbose="false"/> + <property file="${built-clean.properties}" prefix="already.built.clean."/> + <antcall target="-warn-already-built-clean"/> + <propertyfile file="${built-clean.properties}"> + <entry key="${basedir}" value=""/> + </propertyfile> + </target> + <target depends="init" name="-do-clean"> + <delete dir="${build.dir}"/> + <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/> + </target> + <target name="-post-clean"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/> + <target name="-check-call-dep"> + <property file="${call.built.properties}" prefix="already.built."/> + <condition property="should.call.dep"> + <and> + <not> + <isset property="already.built.${call.subproject}"/> + </not> + <available file="${call.script}"/> + </and> + </condition> + </target> + <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep"> + <ant antfile="${call.script}" inheritall="false" target="${call.target}"> + <propertyset> + <propertyref prefix="transfer."/> + <mapper from="transfer.*" to="*" type="glob"/> + </propertyset> + </ant> + </target> +</project> diff --git a/UyTube_aplicacion/nbproject/genfiles.properties b/UyTube_estacion_de_trabajo/nbproject/genfiles.properties similarity index 67% rename from UyTube_aplicacion/nbproject/genfiles.properties rename to UyTube_estacion_de_trabajo/nbproject/genfiles.properties index 28813501de58aa4cdf9ec34a7e1a14b015dc40cd..3d5421537333a053312b4b046032f0c5a447d769 100644 --- a/UyTube_aplicacion/nbproject/genfiles.properties +++ b/UyTube_estacion_de_trabajo/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=59ef3ee3 -build.xml.script.CRC32=1be81de8 +build.xml.data.CRC32=03fbe688 +build.xml.script.CRC32=fb5a3579 build.xml.stylesheet.CRC32=8064a381@1.80.1.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=59ef3ee3 -nbproject/build-impl.xml.script.CRC32=61d910f1 +nbproject/build-impl.xml.data.CRC32=03fbe688 +nbproject/build-impl.xml.script.CRC32=3cd63f78 nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/UyTube_estacion_de_trabajo/nbproject/project.properties b/UyTube_estacion_de_trabajo/nbproject/project.properties new file mode 100644 index 0000000000000000000000000000000000000000..6843fdf606ff30ab449c9cbff66a1f13679656fc --- /dev/null +++ b/UyTube_estacion_de_trabajo/nbproject/project.properties @@ -0,0 +1,81 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/UyTube_estacion_de_trabajo.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +file.reference.JCalendar_1.4.jar=librerias\\JCalendar_1.4.jar +file.reference.UyTube_logica.jar=librerias\\UyTube_logica.jar +includes=** +jar.compress=false +javac.classpath=\ + ${libs.PostgreSQLDriver.classpath}:\ + ${libs.absolutelayout.classpath}:\ + ${libs.eclipselink.classpath}:\ + ${file.reference.JCalendar_1.4.jar}:\ + ${file.reference.UyTube_logica.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=Presentacion.frmPrincipal +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/UyTube_estacion_de_trabajo/nbproject/project.xml b/UyTube_estacion_de_trabajo/nbproject/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..d890fe9df657da9c1d09bc69b2932cae649c29cd --- /dev/null +++ b/UyTube_estacion_de_trabajo/nbproject/project.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.java.j2seproject</type> + <configuration> + <data xmlns="http://www.netbeans.org/ns/j2se-project/3"> + <name>UyTube_estacion_de_trabajo</name> + <source-roots> + <root id="src.dir"/> + </source-roots> + <test-roots> + <root id="test.src.dir"/> + </test-roots> + </data> + </configuration> +</project> diff --git a/UyTube_aplicacion/src/Imagenes/about.png b/UyTube_estacion_de_trabajo/src/Imagenes/about.png similarity index 100% rename from UyTube_aplicacion/src/Imagenes/about.png rename to UyTube_estacion_de_trabajo/src/Imagenes/about.png diff --git a/UyTube_aplicacion/src/Imagenes/des.jpeg b/UyTube_estacion_de_trabajo/src/Imagenes/des.jpeg similarity index 100% rename from UyTube_aplicacion/src/Imagenes/des.jpeg rename to UyTube_estacion_de_trabajo/src/Imagenes/des.jpeg diff --git a/UyTube_aplicacion/src/Imagenes/icono.jpg b/UyTube_estacion_de_trabajo/src/Imagenes/icono.jpg similarity index 100% rename from UyTube_aplicacion/src/Imagenes/icono.jpg rename to UyTube_estacion_de_trabajo/src/Imagenes/icono.jpg diff --git a/UyTube_aplicacion/src/Imagenes/ukp.png b/UyTube_estacion_de_trabajo/src/Imagenes/ukp.png similarity index 100% rename from UyTube_aplicacion/src/Imagenes/ukp.png rename to UyTube_estacion_de_trabajo/src/Imagenes/ukp.png diff --git a/UyTube_aplicacion/src/Presentacion/Categoria/frmAltaCategoria.form b/UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmAltaCategoria.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Categoria/frmAltaCategoria.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmAltaCategoria.form diff --git a/UyTube_aplicacion/src/Presentacion/Categoria/frmAltaCategoria.java b/UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmAltaCategoria.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Categoria/frmAltaCategoria.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmAltaCategoria.java diff --git a/UyTube_aplicacion/src/Presentacion/Categoria/frmConsultaCategoria.form b/UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmConsultaCategoria.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Categoria/frmConsultaCategoria.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmConsultaCategoria.form diff --git a/UyTube_aplicacion/src/Presentacion/Categoria/frmConsultaCategoria.java b/UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmConsultaCategoria.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Categoria/frmConsultaCategoria.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmConsultaCategoria.java diff --git a/UyTube_aplicacion/src/Presentacion/Categoria/frmListarCategorias.form b/UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmListarCategorias.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Categoria/frmListarCategorias.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmListarCategorias.form diff --git a/UyTube_aplicacion/src/Presentacion/Categoria/frmListarCategorias.java b/UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmListarCategorias.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Categoria/frmListarCategorias.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Categoria/frmListarCategorias.java diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.form b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.form rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.form diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.java b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.java rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.java diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.form b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.form rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.form diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.java b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.java rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.java diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.form b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.form rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.form diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.java b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.java rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.java diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.form b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.form rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.form diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.java b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.java rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.java diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.form b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.form rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.form diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.java b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.java rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.java diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.form b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.form rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.form diff --git a/UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.java b/UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.java rename to UyTube_estacion_de_trabajo/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.java diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmAltaUsuario.form b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmAltaUsuario.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmAltaUsuario.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmAltaUsuario.form diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmAltaUsuario.java b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmAltaUsuario.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmAltaUsuario.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmAltaUsuario.java diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmBajaUsuario.form b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmBajaUsuario.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmBajaUsuario.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmBajaUsuario.form diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmBajaUsuario.java b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmBajaUsuario.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmBajaUsuario.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmBajaUsuario.java diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmConsultaUsuario.form b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmConsultaUsuario.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmConsultaUsuario.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmConsultaUsuario.form diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmConsultaUsuario.java b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmConsultaUsuario.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmConsultaUsuario.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmConsultaUsuario.java diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.form b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.form diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.java b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.java diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.form b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.form diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.java b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.java diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmListarUsuarios.form b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmListarUsuarios.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmListarUsuarios.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmListarUsuarios.form diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmListarUsuarios.java b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmListarUsuarios.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmListarUsuarios.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmListarUsuarios.java diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmModificarUsuario.form b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmModificarUsuario.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmModificarUsuario.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmModificarUsuario.form diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmModificarUsuario.java b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmModificarUsuario.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmModificarUsuario.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmModificarUsuario.java diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmSeguirUsuario.form b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmSeguirUsuario.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmSeguirUsuario.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmSeguirUsuario.form diff --git a/UyTube_aplicacion/src/Presentacion/Usuario/frmSeguirUsuario.java b/UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmSeguirUsuario.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Usuario/frmSeguirUsuario.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Usuario/frmSeguirUsuario.java diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmAltaVideo.form b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmAltaVideo.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmAltaVideo.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmAltaVideo.form diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmAltaVideo.java b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmAltaVideo.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmAltaVideo.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmAltaVideo.java diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmComentarVideo.form b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmComentarVideo.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmComentarVideo.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmComentarVideo.form diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmComentarVideo.java b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmComentarVideo.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmComentarVideo.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmComentarVideo.java diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmConsultaVideo.form b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmConsultaVideo.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmConsultaVideo.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmConsultaVideo.form diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmConsultaVideo.java b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmConsultaVideo.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmConsultaVideo.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmConsultaVideo.java diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmConsultaVideoEliminado.form b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmConsultaVideoEliminado.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmConsultaVideoEliminado.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmConsultaVideoEliminado.form diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmConsultaVideoEliminado.java b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmConsultaVideoEliminado.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmConsultaVideoEliminado.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmConsultaVideoEliminado.java diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmModificarVideo.form b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmModificarVideo.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmModificarVideo.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmModificarVideo.form diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmModificarVideo.java b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmModificarVideo.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmModificarVideo.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmModificarVideo.java diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmValorarVideo.form b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmValorarVideo.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmValorarVideo.form rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmValorarVideo.form diff --git a/UyTube_aplicacion/src/Presentacion/Video/frmValorarVideo.java b/UyTube_estacion_de_trabajo/src/Presentacion/Video/frmValorarVideo.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/Video/frmValorarVideo.java rename to UyTube_estacion_de_trabajo/src/Presentacion/Video/frmValorarVideo.java diff --git a/UyTube_aplicacion/src/Presentacion/frmAcercaDeNos.form b/UyTube_estacion_de_trabajo/src/Presentacion/frmAcercaDeNos.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/frmAcercaDeNos.form rename to UyTube_estacion_de_trabajo/src/Presentacion/frmAcercaDeNos.form diff --git a/UyTube_aplicacion/src/Presentacion/frmAcercaDeNos.java b/UyTube_estacion_de_trabajo/src/Presentacion/frmAcercaDeNos.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/frmAcercaDeNos.java rename to UyTube_estacion_de_trabajo/src/Presentacion/frmAcercaDeNos.java diff --git a/UyTube_aplicacion/src/Presentacion/frmInicioSesion.form b/UyTube_estacion_de_trabajo/src/Presentacion/frmInicioSesion.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/frmInicioSesion.form rename to UyTube_estacion_de_trabajo/src/Presentacion/frmInicioSesion.form diff --git a/UyTube_aplicacion/src/Presentacion/frmInicioSesion.java b/UyTube_estacion_de_trabajo/src/Presentacion/frmInicioSesion.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/frmInicioSesion.java rename to UyTube_estacion_de_trabajo/src/Presentacion/frmInicioSesion.java diff --git a/UyTube_aplicacion/src/Presentacion/frmPrincipal.form b/UyTube_estacion_de_trabajo/src/Presentacion/frmPrincipal.form similarity index 100% rename from UyTube_aplicacion/src/Presentacion/frmPrincipal.form rename to UyTube_estacion_de_trabajo/src/Presentacion/frmPrincipal.form diff --git a/UyTube_aplicacion/src/Presentacion/frmPrincipal.java b/UyTube_estacion_de_trabajo/src/Presentacion/frmPrincipal.java similarity index 100% rename from UyTube_aplicacion/src/Presentacion/frmPrincipal.java rename to UyTube_estacion_de_trabajo/src/Presentacion/frmPrincipal.java diff --git a/UyTube_logica/Imagenes/about.png b/UyTube_logica/Imagenes/about.png new file mode 100644 index 0000000000000000000000000000000000000000..937e151247a0fb9b1e63ea91a4ea849744f012da Binary files /dev/null and b/UyTube_logica/Imagenes/about.png differ diff --git a/UyTube_logica/Imagenes/des.jpeg b/UyTube_logica/Imagenes/des.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..7a7eb2ebcdb13adad971a990838700e2ba23ab7d Binary files /dev/null and b/UyTube_logica/Imagenes/des.jpeg differ diff --git a/UyTube_logica/Imagenes/icono.jpg b/UyTube_logica/Imagenes/icono.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e1c6c0706f82d5f48c7f8719a85952965bb15b21 Binary files /dev/null and b/UyTube_logica/Imagenes/icono.jpg differ diff --git a/UyTube_logica/Imagenes/perfiles/JotaJota96.JPG b/UyTube_logica/Imagenes/perfiles/JotaJota96.JPG new file mode 100644 index 0000000000000000000000000000000000000000..3efaaeaebf1d20cb7f712514b0cfc0096f6b0007 Binary files /dev/null and b/UyTube_logica/Imagenes/perfiles/JotaJota96.JPG differ diff --git a/UyTube_logica/Imagenes/perfiles/LuC31G.jpg b/UyTube_logica/Imagenes/perfiles/LuC31G.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f22efc5908db0af0594d76d75ae3f89ebdff93a6 Binary files /dev/null and b/UyTube_logica/Imagenes/perfiles/LuC31G.jpg differ diff --git a/UyTube_logica/Imagenes/perfiles/MCBolso.jpg b/UyTube_logica/Imagenes/perfiles/MCBolso.jpg new file mode 100644 index 0000000000000000000000000000000000000000..35469b84ed023de4e5a7581095434bcbf69719d1 Binary files /dev/null and b/UyTube_logica/Imagenes/perfiles/MCBolso.jpg differ diff --git a/UyTube_logica/Imagenes/perfiles/camilillo15.jpg b/UyTube_logica/Imagenes/perfiles/camilillo15.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dc36ba95eecc24c956cbaf03f53dccda2f9317bb Binary files /dev/null and b/UyTube_logica/Imagenes/perfiles/camilillo15.jpg differ diff --git a/UyTube_logica/Imagenes/perfiles/jarrieta31.jpg b/UyTube_logica/Imagenes/perfiles/jarrieta31.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d54ec04f4eee56374821fcfb9c9928a761cbc10b Binary files /dev/null and b/UyTube_logica/Imagenes/perfiles/jarrieta31.jpg differ diff --git a/UyTube_logica/Imagenes/ukp.png b/UyTube_logica/Imagenes/ukp.png new file mode 100644 index 0000000000000000000000000000000000000000..5939b67d080df91af9d46511590d81eda44a17b9 Binary files /dev/null and b/UyTube_logica/Imagenes/ukp.png differ diff --git a/UyTube_aplicacion/build.xml b/UyTube_logica/build.xml similarity index 94% rename from UyTube_aplicacion/build.xml rename to UyTube_logica/build.xml index f306b19fb55b71534ac8db6abc88697b7337702b..43b76d965608e1c3ecff54241bde903d6e989ba6 100644 --- a/UyTube_aplicacion/build.xml +++ b/UyTube_logica/build.xml @@ -7,8 +7,8 @@ <!-- the Compile on Save feature is turned off for the project. --> <!-- You can turn off the Compile on Save (or Deploy on Save) setting --> <!-- in the project's Project Properties dialog box.--> -<project name="UyTube" default="default" basedir="."> - <description>Builds, tests, and runs the project UyTube.</description> +<project name="UyTube_logica" default="default" basedir="."> + <description>Builds, tests, and runs the project UyTube_logica.</description> <import file="nbproject/build-impl.xml"/> <!-- @@ -58,7 +58,7 @@ An example of overriding the target for project execution could look like this: - <target name="run" depends="UyTube-impl.jar"> + <target name="run" depends="UyTube_logica-impl.jar"> <exec dir="bin" executable="launcher.exe"> <arg file="${dist.jar}"/> </exec> diff --git a/UyTube_logica/librerias/JCalendar_1.4.jar b/UyTube_logica/librerias/JCalendar_1.4.jar new file mode 100644 index 0000000000000000000000000000000000000000..617a3351ca8ade8fa6d57648423a1f97e14c02dc Binary files /dev/null and b/UyTube_logica/librerias/JCalendar_1.4.jar differ diff --git a/UyTube_logica/manifest.mf b/UyTube_logica/manifest.mf new file mode 100644 index 0000000000000000000000000000000000000000..328e8e5bc3b7f1f7bad2bc0751a933e00c801983 --- /dev/null +++ b/UyTube_logica/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/UyTube_aplicacion/nbproject/build-impl.xml b/UyTube_logica/nbproject/build-impl.xml similarity index 99% rename from UyTube_aplicacion/nbproject/build-impl.xml rename to UyTube_logica/nbproject/build-impl.xml index 159a870d5d0032ec917dc3f1de51f19fdd758919..e534ff29d700197e2f680d91a8a7397bf3303f74 100644 --- a/UyTube_aplicacion/nbproject/build-impl.xml +++ b/UyTube_logica/nbproject/build-impl.xml @@ -19,7 +19,7 @@ is divided into following sections: - cleanup --> -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="UyTube-impl"> +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="UyTube_logica-impl"> <fail message="Please build using Ant 1.8.0 or higher."> <condition> <not> @@ -450,7 +450,7 @@ is divided into following sections: </fileset> </union> <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/> - <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="UyTube" testname="TestNG tests" workingDir="${work.dir}"> + <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="UyTube_logica" testname="TestNG tests" workingDir="${work.dir}"> <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/> <propertyset> <propertyref prefix="test-sys-prop."/> @@ -601,7 +601,7 @@ is divided into following sections: <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}"> <isset property="test.method"/> </condition> - <condition else="-suitename UyTube -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}"> + <condition else="-suitename UyTube_logica -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}"> <matches pattern=".*\.xml" string="@{testClass}"/> </condition> <delete dir="${build.test.results.dir}" quiet="true"/> @@ -893,7 +893,7 @@ is divided into following sections: <delete file="${built-jar.properties}" quiet="true"/> </target> <target if="already.built.jar.${basedir}" name="-warn-already-built-jar"> - <echo level="warn" message="Cycle detected: UyTube was already built"/> + <echo level="warn" message="Cycle detected: UyTube_logica was already built"/> </target> <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps"> <mkdir dir="${build.dir}"/> @@ -1378,7 +1378,7 @@ is divided into following sections: <delete file="${built-clean.properties}" quiet="true"/> </target> <target if="already.built.clean.${basedir}" name="-warn-already-built-clean"> - <echo level="warn" message="Cycle detected: UyTube was already built"/> + <echo level="warn" message="Cycle detected: UyTube_logica was already built"/> </target> <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps"> <mkdir dir="${build.dir}"/> diff --git a/UyTube_logica/nbproject/genfiles.properties b/UyTube_logica/nbproject/genfiles.properties new file mode 100644 index 0000000000000000000000000000000000000000..adfa922bf06864cd7d6c248aa001244f11967723 --- /dev/null +++ b/UyTube_logica/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=9a5fdd84 +build.xml.script.CRC32=2a1803ce +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=9a5fdd84 +nbproject/build-impl.xml.script.CRC32=1c0cb7b4 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/UyTube_aplicacion/nbproject/project.properties b/UyTube_logica/nbproject/project.properties similarity index 62% rename from UyTube_aplicacion/nbproject/project.properties rename to UyTube_logica/nbproject/project.properties index 4977975f1ffac44dbd757e50e32fc5b7de9f8d00..326ba1b35441a746c982025d52f23880b2033655 100644 --- a/UyTube_aplicacion/nbproject/project.properties +++ b/UyTube_logica/nbproject/project.properties @@ -4,8 +4,6 @@ annotation.processing.processor.options=-Aeclipselink.canonicalmodel.use_static_ annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=UyTube -application.vendor=Juan build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: @@ -26,60 +24,28 @@ debug.test.classpath=\ dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist -dist.jar=${dist.dir}/UyTube.jar +dist.jar=${dist.dir}/UyTube_logica.jar dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= excludes= -file.reference.jcalendar-1.4.jar=C:\\Users\\Juan\\Desktop\\jcalendar-1.4.jar -<<<<<<< HEAD -<<<<<<< HEAD -file.reference.jcalendar-1.4.jar-1=D:\\Users\\Facu\\Downloads\\jcalendar-1.4.jar -file.reference.jcalendar-1.4.jar-2=C:\\Users\\pc01\\Downloads\\jcalendar-1.4.jar -======= ->>>>>>> origin/pre_master -======= -file.reference.jcalendar-1.4.jar-1=C:\\Users\\Dofus\\Documents\\NetBeansProjects\\jcalendar-1.4.jar ->>>>>>> pre_master -file.reference.jcalendar-1.4.jar-3=D:\\Users\\Facu\\Downloads\\jcalendar-1.4.jar -file.reference.jcalendar-1.4.jar-4=/home/administrador/tecnologo/4to_semestre/PA/Lab-1/jcalendar-1.4.jar -file.reference.jcalendar-1.4.jar-5=C:\\Program Files\\NetBeans 8.2\\extras\\jcalendar-1.4.jar +file.reference.JCalendar_1.4.jar=librerias\\JCalendar_1.4.jar includes=** jar.compress=false javac.classpath=\ - ${libs.absolutelayout.classpath}:\ - <<<<<<< HEAD:\ - ${file.reference.jcalendar-1.4.jar-3}:\ - ${file.reference.jcalendar-1.4.jar-4}:\ - ${file.reference.jcalendar-1.4.jar-5}:\ - ${libs.PostgreSQLDriver.classpath}:\ ${libs.eclipselink.classpath}:\ - ${libs.Logica.classpath} - <<<<<<< HEAD:\ - ${file.reference.jcalendar-1.4.jar-1} - ${file.reference.jcalendar-1.4.jar}:\ - ${file.reference.jcalendar-1.4.jar-1}:\ - ${file.reference.jcalendar-1.4.jar-2} -======= - ${file.reference.jcalendar-1.4.jar} ->>>>>>> origin/pre_master -======= - ${file.reference.jcalendar-1.4.jar}:\ - ${file.reference.jcalendar-1.4.jar-1} ->>>>>>> pre_master + ${libs.PostgreSQLDriver.classpath}:\ + ${libs.absolutelayout.classpath}:\ + ${file.reference.JCalendar_1.4.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.external.vm=true javac.processorpath=\ - ${javac.classpath}:\ - ${libs.eclipselinkmodelgen.classpath} + ${javac.classpath} javac.source=1.8 javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit_4.classpath}:\ - ${libs.hamcrest.classpath} + ${build.classes.dir} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= diff --git a/UyTube_aplicacion/nbproject/project.xml b/UyTube_logica/nbproject/project.xml similarity index 92% rename from UyTube_aplicacion/nbproject/project.xml rename to UyTube_logica/nbproject/project.xml index 27c2a88eff8d682d1a3bad61500917bbcf934605..c472791248d05741efd02d4804ddbcdff59f5249 100644 --- a/UyTube_aplicacion/nbproject/project.xml +++ b/UyTube_logica/nbproject/project.xml @@ -3,7 +3,7 @@ <type>org.netbeans.modules.java.j2seproject</type> <configuration> <data xmlns="http://www.netbeans.org/ns/j2se-project/3"> - <name>UyTube</name> + <name>UyTube_logica</name> <source-roots> <root id="src.dir"/> </source-roots> diff --git a/UyTube_logica/src/Imagenes/about.png b/UyTube_logica/src/Imagenes/about.png new file mode 100644 index 0000000000000000000000000000000000000000..937e151247a0fb9b1e63ea91a4ea849744f012da Binary files /dev/null and b/UyTube_logica/src/Imagenes/about.png differ diff --git a/UyTube_logica/src/Imagenes/des.jpeg b/UyTube_logica/src/Imagenes/des.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..7a7eb2ebcdb13adad971a990838700e2ba23ab7d Binary files /dev/null and b/UyTube_logica/src/Imagenes/des.jpeg differ diff --git a/UyTube_logica/src/Imagenes/icono.jpg b/UyTube_logica/src/Imagenes/icono.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e1c6c0706f82d5f48c7f8719a85952965bb15b21 Binary files /dev/null and b/UyTube_logica/src/Imagenes/icono.jpg differ diff --git a/UyTube_logica/src/Imagenes/ukp.png b/UyTube_logica/src/Imagenes/ukp.png new file mode 100644 index 0000000000000000000000000000000000000000..5939b67d080df91af9d46511590d81eda44a17b9 Binary files /dev/null and b/UyTube_logica/src/Imagenes/ukp.png differ diff --git a/UyTube_logica/src/JPAControllerClasses/AdministradorJpaController.java b/UyTube_logica/src/JPAControllerClasses/AdministradorJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..77038026ebf61756e3924d6b1ba82ee648b52a53 --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/AdministradorJpaController.java @@ -0,0 +1,148 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import JPAControllerClasses.exceptions.PreexistingEntityException; +import Logica.Clases.Administrador; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class AdministradorJpaController implements Serializable { + + public AdministradorJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public AdministradorJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(Administrador administrador) throws PreexistingEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(administrador); + em.getTransaction().commit(); + } catch (Exception ex) { + if (findAdministrador(administrador.getId()) != null) { + throw new PreexistingEntityException("Administrador " + administrador + " already exists.", ex); + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(Administrador administrador) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + administrador = em.merge(administrador); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + int id = administrador.getId(); + if (findAdministrador(id) == null) { + throw new NonexistentEntityException("The administrador with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(int id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + Administrador administrador; + try { + administrador = em.getReference(Administrador.class, id); + administrador.getId(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The administrador with id " + id + " no longer exists.", enfe); + } + em.remove(administrador); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<Administrador> findAdministradorEntities() { + return findAdministradorEntities(true, -1, -1); + } + + public List<Administrador> findAdministradorEntities(int maxResults, int firstResult) { + return findAdministradorEntities(false, maxResults, firstResult); + } + + private List<Administrador> findAdministradorEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(Administrador.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public Administrador findAdministrador(int id) { + EntityManager em = getEntityManager(); + try { + return em.find(Administrador.class, id); + } finally { + em.close(); + } + } + + public int getAdministradorCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<Administrador> rt = cq.from(Administrador.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/BusquedaEnBDD.java b/UyTube_logica/src/JPAControllerClasses/BusquedaEnBDD.java new file mode 100644 index 0000000000000000000000000000000000000000..aa8b7981897e3bef7bdd077bf302b9aba10362bd --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/BusquedaEnBDD.java @@ -0,0 +1,322 @@ +package JPAControllerClasses; + +import Logica.Clases.Canal; +import Logica.Clases.ListaDeReproduccion; +import Logica.Clases.ListaDeReproduccion; +import Logica.Clases.Usuario; +import Logica.Clases.Video; +import Logica.DataType.DtVideo; +import Logica.Enumerados.Filtrado; +import Logica.Enumerados.Ordenacion; +import Logica.Enumerados.TipoListaDeReproduccion; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.Persistence; + +public class BusquedaEnBDD implements Serializable { + private EntityManagerFactory emf = null; + + public BusquedaEnBDD() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public BusquedaEnBDD(EntityManagerFactory emf) { + this.emf = emf; + } + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + /** + * Busca contenido por coincidencia de texto en nombre o descripcion de los + * contenidos del sistema En el resultado se incluirán (si corresponde segun + * el filtrado) los videos privados del usuarioActual + * + * @param busqueda Texto a buscar (si es vacÃo incluye todo el contenido) + * @param filtro Tipo de contenido en el cual se realizará la búsqueda + * @param orden Manera de ordenar el resultado de la búsqueda + * @return Resultado de la busqueda. Puede contener DtVideo, + * DtListaDeReproduccion y/o DtCanal. (para usar los elementos devueltos hay + * que castearlos) + */ + public ArrayList<Object> buscar(String busqueda, Filtrado filtro, Ordenacion orden){ + EntityManager em = getEntityManager(); + List<Object> ret = new ArrayList(); + if (busqueda == null || busqueda.equals("")) { + }else{ + busqueda = "%" + busqueda + "%"; + } + try { + Query q; + // Segun la opcion de filtrado, se obtienen los contenidos que contengan el texto a buscar + // Busca los Canales + if (filtro == Filtrado.TODO || filtro == Filtrado.CANALES){ + if (busqueda == null || busqueda.equals("")){ + q = em.createQuery("SELECT e FROM Canal e WHERE NOT e.eliminado"); + }else{ + q = em.createQuery("SELECT e FROM Canal e WHERE (UPPER(e.nombre)) LIKE (UPPER(?1)) OR (UPPER(e.descripcion)) LIKE (UPPER(?1)) AND NOT e.eliminado"); + q.setParameter(1, busqueda); + } + ret.addAll(q.getResultList()); + } + // Busca los Listas de reproduccion + if (filtro == Filtrado.TODO || filtro == Filtrado.LISTAS_DE_REPRODUCCION){ + if (busqueda == null || busqueda.equals("")){ + q = em.createQuery("SELECT e FROM ListaDeReproduccion e WHERE e.tipo = ? AND NOT e.eliminado"); + q.setParameter(1, TipoListaDeReproduccion.PARTICULAR); + }else{ + q = em.createQuery("SELECT e FROM ListaDeReproduccion e WHERE e.tipo = ?1 AND (UPPER(e.nombre)) LIKE (UPPER(?2)) AND NOT e.eliminado"); + q.setParameter(1, TipoListaDeReproduccion.PARTICULAR); + q.setParameter(2, busqueda); + } + ret.addAll(q.getResultList()); + } + // Busca los Videos + if (filtro == Filtrado.TODO || filtro == Filtrado.VIDEOS){ + if (busqueda == null || busqueda.equals("")){ + q = em.createQuery("SELECT e FROM Video e WHERE NOT e.eliminado"); + }else{ + q = em.createQuery("SELECT e FROM Video e WHERE (UPPER(e.nombre)) LIKE (UPPER(?1)) OR (UPPER(e.descripcion)) LIKE (UPPER(?1)) AND NOT e.eliminado"); + q.setParameter(1, busqueda); + } + ret.addAll(q.getResultList()); + } + + // En este punto ret contiene todos los contenidos que contienen la busqueda en su nombre o descripcion + ArrayList<ParDeObjetos> pares = null; + ArrayList<ParDeObjetos> paresOrdenados; + // Asocia los elementos a su nombre o su fecha (segun como se desee ordenar) + switch (orden){ + case ALFABETICA_ASCENDENTE: + pares = nombrarElementos((ArrayList<Object>) ret); + break; + case FECHA_DESCENDENTE: + pares = fecharElementos((ArrayList<Object>) ret); + break; + } + + // Leido de adentro hacia afuera: + // se ordena por fecha + // Se desarma el par de objetos + // se convierte cada objeto a su DataType + // retorna el resultado + return convertirClaseADatatype( + ParDeObjetos.extraerElementos( + ordenar(pares) + ) + ); + } finally { + em.close(); + } + } + + /** + * Devuelve un listado de Video y ListaDeReproduccion que pertenezcan ala + * categoria indicada, ordenado por fecha de actividasd reciente + * @param cat Categoria a buscar + * @return Lista ordenada Video y ListaDeReproduccion + */ + public ArrayList<Object> buscarPorCategoria(String cat) { + EntityManager em = getEntityManager(); + List<Object> ret = new ArrayList(); + try { + Query q; + // Obtiene los videos en esa categoria + q = em.createQuery("SELECT e FROM Video e WHERE e.categoria = ?1 AND NOT e.eliminado"); + q.setParameter(1, cat); + ret.addAll(q.getResultList()); + // obtiene las listas de reproduccion en esa categoria + q = em.createQuery("SELECT e FROM ListaDeReproduccion e WHERE e.categoria = ?1 AND NOT e.eliminado"); + q.setParameter(1, cat); + ret.addAll(q.getResultList()); + + // Leido de adentro hacia afuera: + // Asocia los elementos a una fecha + // se ordena por fecha + // Se desarma el par de objetos + // se convierte cada objeto a su DataType + // retorna el resultado + return convertirClaseADatatype( + ParDeObjetos.extraerElementos( + ordenar( + fecharElementos( + (ArrayList<Object>) ret + ) + ) + ) + ); + } finally { + em.close(); + } + } + + /** + * Asocia los objetos recibidos a una fecha + * Canal se asocia a la fecha del video mas reciente + * Video a su propia fecha + * ListaDeReproduccion fecha del video con fecha mas reciente + * @param lista Lista de objetos a ordenar (Canal, Video o ListaDeReproduccion) + * @return Lista de los objetos recibidos pero asociados a una fecha + */ + public ArrayList<ParDeObjetos> fecharElementos(ArrayList<Object> lista){ + ArrayList<ParDeObjetos> ret = new ArrayList(); + // Asocia cada elemento del array recibido con su fecha + for (Object o : lista){ + ret.add(new ParDeObjetos(o, ultimaActividad(o))); + } + return ret; + } + + /** + * Asocia los objetos recibidos a una fecha + * Canal se asocia a la fecha del video mas reciente + * Video a su propia fecha + * ListaDeReproduccion fecha del video con fecha mas reciente + * @param lista Lista de objetos a ordenar (Canal, Video o ListaDeReproduccion) + * @return Lista de los objetos recibidos pero asociados a una fecha + */ + public ArrayList<ParDeObjetos> nombrarElementos(ArrayList<Object> lista){ + ArrayList<ParDeObjetos> ret = new ArrayList(); + // Asocia cada elemento del array recibido con su nombre + for (Object o : lista){ + ret.add(new ParDeObjetos(o, nombreParaOrdenar(o))); + } + return ret; + } + + /** + * Devuelve el nombre del objeto + * Canal su nombre + * Video su nombre + * ListaDeReproduccion su nombre + * @param o Objeto a dar nombre + * @return Nombre del objeto + */ + private String nombreParaOrdenar(Object o){ + java.sql.Date ret = null; + // Devuelve el nombre del objeto + if (o instanceof Canal){ + return ((Canal) o).getNombre(); + }else if (o instanceof ListaDeReproduccion){ + return ((ListaDeReproduccion) o).getNombre(); + }else if (o instanceof Video){ + return ((Video) o).getNombre(); + } + return ""; + } + + /** + * Devuelve la fecha de la ultima actividad del objeto + * Canal es la fecha del video mas reciente + * Video su propia fecha + * ListaDeReproduccion la fecha del video con fecha mas reciente + * @param o + * @return + */ + private java.sql.Date ultimaActividad(Object o){ + // Por si no se pude determinar la fecha, inicializo con una fecha bien vieja + java.sql.Date ret = new java.sql.Date(-1900, 0, 1); + // mas viejo que eso solo puede ser algun video de Mirta Legrant, y no creo que ella use UyTube... + + if (o instanceof Canal){ + // si el objeto es un Canal + // busca la fecha de publicacion mas reciente entre los videos del canal + ArrayList<DtVideo> videos = ((Canal) o).listarVideos(); + for (DtVideo dtv : videos){ + if (ret == null || dtv.getFechaPublicacion().compareTo(ret) > 0){ + ret = dtv.getFechaPublicacion(); + } + } + }else if (o instanceof ListaDeReproduccion){ + // si el objeto es una ListaDeReproduccion + // busca la fecha de publicacion mas reciente entre los videos de la lista + ArrayList<DtVideo> videos = ((ListaDeReproduccion) o).listarVideos(); + for (DtVideo dtv : videos){ + if (ret == null || dtv.getFechaPublicacion().compareTo(ret) > 0){ + ret = dtv.getFechaPublicacion(); + } + } + }else if (o instanceof Video){ + // si el objeto es un Video + // Devuelve su fecha + ret = ((Video) o).getFechaPublicacion(); + } + return ret; + } + + /** + * Ordena la lista de pares recibida + * @param lista Lista a ordenar + * @return Lista ordenada + */ + public ArrayList<ParDeObjetos> ordenar(ArrayList<ParDeObjetos> lista){ + // Caso base, no hay lista o es vacia + if (lista == null || lista.isEmpty()){ + return new ArrayList(); + } + + // Extrae el primer elemento de la lista + ParDeObjetos par = lista.remove(0); + // llama a la recursividad + ArrayList<ParDeObjetos> listaOrdenada = ordenar(lista); + + // Recore la lista ya ordenada por la llamada recursiva + // compara cada elemento y para cuando encuentra su lugar + int i = 0; + for (; i < listaOrdenada.size(); i++){ + ParDeObjetos p = listaOrdenada.get(i); + if (comparar(p, par) < 0){ + break; + } + } + // Agrega el elemento al resultado + listaOrdenada.add(i, par); + return listaOrdenada; + } + + /** + * Compara dos pares de objetos + * Se soportan String o java.sql.Date + * @param a Primer par a comparar + * @param b Segundo par a comparar + * @return 0 si (a == b), -1 si (a < b), 1 si (a > b) + */ + private int comparar(ParDeObjetos a, ParDeObjetos b){ + // Realiza la comparacion dependiendo del tipo de objeto para comparar + if (a.getOrderField() instanceof String){ + String str1 = (String) a.getOrderField(); + String str2 = (String) b.getOrderField(); + return (str1.compareToIgnoreCase(str2)) * -1; + }else if (a.getOrderField() instanceof java.sql.Date){ + java.sql.Date date1 = (java.sql.Date) a.getOrderField(); + java.sql.Date date2 = (java.sql.Date) b.getOrderField(); + return date1.compareTo(date2); + } + return 0; + } + + /** + * Reemplaza los objetos de la lista por sus DataType + * @param lst Lista con clases Canal, ListaDeReproduccion o Video + * @return Lista de DtCanal, DtListaDeReproduccion o DtVideo + */ + private ArrayList<Object> convertirClaseADatatype(ArrayList<Object> lst){ + Object o; + // Recorre todo el array + for (int i = 0; i < lst.size(); i++) { + o = lst.get(i); + // Castea el objeto para llamar a la funcion .getDT() + if (o instanceof Canal) { + lst.set(i, ((Canal)o).getDT()); + } else if (o instanceof ListaDeReproduccion) { + lst.set(i, ((ListaDeReproduccion)o).getDt()); + } else if (o instanceof Video) { + lst.set(i, ((Video)o).getDt()); + } + } + return lst; + } +} diff --git a/UyTube_logica/src/JPAControllerClasses/CanalJpaController.java b/UyTube_logica/src/JPAControllerClasses/CanalJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..1876ea644572e94b1be194c49e2bc79e5a47b792 --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/CanalJpaController.java @@ -0,0 +1,142 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import Logica.Clases.Canal; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class CanalJpaController implements Serializable { + + public CanalJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public CanalJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(Canal canal) { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(canal); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(Canal canal) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + canal = em.merge(canal); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + int id = canal.getId(); + if (findCanal(id) == null) { + throw new NonexistentEntityException("The canal with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(int id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + Canal canal; + try { + canal = em.getReference(Canal.class, id); + canal.getId(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The canal with id " + id + " no longer exists.", enfe); + } + em.remove(canal); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<Canal> findCanalEntities() { + return findCanalEntities(true, -1, -1); + } + + public List<Canal> findCanalEntities(int maxResults, int firstResult) { + return findCanalEntities(false, maxResults, firstResult); + } + + private List<Canal> findCanalEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(Canal.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public Canal findCanal(int id) { + EntityManager em = getEntityManager(); + try { + return em.find(Canal.class, id); + } finally { + em.close(); + } + } + + public int getCanalCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<Canal> rt = cq.from(Canal.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/CategoriaJpaController.java b/UyTube_logica/src/JPAControllerClasses/CategoriaJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..3893b56833e851cbcf049db915afe35182941a94 --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/CategoriaJpaController.java @@ -0,0 +1,148 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import JPAControllerClasses.exceptions.PreexistingEntityException; +import Logica.Clases.Categoria; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class CategoriaJpaController implements Serializable { + + public CategoriaJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public CategoriaJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(Categoria categoria) throws PreexistingEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(categoria); + em.getTransaction().commit(); + } catch (Exception ex) { + if (findCategoria(categoria.getNombre()) != null) { + throw new PreexistingEntityException("Categoria " + categoria + " already exists.", ex); + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(Categoria categoria) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + categoria = em.merge(categoria); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + String id = categoria.getNombre(); + if (findCategoria(id) == null) { + throw new NonexistentEntityException("The categoria with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(String id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + Categoria categoria; + try { + categoria = em.getReference(Categoria.class, id); + categoria.getNombre(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The categoria with id " + id + " no longer exists.", enfe); + } + em.remove(categoria); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<Categoria> findCategoriaEntities() { + return findCategoriaEntities(true, -1, -1); + } + + public List<Categoria> findCategoriaEntities(int maxResults, int firstResult) { + return findCategoriaEntities(false, maxResults, firstResult); + } + + private List<Categoria> findCategoriaEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(Categoria.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public Categoria findCategoria(String id) { + EntityManager em = getEntityManager(); + try { + return em.find(Categoria.class, id); + } finally { + em.close(); + } + } + + public int getCategoriaCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<Categoria> rt = cq.from(Categoria.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/ComentarioJpaController.java b/UyTube_logica/src/JPAControllerClasses/ComentarioJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..ca7ea2c884cda73e13fd6fb3df470da3de44086c --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/ComentarioJpaController.java @@ -0,0 +1,142 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import Logica.Clases.Comentario; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class ComentarioJpaController implements Serializable { + + public ComentarioJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public ComentarioJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(Comentario comentario) { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(comentario); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(Comentario comentario) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + comentario = em.merge(comentario); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + int id = comentario.getId(); + if (findComentario(id) == null) { + throw new NonexistentEntityException("The comentario with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(int id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + Comentario comentario; + try { + comentario = em.getReference(Comentario.class, id); + comentario.getId(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The comentario with id " + id + " no longer exists.", enfe); + } + em.remove(comentario); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<Comentario> findComentarioEntities() { + return findComentarioEntities(true, -1, -1); + } + + public List<Comentario> findComentarioEntities(int maxResults, int firstResult) { + return findComentarioEntities(false, maxResults, firstResult); + } + + private List<Comentario> findComentarioEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(Comentario.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public Comentario findComentario(int id) { + EntityManager em = getEntityManager(); + try { + return em.find(Comentario.class, id); + } finally { + em.close(); + } + } + + public int getComentarioCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<Comentario> rt = cq.from(Comentario.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/ListaDeReproduccionJpaController.java b/UyTube_logica/src/JPAControllerClasses/ListaDeReproduccionJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..6b625cd6096408a827c471699c2fc6558d3a5a4d --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/ListaDeReproduccionJpaController.java @@ -0,0 +1,142 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import Logica.Clases.ListaDeReproduccion; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class ListaDeReproduccionJpaController implements Serializable { + + public ListaDeReproduccionJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public ListaDeReproduccionJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(ListaDeReproduccion listaDeReproduccion) { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(listaDeReproduccion); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(ListaDeReproduccion listaDeReproduccion) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + listaDeReproduccion = em.merge(listaDeReproduccion); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + int id = listaDeReproduccion.getId(); + if (findListaDeReproduccion(id) == null) { + throw new NonexistentEntityException("The listaDeReproduccion with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(int id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + ListaDeReproduccion listaDeReproduccion; + try { + listaDeReproduccion = em.getReference(ListaDeReproduccion.class, id); + listaDeReproduccion.getId(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The listaDeReproduccion with id " + id + " no longer exists.", enfe); + } + em.remove(listaDeReproduccion); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<ListaDeReproduccion> findListaDeReproduccionEntities() { + return findListaDeReproduccionEntities(true, -1, -1); + } + + public List<ListaDeReproduccion> findListaDeReproduccionEntities(int maxResults, int firstResult) { + return findListaDeReproduccionEntities(false, maxResults, firstResult); + } + + private List<ListaDeReproduccion> findListaDeReproduccionEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(ListaDeReproduccion.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public ListaDeReproduccion findListaDeReproduccion(int id) { + EntityManager em = getEntityManager(); + try { + return em.find(ListaDeReproduccion.class, id); + } finally { + em.close(); + } + } + + public int getListaDeReproduccionCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<ListaDeReproduccion> rt = cq.from(ListaDeReproduccion.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/ListaPorDefectoJpaController.java b/UyTube_logica/src/JPAControllerClasses/ListaPorDefectoJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..9e2d0ed59291eda457190eaa740a39475c1531c9 --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/ListaPorDefectoJpaController.java @@ -0,0 +1,148 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import JPAControllerClasses.exceptions.PreexistingEntityException; +import Logica.Clases.ListaPorDefecto; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class ListaPorDefectoJpaController implements Serializable { + + public ListaPorDefectoJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public ListaPorDefectoJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(ListaPorDefecto listaPorDefecto) throws PreexistingEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(listaPorDefecto); + em.getTransaction().commit(); + } catch (Exception ex) { + if (findListaPorDefecto(listaPorDefecto.getNombre()) != null) { + throw new PreexistingEntityException("ListaPorDefecto " + listaPorDefecto + " already exists.", ex); + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(ListaPorDefecto listaPorDefecto) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + listaPorDefecto = em.merge(listaPorDefecto); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + String id = listaPorDefecto.getNombre(); + if (findListaPorDefecto(id) == null) { + throw new NonexistentEntityException("The listaPorDefecto with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(String id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + ListaPorDefecto listaPorDefecto; + try { + listaPorDefecto = em.getReference(ListaPorDefecto.class, id); + listaPorDefecto.getNombre(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The listaPorDefecto with id " + id + " no longer exists.", enfe); + } + em.remove(listaPorDefecto); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<ListaPorDefecto> findListaPorDefectoEntities() { + return findListaPorDefectoEntities(true, -1, -1); + } + + public List<ListaPorDefecto> findListaPorDefectoEntities(int maxResults, int firstResult) { + return findListaPorDefectoEntities(false, maxResults, firstResult); + } + + private List<ListaPorDefecto> findListaPorDefectoEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(ListaPorDefecto.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public ListaPorDefecto findListaPorDefecto(String id) { + EntityManager em = getEntityManager(); + try { + return em.find(ListaPorDefecto.class, id); + } finally { + em.close(); + } + } + + public int getListaPorDefectoCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<ListaPorDefecto> rt = cq.from(ListaPorDefecto.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/NombreManejador.java b/UyTube_logica/src/JPAControllerClasses/NombreManejador.java new file mode 100644 index 0000000000000000000000000000000000000000..8a046140c974c191f5ad455aaffcff4b6c8886d8 --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/NombreManejador.java @@ -0,0 +1,9 @@ +package JPAControllerClasses; + +public class NombreManejador { + private static String nombreManejador = "UyTubePU"; + + public static String getNombreManejador(){ + return nombreManejador; + } +} diff --git a/UyTube_logica/src/JPAControllerClasses/ParDeObjetos.java b/UyTube_logica/src/JPAControllerClasses/ParDeObjetos.java new file mode 100644 index 0000000000000000000000000000000000000000..8c38f83397175f66b759940cfe327f8138c1ebbf --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/ParDeObjetos.java @@ -0,0 +1,40 @@ +package JPAControllerClasses; + +import java.util.ArrayList; + +public class ParDeObjetos { + private Object element; + private Object orderField; + + public ParDeObjetos(Object element, Object orderField) { + this.element = element; + this.orderField = orderField; + } + + public Object getElement() { + return element; + } + + public void setElement(Object element) { + this.element = element; + } + + public Object getOrderField() { + return orderField; + } + + public void setOrderField(Object orderField) { + this.orderField = orderField; + } + + + public static ArrayList<Object> extraerElementos(ArrayList<ParDeObjetos> lista){ + ArrayList<Object> ret = new ArrayList(); + for (ParDeObjetos par : lista){ + ret.add(par.getElement()); + } + return ret; + } + + +} diff --git a/UyTube_logica/src/JPAControllerClasses/PersonaJpaController.java b/UyTube_logica/src/JPAControllerClasses/PersonaJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..764949584a6733d6811f56630b621746c26b2cee --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/PersonaJpaController.java @@ -0,0 +1,148 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import JPAControllerClasses.exceptions.PreexistingEntityException; +import Logica.Clases.Persona; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class PersonaJpaController implements Serializable { + + public PersonaJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public PersonaJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(Persona persona) throws PreexistingEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(persona); + em.getTransaction().commit(); + } catch (Exception ex) { + if (findPersona(persona.getId()) != null) { + throw new PreexistingEntityException("Persona " + persona + " already exists.", ex); + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(Persona persona) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + persona = em.merge(persona); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + int id = persona.getId(); + if (findPersona(id) == null) { + throw new NonexistentEntityException("The persona with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(int id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + Persona persona; + try { + persona = em.getReference(Persona.class, id); + persona.getId(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The persona with id " + id + " no longer exists.", enfe); + } + em.remove(persona); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<Persona> findPersonaEntities() { + return findPersonaEntities(true, -1, -1); + } + + public List<Persona> findPersonaEntities(int maxResults, int firstResult) { + return findPersonaEntities(false, maxResults, firstResult); + } + + private List<Persona> findPersonaEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(Persona.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public Persona findPersona(int id) { + EntityManager em = getEntityManager(); + try { + return em.find(Persona.class, id); + } finally { + em.close(); + } + } + + public int getPersonaCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<Persona> rt = cq.from(Persona.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/UsuarioJpaController.java b/UyTube_logica/src/JPAControllerClasses/UsuarioJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..87a42ad7d2b14a123c5eaf3c4ac1128082bbc606 --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/UsuarioJpaController.java @@ -0,0 +1,159 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import JPAControllerClasses.exceptions.PreexistingEntityException; +import Logica.Clases.Usuario; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class UsuarioJpaController implements Serializable { + + public UsuarioJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public UsuarioJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(Usuario usuario) throws PreexistingEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(usuario); + em.getTransaction().commit(); + } catch (Exception ex) { + if (findUsuario(usuario.getNickname()) != null) { + throw new PreexistingEntityException("Usuario " + usuario + " already exists.", ex); + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(Usuario usuario) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + usuario = em.merge(usuario); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + String id = usuario.getNickname(); + if (findUsuario(id) == null) { + throw new NonexistentEntityException("The usuario with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(String id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + Usuario usuario; + try { + usuario = em.getReference(Usuario.class, id); + usuario.getNickname(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The usuario with id " + id + " no longer exists.", enfe); + } + em.remove(usuario); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<Usuario> findUsuarioEntities() { + return findUsuarioEntities(true, -1, -1); + } + + public List<Usuario> findUsuarioEntities(int maxResults, int firstResult) { + return findUsuarioEntities(false, maxResults, firstResult); + } + + private List<Usuario> findUsuarioEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + Query q = em.createQuery("SELECT u FROM Usuario u WHERE u.eliminado = ?1"); + q.setParameter(1, false); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public List<Usuario> findUsuarioEliminadoEntities() { + EntityManager em = getEntityManager(); + try { + Query q = em.createQuery("SELECT u FROM Usuario u WHERE u.eliminado = ?1"); + q.setParameter(1, true); + List<Usuario> usuarios = (List<Usuario>) q.getResultList(); + return usuarios; + } finally { + em.close(); + } + } + + public Usuario findUsuario(String id) { + EntityManager em = getEntityManager(); + try { + return em.find(Usuario.class, id); + } finally { + em.close(); + } + } + + public int getUsuarioCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<Usuario> rt = cq.from(Usuario.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/ValoracionJpaController.java b/UyTube_logica/src/JPAControllerClasses/ValoracionJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..2c4e68764319b25bc23ed03b5021bb5b647f8139 --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/ValoracionJpaController.java @@ -0,0 +1,142 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import Logica.Clases.Valoracion; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class ValoracionJpaController implements Serializable { + + public ValoracionJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + public ValoracionJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(Valoracion valoracion) { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(valoracion); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(Valoracion valoracion) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + valoracion = em.merge(valoracion); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + int id = valoracion.getId(); + if (findValoracion(id) == null) { + throw new NonexistentEntityException("The valoracion with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(int id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + Valoracion valoracion; + try { + valoracion = em.getReference(Valoracion.class, id); + valoracion.getId(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The valoracion with id " + id + " no longer exists.", enfe); + } + em.remove(valoracion); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<Valoracion> findValoracionEntities() { + return findValoracionEntities(true, -1, -1); + } + + public List<Valoracion> findValoracionEntities(int maxResults, int firstResult) { + return findValoracionEntities(false, maxResults, firstResult); + } + + private List<Valoracion> findValoracionEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(Valoracion.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public Valoracion findValoracion(int id) { + EntityManager em = getEntityManager(); + try { + return em.find(Valoracion.class, id); + } finally { + em.close(); + } + } + + public int getValoracionCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<Valoracion> rt = cq.from(Valoracion.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/VideoJpaController.java b/UyTube_logica/src/JPAControllerClasses/VideoJpaController.java new file mode 100644 index 0000000000000000000000000000000000000000..b56d22ac9e42d22cfcdc55d220f97a2b2d9eac7b --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/VideoJpaController.java @@ -0,0 +1,143 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package JPAControllerClasses; + +import JPAControllerClasses.exceptions.NonexistentEntityException; +import Logica.Clases.Video; +import java.io.Serializable; +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Query; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +/** + * + * @author Juan + */ +public class VideoJpaController implements Serializable { + + public VideoJpaController() { + this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); + } + + public VideoJpaController(EntityManagerFactory emf) { + this.emf = emf; + } + private EntityManagerFactory emf = null; + + public EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public void create(Video video) { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + em.persist(video); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public void edit(Video video) throws NonexistentEntityException, Exception { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + video = em.merge(video); + em.getTransaction().commit(); + } catch (Exception ex) { + String msg = ex.getLocalizedMessage(); + if (msg == null || msg.length() == 0) { + int id = video.getId(); + if (findVideo(id) == null) { + throw new NonexistentEntityException("The video with id " + id + " no longer exists."); + } + } + throw ex; + } finally { + if (em != null) { + em.close(); + } + } + } + + public void destroy(int id) throws NonexistentEntityException { + EntityManager em = null; + try { + em = getEntityManager(); + em.getTransaction().begin(); + Video video; + try { + video = em.getReference(Video.class, id); + video.getId(); + } catch (EntityNotFoundException enfe) { + throw new NonexistentEntityException("The video with id " + id + " no longer exists.", enfe); + } + em.remove(video); + em.getTransaction().commit(); + } finally { + if (em != null) { + em.close(); + } + } + } + + public List<Video> findVideoEntities() { + return findVideoEntities(true, -1, -1); + } + + public List<Video> findVideoEntities(int maxResults, int firstResult) { + return findVideoEntities(false, maxResults, firstResult); + } + + private List<Video> findVideoEntities(boolean all, int maxResults, int firstResult) { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + cq.select(cq.from(Video.class)); + Query q = em.createQuery(cq); + if (!all) { + q.setMaxResults(maxResults); + q.setFirstResult(firstResult); + } + return q.getResultList(); + } finally { + em.close(); + } + } + + public Video findVideo(int id) { + EntityManager em = getEntityManager(); + try { + return em.find(Video.class, id); + } finally { + em.close(); + } + } + + public int getVideoCount() { + EntityManager em = getEntityManager(); + try { + CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); + Root<Video> rt = cq.from(Video.class); + cq.select(em.getCriteriaBuilder().count(rt)); + Query q = em.createQuery(cq); + return ((Long) q.getSingleResult()).intValue(); + } finally { + em.close(); + } + } + +} diff --git a/UyTube_logica/src/JPAControllerClasses/exceptions/IllegalOrphanException.java b/UyTube_logica/src/JPAControllerClasses/exceptions/IllegalOrphanException.java new file mode 100644 index 0000000000000000000000000000000000000000..3b58e834bf2dfe2e42918d7e8c27a4604af9878c --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/exceptions/IllegalOrphanException.java @@ -0,0 +1,20 @@ +package JPAControllerClasses.exceptions; + +import java.util.ArrayList; +import java.util.List; + +public class IllegalOrphanException extends Exception { + private List<String> messages; + public IllegalOrphanException(List<String> messages) { + super((messages != null && messages.size() > 0 ? messages.get(0) : null)); + if (messages == null) { + this.messages = new ArrayList<String>(); + } + else { + this.messages = messages; + } + } + public List<String> getMessages() { + return messages; + } +} diff --git a/UyTube_logica/src/JPAControllerClasses/exceptions/NonexistentEntityException.java b/UyTube_logica/src/JPAControllerClasses/exceptions/NonexistentEntityException.java new file mode 100644 index 0000000000000000000000000000000000000000..4722e104e36b54ab9c5c491d14a60405b1d906df --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/exceptions/NonexistentEntityException.java @@ -0,0 +1,10 @@ +package JPAControllerClasses.exceptions; + +public class NonexistentEntityException extends Exception { + public NonexistentEntityException(String message, Throwable cause) { + super(message, cause); + } + public NonexistentEntityException(String message) { + super(message); + } +} diff --git a/UyTube_logica/src/JPAControllerClasses/exceptions/PreexistingEntityException.java b/UyTube_logica/src/JPAControllerClasses/exceptions/PreexistingEntityException.java new file mode 100644 index 0000000000000000000000000000000000000000..6e3acce872661df58e32b20d9b8b92e4a474d00b --- /dev/null +++ b/UyTube_logica/src/JPAControllerClasses/exceptions/PreexistingEntityException.java @@ -0,0 +1,10 @@ +package JPAControllerClasses.exceptions; + +public class PreexistingEntityException extends Exception { + public PreexistingEntityException(String message, Throwable cause) { + super(message, cause); + } + public PreexistingEntityException(String message) { + super(message); + } +} diff --git a/UyTube_logica/src/Logica/Clases/Administrador.java b/UyTube_logica/src/Logica/Clases/Administrador.java new file mode 100644 index 0000000000000000000000000000000000000000..373b88d46f222de027143277825511fdde8766c7 --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/Administrador.java @@ -0,0 +1,33 @@ +package Logica.Clases; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name="administrador") +public class Administrador extends Persona implements Serializable{ + + @Id + // No logre hacer que el id fuera auto-incremental, no se por que, probe de todo y no pude + //@GeneratedValue(strategy=GenerationType.IDENTITY) + //@Column(name = "id") + private Integer id; + + //------------------------------------------------------------------------- + + public Administrador() { + super(); + } + + public Administrador(int id, String contrasenia, String nombre, String apellido){ + super(nombre,apellido,contrasenia); + this.id = id; + } + + public int getIdAdmin() { + return id; + } + +} diff --git a/UyTube_logica/src/Logica/Clases/Canal.java b/UyTube_logica/src/Logica/Clases/Canal.java new file mode 100644 index 0000000000000000000000000000000000000000..ebd5294e66df60b9b5c83afd43fa37d859e629d5 --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/Canal.java @@ -0,0 +1,540 @@ +package Logica.Clases; + +import JPAControllerClasses.ListaDeReproduccionJpaController; +import JPAControllerClasses.VideoJpaController; +import Logica.Enumerados.Privacidad; +import Logica.DataType.DtComentario; +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtValoracion; +import Logica.DataType.DtVideo; +import Logica.DataType.DtCanal; +import Logica.Enumerados.TipoListaDeReproduccion; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Map; +import java.util.TreeMap; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +@Entity +@Table(name = "canal") +public class Canal implements Serializable { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + @Column(name = "nombre") + private String nombre; + + @Column(name = "descripcion") + private String descripcion; + + @Enumerated(EnumType.STRING) + @Column(name = "privacidad") + private Privacidad privacidad; + + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "id_canal") + @MapKey(name = "id") + private Map<Integer, ListaDeReproduccion> misListas; + + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "id_canal") + @MapKey(name = "id") + private Map<Integer, Video> misVideos; + + @Column(name = "eliminado") + private boolean eliminado; + + //------------------------------------------------------------------------------------- + public Canal() { + } + + public Canal(int id, String nombre, String descripcion, Privacidad privacidad) { + if (nombre.equals("")){ + throw new RuntimeException("El nombre del canal no puede ser vacio"); + } + + this.id = id; + this.nombre = nombre; + this.descripcion = descripcion; + this.privacidad = privacidad; + this.misListas = new TreeMap(); + this.misVideos = new TreeMap(); + this.eliminado = false; + } + + public int getId() { + return id; + } + + public String getNombre() { + return nombre; + } + + public String getDescripcion() { + return descripcion; + } + + public Privacidad getPrivacidad() { + return privacidad; + } + + public void setNombre(String nombre) { + if (nombre.equals("")) { + throw new RuntimeException("El nombre del canal no puede ser vacio"); + } + this.nombre = nombre; + } + + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + public void setPrivacidad(Privacidad privacidad) { + // Si el canal es publico y se va a cambiar a privado, se deben cambiar a privado todos los videos del canal + if (privacidad == Privacidad.PRIVADO){ + for (Map.Entry<Integer, Video> m : misVideos.entrySet()) { + m.getValue().setPrivacidad(Privacidad.PRIVADO); + } + for (Map.Entry<Integer, ListaDeReproduccion> m : misListas.entrySet()) { + m.getValue().setPrivacidad(Privacidad.PRIVADO); + } + } + this.privacidad = privacidad; + } + + + public void eliminar(){ + this.eliminado = true; + // elimina logicamente cada lista de reproduccion del canal + for (Map.Entry<Integer, ListaDeReproduccion> it : this.misListas.entrySet()){ + it.getValue().eliminar(); + try { + new ListaDeReproduccionJpaController().edit(it.getValue()); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + // elimina logicamente cada video del canal + // en el proceso se eliminan los comentarios, pero lo hace permanentemente + for (Map.Entry<Integer, Video> it : this.misVideos.entrySet()){ + it.getValue().eliminar(); + try { + new VideoJpaController().edit(it.getValue()); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + } + + public void eliminarTodoRastroDelUsuario(String nickname) { + // recorre los videos del canal eliminando comentarios y valoraciones hechas por el usuario con ese nickname + for (Map.Entry<Integer, Video> it : this.misVideos.entrySet()){ + it.getValue().eliminarTodoRastroDelUsuario(nickname); + try { + new VideoJpaController().edit(it.getValue()); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + } + //----------------------------------------------------------------------------- + public void actualizarListasPorDefecto(ArrayList<String> listas) { + // descarta las listas que ya estan agregadas + for (Map.Entry<Integer, ListaDeReproduccion> l : misListas.entrySet()) { + if (l.getValue().getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { + listas.remove(l.getValue().getNombre()); + } + } + // agrega las que pasaron el filtro anterior + for (String lista : listas) { + ListaDeReproduccion nuevaLista = new ListaDeReproduccion(0, lista, Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); + // crea la tupla en la base de datos + // asi se genera el ID y se puede agregar al Map + new ListaDeReproduccionJpaController().create(nuevaLista); + this.misListas.put(nuevaLista.getId(), nuevaLista); + } + } + + public void agregarComentarioAVideo(int id, DtComentario comentario, Usuario usuario) { + if (this.misVideos.containsKey(id)) { + this.misVideos.get(id).agregarComentario(comentario, usuario); + try { + new VideoJpaController().edit(this.misVideos.get(id)); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + } + + public void agregarComentarioAVideo(int id, int idComentario, DtComentario comentario, Usuario usuario) { + if (this.misVideos.containsKey(id)) { + this.misVideos.get(id).agregarComentario(idComentario, comentario, usuario); + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + } + + public void agregarListaParticular(DtListaDeReproduccion listaReproduccion) { + if (listaReproduccion == null){ + throw new RuntimeException("La lista de reprodccion es null"); + } + if (listaReproduccion.getNombre().equals("")){ + throw new RuntimeException("El nombre no puede ser vacio"); + } + if (this.privacidad == Privacidad.PRIVADO && listaReproduccion.getPrivacidad() == Privacidad.PUBLICO){ + throw new RuntimeException("No se puede agregar una lista de reproduccion publica a un canal privado"); + } + if (listaReproduccion.getCategoria().equals("")){ + throw new RuntimeException("La categoria no puede ser vacia"); + } + + // un canal no puede tener dos videos con el mismo nomre + for (Map.Entry<Integer, ListaDeReproduccion> v : misListas.entrySet()){ + if (v.getValue().getNombre().equals(listaReproduccion.getNombre())){ + throw new RuntimeException("El canal ya posee una lista de reproduccion con ese nombre"); + } + } + + ListaDeReproduccion ldr = new ListaDeReproduccion( + 0, + listaReproduccion.getNombre(), + listaReproduccion.getPrivacidad(), + listaReproduccion.getTipo(), + listaReproduccion.getCategoria()); + // crea la tupla en la base de datos + // asi se genera el ID y se puede agregar al Map + new ListaDeReproduccionJpaController().create(ldr); + this.misListas.put(ldr.getId(), ldr); + } + + public void quitarValoracion(int idVideo, String nickname) { + if (this.misVideos.containsKey(idVideo)) { + this.misVideos.get(idVideo).quitarValoracion(nickname); + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + + } + + public void agregarModificarValoracion(int id, DtValoracion valoracion, Usuario usuario) { + if (this.misVideos.containsKey(id)) { + this.misVideos.get(id).agregarModificarValoracion(valoracion, usuario); + try { + new VideoJpaController().edit(this.misVideos.get(id)); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + + } + + public void agregarVideo(DtVideo video) { + if(video== null){ + throw new RuntimeException("El Datatype del video es null"); + } + if (video.getNombre().equals("")){ + throw new RuntimeException("El nombre no puede ser vacio"); + } + if(video.getDuracion() == null){ + throw new RuntimeException("La duracion no puede ser null"); + } + if(video.getFechaPublicacion() == null){ + throw new RuntimeException("La fecha de publicion no puede ser null"); + } + if (video.getUrlVideoOriginal().equals("")){ + throw new RuntimeException("La direccion URL no puede ser vacia"); + } + if (video.getCategoria().equals("")){ + throw new RuntimeException("La categorÃa no puede ser vacÃa"); + } + + // un canal no puede tener dos videos con el mismo nomre + for (Map.Entry<Integer, Video> v : misVideos.entrySet()){ + if (v.getValue().getNombre().equals(video.getNombre())){ + throw new RuntimeException("El canal ya posee un video con ese nombre"); + } + } + + Video vd = new Video( + 0, + video.getNombre(), + video.getDescripcion(), + video.getDuracion(), + video.getFechaPublicacion(), + video.getUrlVideoOriginal(), + video.getCategoria()); + + // si el canal es privado, el video debera serlo tambien + // si el canal es publico, el video sera lo definido en el DataType + if (this.privacidad == Privacidad.PRIVADO){ + vd.setPrivacidad(Privacidad.PRIVADO); + } + // crea la tupla en la base de datos + // asi se genera el ID y se puede agregar al Map + new VideoJpaController().create(vd); + this.misVideos.put(vd.getId(), vd); + } + + public void agregarVideoALista(int id, Video video) { + if (this.misListas.containsKey(id)) { + this.misListas.get(id).agregarVideoA(video); + try { + new ListaDeReproduccionJpaController().edit(this.misListas.get(id)); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } else { + throw new RuntimeException("La lista no pertenece al canal"); + } + } + + public DtCanal getDT() { + return new DtCanal(this.id, + this.nombre, + this.descripcion, + this.privacidad); + } + + public ArrayList<DtComentario> listarComentariosDeVideo(int id) { + if (this.misVideos.containsKey(id)) { + return this.misVideos.get(id).listarComentarios(); + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + } + + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccion(boolean soloParticulares) { + ArrayList<DtListaDeReproduccion> ret = new ArrayList(); + // porDefecto = false --> lista todas las listas + // porDefecto = true --> lista solo las particulares + for (Map.Entry<Integer, ListaDeReproduccion> m : misListas.entrySet()) { + if(soloParticulares && m.getValue().getTipo()==TipoListaDeReproduccion.POR_DEFECTO){ + continue; + } + ret.add(m.getValue().getDt()); + } + + return ret; + } + + public ArrayList<DtValoracion> listarValoracionesDeVideo(int id) { + if (this.misVideos.containsKey(id)) { + return this.misVideos.get(id).listarValoraciones(); + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + } + + public ArrayList<DtVideo> listarVideos() { + ArrayList<DtVideo> ret = new ArrayList(); + + // para cada elemento en misVideos + /** + * este for no es normal, se declara la variable m que es de tipo + * Entrada de Map (como un nodo arbol), y autmaticamente la hace avanzar + * por todas las entradas de la coleccion. De la entrada actual se puede + * obtener la Key y el Valor almacenado + */ + for (Map.Entry<Integer, Video> m : misVideos.entrySet()) { + // hace un getDT y lo agrega a la coleccion de retorno + ret.add(m.getValue().getDt()); + } + return ret; + } + + public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(int id) { + if (this.misListas.containsKey(id)) { + return this.misListas.get(id).listarVideos(); + } else { + throw new RuntimeException("La lista de reproduccion no pertenece al canal"); + } + } + + public void modificar(DtCanal canal) { + if (canal.getNombre().equals("")) { + throw new RuntimeException("El nombre no puede ser vacio"); + } + + // Si el canal es publico y se va a cambiar a privado, se deben cambiar a privado todos los videos del canal + if (this.privacidad == Privacidad.PUBLICO && canal.getPrivacidad() == Privacidad.PRIVADO){ + this.setPrivacidad(canal.getPrivacidad()); + } + + this.nombre = canal.getNombre(); + this.descripcion = canal.getDescripcion(); + this.privacidad = canal.getPrivacidad(); + } + + public void modificarListaDeReproduccion(DtListaDeReproduccion ldr) { + if (ldr == null) { + throw new RuntimeException("El Datatype de la lista de reprodccion es null"); + } + if (this.misListas.containsKey(ldr.getId())) { + + if (this.privacidad == Privacidad.PRIVADO && ldr.getPrivacidad() == Privacidad.PUBLICO){ + throw new RuntimeException("No se puede hacer publica una lista de reproduccion de un canal privado"); + } + for (Map.Entry<Integer, ListaDeReproduccion> m : this.misListas.entrySet()){ + if (m.getKey() != ldr.getId()){ + if (m.getValue().getNombre().equals(ldr.getNombre())) { + throw new RuntimeException("El canal ya posee una lista con ese nombre"); + } + } + } + + this.misListas.get(ldr.getId()).modificar(ldr); + try { + new ListaDeReproduccionJpaController().edit(this.misListas.get(ldr.getId())); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } else { + throw new RuntimeException("La lista de reproduccion no pertenece al canal"); + } + } + + public void modificarVideo(DtVideo video) { + if(video== null){ + throw new RuntimeException("El Datatype del video es null"); + } + + if (this.misVideos.containsKey(video.getId())) { + + if (this.privacidad == Privacidad.PRIVADO && video.getPrivacidad() == Privacidad.PUBLICO){ + throw new RuntimeException("No se puede hacer publico un video de un canal privado"); + } + + for (Map.Entry<Integer, Video> m : this.misVideos.entrySet()){ + if (m.getKey() != video.getId()){ + if (m.getValue().getNombre().equals(video.getNombre())) { + throw new RuntimeException("El canal ya posee una lista con ese nombre"); + } + } + } + + this.misVideos.get(video.getId()).modificar(video); + try { + new VideoJpaController().edit(this.misVideos.get(video.getId())); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + } + + public DtListaDeReproduccion obtenerListaDeReproduccion(int id){ + ListaDeReproduccion ldr = misListas.get(id); + if (ldr == null){ + throw new RuntimeException("La lista de reproduccion no pertenece al canal"); + }else{ + return ldr.getDt(); + } + } + + public ArrayList<DtListaDeReproduccion> obtenerListasEnCategoria(String cat) { + ArrayList<DtListaDeReproduccion> ret = new ArrayList(); + + // para cada elemento en misVideos + /** + * este for no es normal, se declara la variable m que es de tipo + * Entrada de Map (como un nodo arbol), y autmaticamente la hace avanzar + * por todas las entradas de la coleccion. De la entrada actual se puede + * obtener la Key y el Valor almacenado + */ + for (Map.Entry<Integer, ListaDeReproduccion> m : misListas.entrySet()) { + // hace un getDT y lo agrega a la coleccion de retorno + if (m.getValue().getCategoria().equals(cat)) { + ret.add(m.getValue().getDt()); + } + } + + return ret; + } + + public DtVideo obtenerDtVideo(int id) { + if (this.misVideos.containsKey(id)) { + return this.misVideos.get(id).getDt(); + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + } + + public Video obtenerVideo(int id) { + if (this.misVideos.containsKey(id)) { + return this.misVideos.get(id); + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + } + + public ArrayList<DtVideo> obtenerVideosEnCategoria(String cat) { + ArrayList<DtVideo> ret = new ArrayList(); + + // para cada elemento en misVideos + /** + * este for no es normal, se declara la variable m que es de tipo + * Entrada de Map (como un nodo arbol), y autmaticamente la hace avanzar + * por todas las entradas de la coleccion. De la entrada actual se puede + * obtener la Key y el Valor almacenado + */ + for (Map.Entry<Integer, Video> m : misVideos.entrySet()) { + // hace un getDT y lo agrega a la coleccion de retorno + if (m.getValue().getCategoria().equals(cat)) { + ret.add(m.getValue().getDt()); + } + } + + return ret; + } + + public void quitarVideoDeListaDeReproduccion(int idLista, int idVideo) { + if (this.misListas.containsKey(idLista)) { + this.misListas.get(idLista).quitarVideo(idVideo); + try { + new ListaDeReproduccionJpaController().edit(this.misListas.get(idLista)); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } else { + throw new RuntimeException("La lista de reproduccion no pertenece al canal"); + } + } + + public boolean validarListaParticular(String nombreLista) { + for (Map.Entry<Integer, ListaDeReproduccion> l : misListas.entrySet()) { + if (l.getValue().getTipo() == TipoListaDeReproduccion.PARTICULAR && l.getValue().getNombre().equals(nombreLista)) { + return false; + } + } + return true; + } + + public DtValoracion obtenerValoracion(int id, String nickname) { + if (this.misVideos.containsKey(id)) { + return this.misVideos.get(id).obtenerValoracion(nickname); + } else { + throw new RuntimeException("El video no pertenece al canal"); + } + } + +} diff --git a/UyTube_logica/src/Logica/Clases/Categoria.java b/UyTube_logica/src/Logica/Clases/Categoria.java new file mode 100644 index 0000000000000000000000000000000000000000..b02df9b0a041fd7ae27c44528f295952327341c6 --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/Categoria.java @@ -0,0 +1,30 @@ +package Logica.Clases; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "categoria") +public class Categoria implements Serializable { + @Id + @Column(name = "nombre") + private String nombre; + + //--------------------------------------------------------------------------- + public Categoria() { + } + + public Categoria(String nombre) { + if (nombre.equals("")){ + throw new RuntimeException("El nombre de la categoria no puede ser vacio"); + } + this.nombre = nombre; + } + + public String getNombre() { + return nombre; + } +} diff --git a/UyTube_logica/src/Logica/Clases/Comentario.java b/UyTube_logica/src/Logica/Clases/Comentario.java new file mode 100644 index 0000000000000000000000000000000000000000..752952e492d173ec0283804cc9112a98a2fd6c25 --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/Comentario.java @@ -0,0 +1,158 @@ +package Logica.Clases; + +import JPAControllerClasses.ComentarioJpaController; +import Logica.DataType.DtComentario; +import java.io.Serializable; +import java.sql.Date; +import java.util.ArrayList; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "comentario") +public class Comentario implements Serializable { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + @Basic + @Column(name = "fecha") + private Date fecha; + + @Column(name = "texto") + private String texto; + + @Column(name = "nivel") + private int nivelSubComentario; + + @ManyToOne() + @JoinColumn(name = "nick_usuario") + private Usuario usr; + + @OneToMany(cascade = CascadeType.ALL, + orphanRemoval = true) + @JoinColumn(name = "id_com_padre") + private List<Comentario> misComentario; + + //--------------------------------------------------------------------------- + public Comentario() { + } + + public Comentario(int id, Date fecha, String texto, int nivelSubComentario, Usuario usr) { + if(usr==null){ + throw new RuntimeException("Usuario No puede ser null"); + } + if(fecha==null){ + throw new RuntimeException("Date No puede ser null"); + } + this.id = id; + this.fecha = fecha; + this.texto = texto; + this.nivelSubComentario = nivelSubComentario; + this.usr = usr; + this.misComentario = new ArrayList(); + } + + public int getId() { + return id; + } + + public Date getFecha() { + return fecha; + } + public String getTexto() { + return texto; + } + public int getNivelSubComentario() { + return nivelSubComentario; + } + + public Usuario getUsr() { + return usr; + } + + public void setUsr(Usuario usr) { + this.usr = usr; + } + + @Override + public String toString() { + return "Comentario{" + "id=" + id + ", fecha=" + fecha + ", texto=" + texto + ", nivelSubComentario=" + nivelSubComentario + '}'; + } + + public void eliminarTodoRastroDelUsuario(String nickname) { + + for (int i = 0; i < this.misComentario.size(); i++){ + if (this.misComentario.get(i).getUsr().getNickname().equals(nickname)){ + this.misComentario.remove(i); + i--; + } else { + this.misComentario.get(i).eliminarTodoRastroDelUsuario(nickname); + try { + new ComentarioJpaController().edit(this.misComentario.get(i)); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + } + } + + + public boolean agregarSubComentario(int idComPadre, DtComentario dtC, Usuario usr) { + if(dtC==null){ + throw new RuntimeException("DtComentario No puede ser null"); + } + if(usr==null){ + throw new RuntimeException("Usuario No puede ser null"); + } + if (this.id == idComPadre) { + Comentario com = new Comentario(0, + dtC.getFecha(), + dtC.getTexto(), + this.nivelSubComentario + 1, + usr); + // crea la tupla en la base de datos + // asi se genera el ID y se puede agregar al Map + new ComentarioJpaController().create(com); + this.misComentario.add(com); + return true; + } else { + boolean comentarioComentado; + for (int i = 0; i < misComentario.size(); i++) { + comentarioComentado = this.misComentario.get(i).agregarSubComentario(idComPadre, dtC, usr); + if (comentarioComentado) { + return true; + } + } + return false; + } + } + + public DtComentario getDT() { + DtComentario dtC = new DtComentario(this.id, this.usr.getNickname(), this.fecha, this.texto, this.nivelSubComentario); + return dtC; + } + + public ArrayList<DtComentario> listarSubComentarios() { + ArrayList lsc = new ArrayList(); + + for (int i = 0; i < this.misComentario.size(); i++) { + lsc.add(this.misComentario.get(i).getDT()); + lsc.addAll(this.misComentario.get(i).listarSubComentarios()); + } + return lsc; + } +} diff --git a/UyTube_logica/src/Logica/Clases/ListaDeReproduccion.java b/UyTube_logica/src/Logica/Clases/ListaDeReproduccion.java new file mode 100644 index 0000000000000000000000000000000000000000..171684d3ad3899880f1f04449e0ff7a437339e05 --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/ListaDeReproduccion.java @@ -0,0 +1,174 @@ +package Logica.Clases; + +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtVideo; +import Logica.Enumerados.Privacidad; +import Logica.Enumerados.TipoListaDeReproduccion; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Map; +import java.util.TreeMap; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +@Entity +@Table(name = "lista_de_reproduccion") +public class ListaDeReproduccion implements Serializable { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + @Column(name = "nombre") + private String nombre; + + @Enumerated(EnumType.STRING) + @Column(name = "privacidad") + private Privacidad privacidad; + + @Column(name = "eliminado") + private boolean eliminado; + + @Enumerated(EnumType.STRING) + @Column(name = "tipo") + private TipoListaDeReproduccion tipo; + + @Column(name = "categoria") + private String categoria; + + @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) + @JoinTable( + name="videos_en_listas", + joinColumns={@JoinColumn(name="id_lista", referencedColumnName="id")}, + inverseJoinColumns={@JoinColumn(name="id_video", referencedColumnName="id")}) + @MapKey(name = "id") + private Map<Integer, Video> misVideos; + + //----------------------------------------------------------------------------- + public ListaDeReproduccion() { + } + + public ListaDeReproduccion(int id, String nombre, Privacidad privacidad, TipoListaDeReproduccion tipo, String categoria) { + if (nombre.equals("")){ + throw new RuntimeException("El nombre de la lista de reproduccion no puede ser vacio"); + } + if (categoria.equals("")){ + throw new RuntimeException("La Categoria de la lista de reproduccion no puede ser vacia"); + } + if (tipo == TipoListaDeReproduccion.POR_DEFECTO && privacidad != Privacidad.PRIVADO){ + throw new RuntimeException("No se puede crear una lista de reproduccion por defecto publica"); + } + if (tipo == TipoListaDeReproduccion.POR_DEFECTO && !categoria.equals("UNDEFINED")){ + throw new RuntimeException("No se puede crear una lista de reproduccion por defecto en una categoria"); + } + this.id = id; + this.nombre = nombre; + this.privacidad = privacidad; + this.tipo = tipo; + this.categoria = categoria; + this.misVideos = new TreeMap(); + this.eliminado = false; + } + + public int getId() { + return id; + } + + public String getNombre() { + return nombre; + } + + public Privacidad getPrivacidad() { + return privacidad; + } + + public void setPrivacidad(Privacidad privacidad) { + this.privacidad = privacidad; + } + + public TipoListaDeReproduccion getTipo() { + return tipo; + } + + public String getCategoria() { + return categoria; + } + + @Override + public String toString() { + return "ListaDeReproduccion{" + "id=" + id + ", nombre=" + nombre + ", privacidad=" + privacidad + ", tipo=" + tipo + ", categoria=" + categoria + ", misVideos.size=" + misVideos.size() + '}'; + } + + public void eliminar(){ + this.eliminado = true; + + } + ///////////////////////////////////////////////////////////////////////////////////////// + + public void agregarVideoA(Video v){ + if (v == null){ + throw new RuntimeException("El video recibido para agregar a la lista es NULL"); + } + // agrega el video y su clave a la coleccion + this.misVideos.put(v.getId(), v); + } + + public DtListaDeReproduccion getDt(){ + // devuelve un DT con los datos de la lista + return new DtListaDeReproduccion(this.id, this.nombre, this.privacidad, this.tipo, this.categoria); + } + + public ArrayList<DtVideo> listarVideos(){ + // crea una lista de retorno + ArrayList<DtVideo> ret = new ArrayList(); + + // para cada elemento en misVideos + /** + * este for no es normal, se declara la variable m que es de tipo + * Entrada de Map (como un nodo arbol), y autmaticamente la hace avanzar + * por todas las entradas de la coleccion. + * De la entrada actual se puede obtener la Key y el Valor almacenado + */ + for (Map.Entry<Integer, Video> m : misVideos.entrySet()){ + // hace un getDT y lo agrega a la coleccion de retorno + ret.add(m.getValue().getDt()); + } + + return ret; + } + + public void modificar(DtListaDeReproduccion ldr) { + if (this.tipo == TipoListaDeReproduccion.POR_DEFECTO){ + throw new RuntimeException("No se puede modificar una lista por defecto"); + } + if (ldr == null){ + throw new RuntimeException("El DataTyppe recibido para modificar la lista de reproduccion es NULL"); + } + if (ldr.getNombre().equals("")){ + throw new RuntimeException("El nombre de la lista de reproduccion no puede ser vacio"); + } + // se sobreescriben los atributos que pueden ser modificados + this.nombre = ldr.getNombre(); + this.privacidad = ldr.getPrivacidad(); + this.categoria = ldr.getCategoria(); + // el ID y el tipo de lista no se puede modificar + } + + public void quitarVideo(int idVideo) { + // remueve de la coleccion el video con la clave idVideo + this.misVideos.remove(idVideo); + } + +} diff --git a/UyTube_logica/src/Logica/Clases/ListaPorDefecto.java b/UyTube_logica/src/Logica/Clases/ListaPorDefecto.java new file mode 100644 index 0000000000000000000000000000000000000000..2860ce7d3b5aca952cadb5594a54b80c6323d302 --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/ListaPorDefecto.java @@ -0,0 +1,29 @@ +package Logica.Clases; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "lista_por_defecto") +public class ListaPorDefecto implements Serializable { + + @Id + @Column(name = "nombre") + private String nombre; + + //---------------------------------------------------------------------- + public ListaPorDefecto() { + } + + public ListaPorDefecto(String nombre) { + this.nombre = nombre; + } + + public String getNombre() { + return nombre; + } + +} diff --git a/UyTube_logica/src/Logica/Clases/Persona.java b/UyTube_logica/src/Logica/Clases/Persona.java new file mode 100644 index 0000000000000000000000000000000000000000..599c6d0099d0efaa1df00940d5df94beb28aad43 --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/Persona.java @@ -0,0 +1,71 @@ +package Logica.Clases; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +@Entity +@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) +public abstract class Persona implements Serializable { + @Id + private int id; + + @Column(name = "nombre") + private String nombre; + + @Column(name = "apellido") + private String apellido; + + @Column(name = "contrasenia") + private String contrasenia; + + //----------------------------------------------------------------------------- + + public Persona() { + } + + public Persona(String nombre, String apellido, String contrasenia) { + if(contrasenia.equals("")){ + throw new RuntimeException("La contraseña no puede ser Vacio"); + } + this.nombre = nombre; + this.apellido = apellido; + this.contrasenia = contrasenia; + } + + public int getId() { + return id; + } + + public String getNombre() { + return nombre; + } + + public String getApellido() { + return apellido; + } + + public String getContrasenia() { + return contrasenia; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public void setApellido(String apellido) { + this.apellido = apellido; + } + + public void setContrasenia(String contrasenia) { + this.contrasenia = contrasenia; + } + + public boolean validarContrasenia(String pass){ + return this.contrasenia.equals(pass); + } + +} diff --git a/UyTube_logica/src/Logica/Clases/Usuario.java b/UyTube_logica/src/Logica/Clases/Usuario.java new file mode 100644 index 0000000000000000000000000000000000000000..1ca5dcaeedc420c6fb07b0861120d6d689d2691f --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/Usuario.java @@ -0,0 +1,406 @@ +package Logica.Clases; +import JPAControllerClasses.CanalJpaController; +import java.sql.Date; +import Logica.DataType.*; +import java.util.ArrayList; +import java.util.Map; +import java.util.TreeMap; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +@Entity +@Table(name="usuario") +public class Usuario extends Persona{ + @Id + @Column(name = "id") + private String id; + + @Column(name = "correo") + private String correo; + + @Basic + @Column(name = "fecha_nacimiento") + private Date fechaNacimiento; + + @Column(name = "imagen") + private String imagen; + + @Column(name = "seguidores") + private int seguidores; + + @Column(name = "eliminado") + private boolean eliminado; + + @Basic + @Column(name = "fecha_eliminado") + private Date fechaEliminado; + + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "id_canal") + private Canal MiCanal; + + @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) + @JoinTable( + name="usuarios_seguidores", + joinColumns={@JoinColumn(name="nick_seguido", referencedColumnName="id")}, + inverseJoinColumns={@JoinColumn(name="nick_seguidor", referencedColumnName="id")}) + @MapKey(name = "id") + private Map<String, Usuario> misSeguidores; + + @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) + @JoinTable( + name="usuarios_seguidos", + joinColumns={@JoinColumn(name="nick_seguidor", referencedColumnName="id")}, + inverseJoinColumns={@JoinColumn(name="nick_seguido", referencedColumnName="id")}) + @MapKey(name = "id") + private Map<String, Usuario> seguidos; + + //---------------------------------------------------------------------------------- + public Usuario() { + super(); + } + + public Usuario(String nickname, String correo, Date fechaNacimiento, String imagen, String contrasenia, String nombre, String apellido, DtCanal DTC) { + super(nombre,apellido,contrasenia); + + if(fechaNacimiento == null){ + throw new RuntimeException("la fecha no puede ser nill"); + } + if(DTC == null){ + throw new RuntimeException("El canal no puede ser null"); + } + if(nickname == ""){ + throw new RuntimeException("El nickname no puede ser Vacio"); + } + + if(correo == ""){ + throw new RuntimeException("El correo no puede ser Vacio"); + } + + this.id = nickname; + this.correo = correo; + this.fechaNacimiento = fechaNacimiento; + this.imagen = imagen; + this.seguidores = 0; + this.MiCanal = new Canal(0,DTC.getNombre(),DTC.getDescripcion(),DTC.getPrivacidad()); + this.misSeguidores = new TreeMap(); + this.seguidos = new TreeMap(); + this.eliminado = false; + this.fechaEliminado = null; + } + + public String getNickname() { + return id; + } + + public String getCorreo() { + return correo; + } + + public Date getFechaNacimiento() { + return fechaNacimiento; + } + + public String getImagen() { + return imagen; + } + + public int getSeguidores() { + return seguidores; + } + + public DtUsuario getDT(){ + return new DtUsuario(this.id, super.getContrasenia(), super.getNombre(), super.getApellido(), this.correo, this.fechaNacimiento, this.fechaEliminado, this.imagen, this.seguidores); + } + + public void eliminar(Date fecha) { + this.fechaEliminado = fecha; + this.eliminado = true; + this.MiCanal.eliminar(); + try { + new CanalJpaController().edit(this.MiCanal); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public void eliminarTodoRastroDelUsuario(String nickname) { + // Esta funcion que estas leyendo NO se encarga de eliminar vinculos de seguimiento + this.MiCanal.eliminarTodoRastroDelUsuario(nickname); + try { + new CanalJpaController().edit(this.MiCanal); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public void actualizarListasPorDefecto(ArrayList<String> listas){ + this.MiCanal.actualizarListasPorDefecto(listas); + try { + new CanalJpaController().edit(this.MiCanal); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public void agregarComentarioAVideo(int idVideo, DtComentario DtComentario, Usuario Usu){ + if(DtComentario == null){ + throw new RuntimeException("El comentario no puede ser null"); + } + if(Usu == null){ + throw new RuntimeException("El usuario no puede ser null"); + } + + this.MiCanal.agregarComentarioAVideo(idVideo, DtComentario, Usu); + } + + public void agregarComentarioAVideo(int idVideo, int idCom, DtComentario DtComentario, Usuario Usu){ + if(DtComentario == null){ + throw new RuntimeException("El comentario no puede ser null"); + } + if(Usu == null){ + throw new RuntimeException("El usuario no puede ser null"); + } + + this.MiCanal.agregarComentarioAVideo(idVideo, idCom, DtComentario, Usu); + } + + public void agregarListaParticular(DtListaDeReproduccion DtValoracion){ + if(DtValoracion == null){ + throw new RuntimeException("La valoracion no puede ser null"); + } + this.MiCanal.agregarListaParticular(DtValoracion); + try { + new CanalJpaController().edit(this.MiCanal); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public void agregarModificarValoracionDeVideo(int idVideo, DtValoracion DtValoracion, Usuario Usu){ + if(DtValoracion == null){ + throw new RuntimeException("La valoracion no puede ser null"); + } + if(Usu == null){ + throw new RuntimeException("El usuario no puede ser null"); + } + + this.MiCanal.agregarModificarValoracion(idVideo , DtValoracion, Usu); + } + + public void agregarOQuitarSeguido(Usuario Usu){ + if(Usu == null){ + throw new RuntimeException("El usuario no puede ser null"); + } + if(Usu == this){ + throw new RuntimeException("Un usuario no se puede seguir a si mismo"); + } + + if (this.seguidos.containsKey(Usu.getNickname())){ + this.seguidos.remove(Usu.getNickname()); + }else{ + this.seguidos.put(Usu.getNickname(), Usu); + } + + Usu.agregarOQuitarSeguidor(this); + } + + // si, esta si es private, no es un error + private void agregarOQuitarSeguidor(Usuario Usu){ + if(Usu == null){ + throw new RuntimeException("El usuario no puede ser null"); + } + + if (this.misSeguidores.containsKey(Usu.id)){ + this.misSeguidores.remove(Usu.getNickname()); + this.seguidores--; + }else{ + this.misSeguidores.put(Usu.getNickname(), Usu); + this.seguidores++; + } + } + + public void agregarVideoACanal(DtVideo DtVideo){ + if(DtVideo == null){ + throw new RuntimeException("El video no puede ser null"); + } + this.MiCanal.agregarVideo(DtVideo); + try { + new CanalJpaController().edit(this.MiCanal); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public void agregarVideoALista(int idLista , int idVideo, Usuario Usu){ + if(Usu == null){ + throw new RuntimeException("El usuario no puede ser null"); + } + Video v = null; + try { + v = Usu.obtenerVideo(idVideo); + } catch (Exception e) { + throw new RuntimeException("El video no pertenece al usuario: " + Usu.getNickname()); + } + this.MiCanal.agregarVideoALista(idLista, v); + } + + public ArrayList<DtComentario> listarComentariosDeVideo(int idVideo){ + return this.MiCanal.listarComentariosDeVideo(idVideo); + } + + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeCanal(boolean soloParticulares){ + return this.MiCanal.listarListasDeReproduccion(soloParticulares); + } + + public ArrayList<DtUsuario> listarUsuariosSeguidos(){ + // crea una lista de retorno + ArrayList<DtUsuario> ret = new ArrayList(); + + for (Map.Entry<String,Usuario> i : this.seguidos.entrySet()){ + // hace un getDT y lo agrega a la coleccion de retorno + ret.add(i.getValue().getDT()); + } + return ret; + }//(Ctrl + C Ctrl + V) De la clase video + + public ArrayList<DtUsuario> listarUsuariosSeguidores(){ + // crea una lista de retorno + ArrayList<DtUsuario> ret = new ArrayList(); + + for (Map.Entry<String,Usuario> i : this.misSeguidores.entrySet()){ + // hace un getDT y lo agrega a la coleccion de retorno + ret.add(i.getValue().getDT()); + } + return ret; + }//(Ctrl + C Ctrl + V) De la clase lirRepro + + public ArrayList<DtValoracion> listarValoracionesDeVideo(int id){ + return this.MiCanal.listarValoracionesDeVideo(id); + } + + public ArrayList<DtVideo> listarVideosDeCanal(){ + return this.MiCanal.listarVideos(); + } + + public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(int id){ + return this.MiCanal.listarVideosDeListaDeReproduccion(id); + } + + public void modificar(DtUsuario DtUsu, DtCanal DtCanal){ + if(DtUsu == null){ + throw new RuntimeException("El usuario no puede ser null"); + } + if(DtUsu.getFechaNacimiento() == null){ + throw new RuntimeException("La fecha no puede ser null"); + } + if(DtCanal == null){ + throw new RuntimeException("El canal no puede ser null"); + } + if (this.id != DtUsu.getNickname()){ + throw new RuntimeException("El nickname no puede ser modificado"); + } + if (this.correo != DtUsu.getCorreo()){ + throw new RuntimeException("El correo no puede ser modificado"); + } + super.setNombre(DtUsu.getNombre()); + super.setApellido(DtUsu.getApellido()); + super.setContrasenia(DtUsu.getContrasenia()); + this.fechaNacimiento = DtUsu.getFechaNacimiento(); + this.imagen = DtUsu.getImagen(); + + this.MiCanal.modificar(DtCanal); + try { + new CanalJpaController().edit(this.MiCanal); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public void modificarListaDeReproduccionDeCanal(DtListaDeReproduccion DtListaDeReproduccion){ + if(DtListaDeReproduccion == null){ + throw new RuntimeException("La lista de reproduccion no puede ser null"); + } + + this.MiCanal.modificarListaDeReproduccion(DtListaDeReproduccion); + } + + public void modificarVideoDeCanal(DtVideo DtVideo){ + if(DtVideo == null){ + throw new RuntimeException("El video no puede ser null"); + } + this.MiCanal.modificarVideo(DtVideo); + } + + public DtCanal obtenerCanal(){ + return this.MiCanal.getDT(); + } + + + public DtListaDeReproduccion obtenerListaDeReproduccion(int id){ + return MiCanal.obtenerListaDeReproduccion(id); + } + + + public ArrayList<DtListaDeReproduccion> obtenerListasEnCategoria(String cat){ + if(cat == ""){ + throw new RuntimeException("La categoria no puede ser vacia"); + } + + return this.MiCanal.obtenerListasEnCategoria(cat); + } + + public DtValoracion obtenerValoracion(int id, String nickname){ + if(nickname == ""){ + throw new RuntimeException("El nickname no puede ser vacio"); + } + + return this.MiCanal.obtenerValoracion(id, nickname); + } + + public Video obtenerVideo(int id){ + return this.MiCanal.obtenerVideo(id); + } + + public DtVideo obtenerVideoDeCanal(int idVideo){ + return this.MiCanal.obtenerDtVideo(idVideo); + } + + public ArrayList<DtVideo> obtenerVideosEnCategoria(String cat){ + if(cat == ""){ + throw new RuntimeException("La categoria no puede ser vacia"); + } + + return this.MiCanal.obtenerVideosEnCategoria(cat); + + } + + public void quitarValoracion(int id, String nickname){ + if(nickname == ""){ + throw new RuntimeException("El nickname no puede ser vacia"); + } + this.MiCanal.quitarValoracion(id, nickname); + } + + public void quitarVideoDeListaDeReproduccion(int idLista, int idVideo){ + this.MiCanal.quitarVideoDeListaDeReproduccion(idLista, idVideo); + } + + public boolean validarListaParticular(String nombre){ + if(nombre == ""){ + throw new RuntimeException("El nombre de la lista no puede ser vacia"); + } + return this.MiCanal.validarListaParticular(nombre); + } +} + diff --git a/UyTube_logica/src/Logica/Clases/Valoracion.java b/UyTube_logica/src/Logica/Clases/Valoracion.java new file mode 100644 index 0000000000000000000000000000000000000000..69d547d87034d9aa96a2e0c2d005c49e2ccb3a44 --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/Valoracion.java @@ -0,0 +1,95 @@ +package Logica.Clases; + +import Logica.DataType.DtValoracion; +import Logica.Enumerados.TipoValoracion; +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "valoracion") +public class Valoracion implements Serializable { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + @Enumerated(EnumType.STRING) + @JoinColumn(name = "valoracion") + private TipoValoracion val; + + @OneToOne(cascade = CascadeType.MERGE) + @JoinColumn(name = "nick_usuario") + private Usuario usr; + + //----------------------------------------------------------------------- + public Valoracion() { + } + + public Valoracion(TipoValoracion val, Usuario usr) { + if(usr==null){ + throw new RuntimeException("Usuario No puede ser null"); + } + this.val = val; + this.usr = usr; + } + + //----------------------------------------------------------------------- + public int getId() { + return id; + } + + public TipoValoracion getVal() { + return val; + } + + public void setVal(TipoValoracion val) { + this.val = val; + } + + public String getNicknameDeUsuario() { + return this.usr.getNickname(); + } + + public DtValoracion getDT(){ + DtValoracion dtV = new DtValoracion(this.val, this.usr.getNickname()); + return dtV; + } + public DtValoracion getDT(String nickname){ + if(nickname==null){ + throw new RuntimeException("Nickname No puede ser null"); + } + // si esta valoracion corresponde al usuario, devuelve su DT, sino null + if (nickname.equals(this.usr.getNickname())){ + return this.getDT(); + }else{ + return null; + } + } + public boolean modificar(DtValoracion dtV, String nickname){ + if(dtV==null){ + throw new RuntimeException("DtValoracion No puede ser null"); + } + if(nickname==null){ + throw new RuntimeException("Nickname No puede ser null"); + } + if (nickname.equals(this.usr.getNickname())){ + this.val = dtV.getVal(); + return true; + }else{ + return false; + } + } + + +} diff --git a/UyTube_logica/src/Logica/Clases/Video.java b/UyTube_logica/src/Logica/Clases/Video.java new file mode 100644 index 0000000000000000000000000000000000000000..221025a6cffe770ca127a9a1ad4ea344772278df --- /dev/null +++ b/UyTube_logica/src/Logica/Clases/Video.java @@ -0,0 +1,429 @@ +package Logica.Clases; +import JPAControllerClasses.ComentarioJpaController; +import JPAControllerClasses.ValoracionJpaController; +import Logica.DataType.DtComentario; +import Logica.DataType.DtValoracion; +import Logica.DataType.DtVideo; +import java.sql.Time; +import java.sql.Date; +import Logica.Enumerados.Privacidad; +import Logica.Enumerados.TipoValoracion; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +@Entity +@Table(name = "video") +public class Video implements Serializable { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + @Column(name = "nombre") + private String nombre; + + @Column(name = "descripcion") + private String descripcion; + + @Basic + @Column(name = "duracion") + private Time duracion; + + @Basic + @Column(name = "fecha_publicacion") + private Date fechaPublicacion; + + + @Column(name = "url") + private String urlVideoOriginal; + + @Enumerated(EnumType.STRING) + private Privacidad privacidad = Privacidad.PRIVADO; + + + @Column(name = "categoria") + private String categoria; + + + @Column(name = "cant_likes") + private int cantLikes = 0; + + + @Column(name = "cant_dislikes") + private int cantDisLikes = 0; + + @Column(name = "eliminado") + private boolean eliminado; + + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "id_video") + private List<Valoracion> valoraciones; + + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "id_video") + @MapKey(name = "id") + private Map<Integer, Comentario> comentarios; + + //------------------------------------------------------------------------ + public Video(){ + + } + /********************** Constructor *********************/ + public Video(int _id, String _nombre, String _descripcion,Time _duracion, Date _fechaPublicacion,String _urlVideoOriginal,String _categoria ){ + if (_nombre == "") { + throw new RuntimeException("Error, el nombre del video está vacÃo"); + } + if (_duracion == null) { + throw new RuntimeException("Error, la duración del video es null."); + } + if (_fechaPublicacion == null) { + throw new RuntimeException("Error, la fecha de publicación del video es null."); + } + if (_urlVideoOriginal == "") { + throw new RuntimeException("Error, la url del video está vacÃa."); + } + if (_categoria == "") { + throw new RuntimeException("Error, la descripción del video está vacÃa."); + } + + this.id = _id; + this.nombre = _nombre; + this.descripcion = _descripcion; + this.duracion = _duracion; + this.fechaPublicacion = _fechaPublicacion; + this.urlVideoOriginal = _urlVideoOriginal; + this.categoria = _categoria; + this.valoraciones = new ArrayList<Valoracion>(); + this.comentarios = new TreeMap<Integer, Comentario>(); + this.eliminado = false; + } + + + public void eliminar(){ + this.eliminado = true; + this.valoraciones = new ArrayList<Valoracion>(); + this.comentarios = new TreeMap<Integer, Comentario>(); + } + + public void eliminarTodoRastroDelUsuario(String nickname) { + // manda a quitar la valoracion del usuario (si no ha valorado no tiene efecto) + quitarValoracion(nickname); + ArrayList<Integer> idAEliminar = new ArrayList(); + + for (Map.Entry<Integer, Comentario> it : this.comentarios.entrySet()){ + if (it.getValue().getDT().getNickname().equals(nickname)){ + idAEliminar.add(it.getKey()); + } else { + it.getValue().eliminarTodoRastroDelUsuario(nickname); + try { + new ComentarioJpaController().edit(it.getValue()); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + } + for (Integer i : idAEliminar){ + this.comentarios.remove(i); + } + } + + + + /** Agregar un nuevo comentario **/ + public void agregarComentario(DtComentario dtComentario, Usuario usuario){ + if (dtComentario == null){ + throw new RuntimeException("El DataType es null"); + } + if (usuario == null){ + throw new RuntimeException("El usuario es null"); + } + + Comentario nuevoComentario = new Comentario(0, dtComentario.getFecha(), dtComentario.getTexto(), 0, usuario); + // crea la tupla en la base de datos + // asi se genera el ID y se puede agregar al Map + new ComentarioJpaController().create(nuevoComentario); + comentarios.put(nuevoComentario.getId(), nuevoComentario); + } + + /* Agregar un subcomentario a un comentario existente */ + public void agregarComentario(int idCom, DtComentario dtComentario, Usuario usuario){ + if (dtComentario == null){ + throw new RuntimeException("El DataType es null"); + } + if (usuario == null){ + throw new RuntimeException("El usuario es null"); + } + boolean comentarioComentado; + for (Map.Entry<Integer, Comentario> coment : comentarios.entrySet()) { + comentarioComentado = coment.getValue().agregarSubComentario(idCom, dtComentario, usuario); + if (comentarioComentado) { + try { + new ComentarioJpaController().edit(coment.getValue()); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + break; + } + } + } + + /* Agrega o midifica una valoración */ + public void agregarModificarValoracion(DtValoracion dtValoracion, Usuario usuario) { + if (dtValoracion == null) { + throw new RuntimeException("El DataType es null"); + } + if (usuario == null){ + throw new RuntimeException("El usuario es null"); + } + + String nickname = usuario.getNickname(); + // por las dudas, para que los contadores de likes no queden inconsistentes: + // obtengo la valoracion que le habia dado antes el usuario (si es que lo habia alorado) + DtValoracion dtv = this.obtenerValoracion(nickname); + // si el usuario ya lo valoro + if (dtv != null) { + // segun cual fuera la valoracion anterior, resta 1 al contador + if (dtv.getVal() == TipoValoracion.LIKE) { + cantLikes--; + } else { + cantDisLikes--; + } + + // Si te estas preguntando por que esta parte de la cobertura esta en amarillo + // te comento que es porque al for siempre se entra al menos una vez, dado que + // si se esta en este bloque del if, significa que el usuario ya ha valorado el + // video, pero para no entrar al for, ningun usuario debe haberlo hecho. + // Con el if dentro del for sucede lo mismo, tarde o temprano encuentra al + // usuario que quiere modificar su valoracion + for (Valoracion val : valoraciones) { + if (val.modificar(dtValoracion, nickname)) { + try { + new ValoracionJpaController().edit(val); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + break; + } + } + } else { + Valoracion nuevaValoracion = new Valoracion(dtValoracion.getVal(), usuario); + new ValoracionJpaController().create(nuevaValoracion); + valoraciones.add(nuevaValoracion); + } + + // segun cual sea la nueva valoracion, suma 1 al contador + if (dtValoracion.getVal() == TipoValoracion.LIKE) { + cantLikes++; + } else { + cantDisLikes++; + } + } + + public DtVideo getDt(){ + return new DtVideo(this.id, this.nombre, this.descripcion, this.duracion, this.fechaPublicacion, this.urlVideoOriginal, this.privacidad, this.categoria, this.cantLikes, this.cantDisLikes); + } + + public ArrayList<DtComentario> listarComentarios(){ + ArrayList<DtComentario> listaComent = new ArrayList<DtComentario>(); + // recorro los comentarios sobre el video + for (Map.Entry<Integer, Comentario> coment : comentarios.entrySet()) { + // le obtengo el DT y lo agrego a la lista resultado + listaComent.add(coment.getValue().getDT()); + // agrego a la lista resultado, la lista de sub comentarios + listaComent.addAll(coment.getValue().listarSubComentarios()); + } + return listaComent; + } + + public ArrayList<DtValoracion> listarValoraciones(){ + ArrayList<DtValoracion> listaValoraciones = new ArrayList(); + // recorre todo el array de valoraciones + for(int i = 0; i < this.valoraciones.size(); i++){ + // para cada elemento le pide el DT (al llamar esa funcion es que hace el new) y lo agrega a la coleccion de retorno + listaValoraciones.add(this.valoraciones.get(i).getDT()); + } + return listaValoraciones; + } + + public void modificar(DtVideo dtVideo){ + if(dtVideo == null){ + throw new RuntimeException("El DtVideo es vacÃo"); + } + // Perdon julio pero no entendi nada xD + + if(dtVideo.getNombre()== ""){ + throw new RuntimeException("El nombre no puede ser vacÃo"); + } + + if (dtVideo.getDuracion()== null) { + throw new RuntimeException("La duracion no puede ser vacÃa"); + } + + if (dtVideo.getFechaPublicacion() == null) { + throw new RuntimeException("La fecha no puede ser vacÃa"); + } + + if (dtVideo.getCategoria() == "") { + throw new RuntimeException("La categoria no puede ser vacÃa"); + } + + this.nombre = dtVideo.getNombre(); + this.descripcion = dtVideo.getDescripcion(); + this.duracion = dtVideo.getDuracion(); + this.fechaPublicacion = dtVideo.getFechaPublicacion(); + this.privacidad = dtVideo.getPrivacidad(); + this.categoria = dtVideo.getCategoria(); + this.urlVideoOriginal = dtVideo.getUrlVideoOriginal(); + } + + /* Obtiene la valoracion que hizo un usuario */ + public DtValoracion obtenerValoracion(String nickname) { + if (nickname.equals("")) { + throw new RuntimeException("El nickname no puede ser vacio"); + } + for(int i = 0; i < this.valoraciones.size(); i++){ + if( valoraciones.get(i).getNicknameDeUsuario() == nickname){ + return valoraciones.get(i).getDT(); + } + } + return null; + } + + public void quitarValoracion(String nickname){ + if (nickname.equals("")){ + throw new RuntimeException("El nickname no puede ser vacio"); + } + // Recorrer todas las valoraciones hasta encontrar la valoracion cuyo usuario sea el que tiene ese nickname + // cuando la encuentre, la saca de la coleccion + + for(int i = 0; i < this.valoraciones.size(); i++){ + if(valoraciones.get(i).getNicknameDeUsuario().equals(nickname) ){ + + // segun cual fuera la valoracion anterior, resta 1 al contador + if (valoraciones.get(i).getVal() == TipoValoracion.LIKE) { + cantLikes--; + } else { + cantDisLikes--; + } + + // remueve de la coleccion + Valoracion borrada = valoraciones.remove(i); + try { + new ValoracionJpaController().destroy(borrada.getId()); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + break; + } + + } + } + + +//============================ Get and Set ================================ + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getDescripcion() { + return descripcion; + } + + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + public Time getDuracion() { + return duracion; + } + + public void setDuracion(Time duracion) { + this.duracion = duracion; + } + + public Date getFechaPublicacion() { + return fechaPublicacion; + } + + public void setFechaPublicacion(Date fechaPublicacion) { + this.fechaPublicacion = fechaPublicacion; + } + + public String getUrlVideoOriginal() { + return urlVideoOriginal; + } + + public void setUrlVideoOriginal(String urlVideoOriginal) { + this.urlVideoOriginal = urlVideoOriginal; + } + + public Privacidad getPrivacidad() { + return privacidad; + } + + public void setPrivacidad(Privacidad privacidad) { + this.privacidad = privacidad; + } + + public String getCategoria() { + return categoria; + } + + public void setCategoria(String categoria) { + this.categoria = categoria; + } + + public int getCantLikes() { + return cantLikes; + } + + public void setCantLikes(int cantLikes) { + this.cantLikes = cantLikes; + } + + public int getCantDisLikes() { + return cantDisLikes; + } + + public void setCantDisLikes(int cantDisLikes) { + this.cantDisLikes = cantDisLikes; + } + + @Override + public String toString() { + return "Video{" + "id=" + id + ", nombre=" + nombre + ", descripcion=" + descripcion + ", duracion=" + duracion + ", fechaPublicacion=" + fechaPublicacion + ", urlVideoOriginal=" + urlVideoOriginal + ", privacidad=" + privacidad + ", categoria=" + categoria + ", cantLikes=" + cantLikes + ", cantDisLikes=" + cantDisLikes + '}'; + } + + + + +} diff --git a/UyTube_logica/src/Logica/Controladores/CAdmin.java b/UyTube_logica/src/Logica/Controladores/CAdmin.java new file mode 100644 index 0000000000000000000000000000000000000000..ae1e57e788a9d173b3983a0423fd56560cccf288 --- /dev/null +++ b/UyTube_logica/src/Logica/Controladores/CAdmin.java @@ -0,0 +1,982 @@ +package Logica.Controladores; + +// Interfaz que se realizara +import JPAControllerClasses.AdministradorJpaController; +import JPAControllerClasses.CategoriaJpaController; +import JPAControllerClasses.ListaPorDefectoJpaController; +import JPAControllerClasses.UsuarioJpaController; +import Logica.Interfaces.IAdmin; +// DataTypes +import Logica.DataType.*; +// Clases necesarias +import Logica.Clases.Administrador; +import Logica.Clases.Usuario; +import Logica.Clases.Categoria; +import Logica.Clases.ListaPorDefecto; +import Logica.DatosDePrueba; +// Colecciones +import java.util.Map; +import java.util.TreeMap; +import java.util.ArrayList; +import java.util.List; + + +public class CAdmin implements IAdmin{ + private static CAdmin instancia = null; + private Map<String, Usuario> usuarios; + private Map<Integer, Administrador> administradores; + private Map<String, Categoria> categorias; + private Map<String, ListaPorDefecto> listasPorDefecto; + private Usuario usuarioActual; + private Usuario usuarioSeleccionado; + private int idListaSeleccionada; + private int idVideoSeleccionado; + + + private CAdmin(){ + this.usuarios = new TreeMap(String.CASE_INSENSITIVE_ORDER); + this.administradores = new TreeMap(); + this.categorias = new TreeMap(); + this.listasPorDefecto = new TreeMap(); + this.usuarioActual = null; + this.usuarioSeleccionado = null; + this.idListaSeleccionada = 0; + this.idVideoSeleccionado = 0; + + // si la categoria no esta en la BDD, la crea + if ( ! existeCategoria("UNDEFINED")){ + this.altaCategoria("UNDEFINED"); + } + + sincronizarAdministradoresConBDD(); + sincronizarCategoriasConBDD(); + sincronizarListasPorDefectoConBDD(); + sincronizarUsuariosConBDD(); + + // si en la BDD no hay administrador, lo crea + if (this.administradores.isEmpty()) { + // Administrador por defecto (temporal) + Administrador root = new Administrador(0, "admin", "administrador", "root"); + try { + new AdministradorJpaController().create(root); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + this.administradores.put(root.getIdAdmin(), root); + } + } + + public static CAdmin getInstancia(){ + if( instancia == null ){ + instancia = new CAdmin(); + } + return instancia; + } + + private void sincronizarUsuariosConBDD(){ + this.usuarios = new TreeMap(String.CASE_INSENSITIVE_ORDER); + try { + List<Usuario> usuariosEnBDD = new UsuarioJpaController().findUsuarioEntities(); + for (Usuario u : usuariosEnBDD){ + // si en BDD hay algo que no este en memoria + if ( ! this.usuarios.containsKey(u.getNickname())){ + this.usuarios.put(u.getNickname(), u); + } + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + private void sincronizarAdministradoresConBDD(){ + this.administradores = new TreeMap(); + try { + List<Administrador> administradoresEnBDD = new AdministradorJpaController().findAdministradorEntities(); + for (Administrador a : administradoresEnBDD){ + // si en BDD hay algo que no este en memoria + if ( ! this.administradores.containsKey(a.getIdAdmin())){ + this.administradores.put(a.getIdAdmin(), a); + } + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + private void sincronizarCategoriasConBDD(){ + this.categorias = new TreeMap(); + try { + List<Categoria> categoriasEnBDD = new CategoriaJpaController().findCategoriaEntities(); + for (Categoria c : categoriasEnBDD){ + // si en BDD hay algo que no este en memoria + if ( ! this.categorias.containsKey(c.getNombre())){ + this.categorias.put(c.getNombre(), c); + } + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + private void sincronizarListasPorDefectoConBDD(){ + this.listasPorDefecto = new TreeMap(); + try { + List<ListaPorDefecto> listasPorDefectoEnBDD = new ListaPorDefectoJpaController().findListaPorDefectoEntities(); + for (ListaPorDefecto l : listasPorDefectoEnBDD){ + // si en BDD hay algo que no este en memoria + if ( ! this.listasPorDefecto.containsKey(l.getNombre())){ + this.listasPorDefecto.put(l.getNombre(), l); + } + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + // //////////////////////////////////////////////////////////////////////////////////////// + public void agregarVideoAListaDeReproduccion(int idLista){ + /** + * Agrega el video idVideoSeleccionado a la lista idListaSeleccionada + */ + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (usuarioActual == null){ + throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + if (idLista == 0){ + throw new RuntimeException("El ID de la lista de reproduccion no es valido"); + } + usuarioActual.agregarVideoALista(idLista, idVideoSeleccionado, usuarioSeleccionado); + } + + public void altaCategoria(String categoria){ + /** + * Crea la categoria con el nombre indicado + */ + if (categoria.equals("")){ + throw new RuntimeException("El nombre de la categoria no puede ser vacio"); + } + if (existeCategoria(categoria)){ + throw new RuntimeException("El sistema ya posee una categoria con ese nombre"); + } + Categoria cat = new Categoria(categoria); + categorias.put(cat.getNombre(), cat); + try { + new CategoriaJpaController().create(cat); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public void altaComentario(DtComentario dtCom){ + /** + * Comenta el video idVideoSeleccionado a nombre de usuarioActual + */ + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (usuarioActual == null){ + throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); + } + if (dtCom == null){ + throw new RuntimeException("El DataType comentario no puede ser null"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + usuarioSeleccionado.agregarComentarioAVideo(idVideoSeleccionado, dtCom, usuarioActual); + } + + public void altaComentario(DtComentario dtCom, int idComPadre){ + /** + * Comenta el comentario con dicho ID a nombre de usuarioActual + */ + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (usuarioActual == null){ + throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); + } + if (dtCom == null){ + throw new RuntimeException("El DataType comentario no puede ser null"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + usuarioSeleccionado.agregarComentarioAVideo(idVideoSeleccionado, idComPadre, dtCom, usuarioActual); + } + + public void altaListaDeReproduccionParticular(DtListaDeReproduccion lista) { + /** + * Crea la lista de reproduccion para usuarioSeleccionado + */ + if (usuarioSeleccionado == null) { + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (lista == null) { + throw new RuntimeException("El DataType recibido es null"); + } + if (!existeCategoria(lista.getCategoria())) { + throw new RuntimeException("La categoria no existe"); + } + usuarioSeleccionado.agregarListaParticular(lista); + } + + public void altaListaDeReproduccionPorDefecto(DtListaDeReproduccion lista){ + /** + * Crea la lista de reproduccion para todos los usuarios del sistema y + * la agrega listas por defecto (para que se creen al crear un usuario nuevo) + */ + if (lista == null){ + throw new RuntimeException("El DataType lista de reproduccion no puede ser null"); + } + if (lista.getNombre().equals("")){ + throw new RuntimeException("El nombre de la nueva lista de reproduccion por defecto no puede ser vacio"); + } + if (listasPorDefecto.containsKey(lista.getNombre())){ + throw new RuntimeException("El sistema ya posee una lista de reproduccion por defecto con ese nombre"); + } + ListaPorDefecto lpd = new ListaPorDefecto(lista.getNombre()); + try { + new ListaPorDefectoJpaController().create(lpd); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + listasPorDefecto.put(lista.getNombre(), lpd); + ArrayList<String> nuevaLista = new ArrayList(); + nuevaLista.add(lista.getNombre()); + for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ + u.getValue().actualizarListasPorDefecto(nuevaLista); + } + } + + public void altaUsuarioCanal(DtUsuario usr, DtCanal canal){ + /** + * Crea un usuario y su canal a partir de los datos recibidos + */ + if (usr == null){ + throw new RuntimeException("El DataType usuario no puede ser null"); + } + if (canal == null){ + throw new RuntimeException("El DataType canal no puede ser null"); + } + if (existeNickname(usr.getNickname())){ + throw new RuntimeException("El sistema ya tiene un usuario con ese nickname"); + } + if (existeEmail(usr.getCorreo())){ + throw new RuntimeException("El sistema ya tiene un usuario con ese correo"); + } + + ArrayList<String> listasDefault = new ArrayList(); + for (Map.Entry<String, ListaPorDefecto> lpd : listasPorDefecto.entrySet()) { + listasDefault.add(lpd.getKey()); + } + + Usuario nuevoUsuario = new Usuario( + usr.getNickname(), + usr.getCorreo(), + usr.getFechaNacimiento(), + usr.getImagen(), + usr.getContrasenia(), + usr.getNombre(), + usr.getApellido(), + canal + ); + try { + new UsuarioJpaController().create(nuevoUsuario); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + nuevoUsuario.actualizarListasPorDefecto(listasDefault); + usuarios.put(nuevoUsuario.getNickname(), nuevoUsuario); + } + + public void altaValoracion(DtValoracion val){ + /** + Se ingresa la nueva valoracion dada por usuarioActual al video idVideoSeleccionado + Si el usuario ya habia valorado, se actualiza la valoracion dada + */ + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (usuarioActual == null){ + throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + if (val == null){ + usuarioSeleccionado.quitarValoracion(idVideoSeleccionado, usuarioActual.getNickname()); + }else{ + usuarioSeleccionado.agregarModificarValoracionDeVideo(idVideoSeleccionado, val, usuarioActual); + } + } + + public void altaVideo(DtVideo video){ + /** + * Se crea un video nuevo en el canal de usuarioSeleccionado + */ + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (video == null){ + throw new RuntimeException("El DataType video no puede ser null"); + } + if ( ! existeCategoria(video.getCategoria())){ + throw new RuntimeException("La categoria no existe"); + } + usuarioSeleccionado.agregarVideoACanal(video); + } + + public void bajaUsuario(){ + /** + * Elimina el usuario actual seleccionado + */ + /** + * Este algoritmo debe: + * Quitar las relaciones con usuarios seguidos y de seguidores + * Quitar los videos del usuario a eliminar de las listas de otros usuarios. + * Quitar comentarios en los videos del usuario a eliminar + * Quitar valoraciones en los videos del usuario a eliminar + * Quitar las valoraciones dadas por el usuario de todos los videos del sistema + * Quitar los comentarios hechos por el usuario de todos los videos del sistema + * + */ + + Usuario elim = usuarioActual; + + // * Quitar las relaciones con usuarios seguidos y de seguidores + // El usuario que se va a eliminar deja de seguir a todos los que sigue + ArrayList<DtUsuario> seguidos = usuarioActual.listarUsuariosSeguidos(); + for (DtUsuario u : seguidos) { + this.seleccionarUsuario(u.getNickname()); + this.seguirUsuario(); + } + this.liberarMemoriaUsuario(); + + // Todos los usuarios que siguen al que se va a eliminar, lo dejan de seguir + ArrayList<DtUsuario> seguidores = usuarioActual.listarUsuariosSeguidores(); + this.seleccionarUsuario(usuarioActual.getNickname()); + for (DtUsuario u : seguidores) { + this.seleccionarUsuarioActual(u.getNickname()); + this.seguirUsuario(); + } + this.liberarMemoriaUsuario(); + this.seleccionarUsuarioActual(elim.getNickname()); + + // para cada usuario del sistema, recorro todas sus listas y en cada + // una manda a quitar todoslos videos del usuario a eliminar + this.seleccionarUsuario(elim.getNickname()); + ArrayList<DtVideo> videos = this.listarVideosDeUsuario(); + // Para facilitar el algoritmo, agrego a la coleccion (de manera provisoria) los usuarios eliminados + // ¡Recuerdo los nicknames para sacarlos despues! + ArrayList<String> nicksProvisorios = new ArrayList(); + try { + for (Usuario u : new UsuarioJpaController().findUsuarioEliminadoEntities()){ + nicksProvisorios.add(u.getNickname()); + this.usuarios.put(u.getNickname(), u); + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + + for (Map.Entry<String, Usuario> it : usuarios.entrySet()){ + if (it.getValue().getNickname().equals(elim.getNickname())) continue; + + // * Quitar los videos del usuario a eliminar de las listas de otros usuarios. + ArrayList<DtListaDeReproduccion> listas = it.getValue().listarListasDeReproduccionDeCanal(false); + for (DtListaDeReproduccion l : listas){ + for (DtVideo v : videos){ + it.getValue().quitarVideoDeListaDeReproduccion(l.getId(), v.getId()); + } + } + + // * Quitar las valoraciones dadas por el usuario de todos los videos del sistema + // * Quitar los comentarios hechos por el usuario de todos los videos del sistema + it.getValue().eliminarTodoRastroDelUsuario(elim.getNickname()); + try { + new UsuarioJpaController().edit(it.getValue()); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + // quito de la coleccion los usuarios que estaban eliminados y agregue provisoriamente antes del for + for (String s : nicksProvisorios){ + this.usuarios.remove(s); + } + + // obtiene la fecha actual + java.util.Date utilDate = new java.util.Date(); + java.sql.Date hoy = new java.sql.Date(utilDate.getTime()); + + // * Quitar comentarios en los videos del usuario a eliminar + // * Quitar valoraciones en los videos del usuario a eliminar + usuarioActual.eliminar(hoy); + try { + new UsuarioJpaController().edit(usuarioActual); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + this.usuarios.remove(elim.getNickname()); + } + + + public boolean existeCategoria(String cat){ + /** + * Verifica si existe una categoria con el nombre recibido + */ + sincronizarCategoriasConBDD(); + return categorias.containsKey(cat); + } + + public boolean existeEmail(String email){ + /** + * Verifica si existe un usuario con el mail recibido + */ + sincronizarUsuariosConBDD(); + for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ + if (u.getValue().getCorreo().equals(email)){ + return true; + } + } + for (DtUsuario dtu : this.listarUsuariosEliminados()){ + if (dtu.getCorreo().equals(email)){ + return true; + } + } + return false; + } + + public boolean existeNickname(String nickname){ + /** + * Verifica si existe un usuario con el nickname recibido + */ + sincronizarUsuariosConBDD(); + if (usuarios.containsKey(nickname)){ + return true; + } + for (DtUsuario dtu : this.listarUsuariosEliminados()){ + if (dtu.getNickname().equals(nickname)){ + return true; + } + } + return false; + } + + public boolean iniciarSesionAdministrador(int id, String pass){ + /** + * Verifica la contrasenia para el administrador con esa ID y devuelve true si es correcta + * En cualquier otro caso devuelve false + */ + sincronizarAdministradoresConBDD(); + Administrador a = administradores.get(id); + if (a == null){ + return false; + } + return a.validarContrasenia(pass); + } + + public boolean iniciarSesionUsuario(String nickname, String pass){ + sincronizarUsuariosConBDD(); + Usuario u = usuarios.get(nickname); + if (u == null){ + return false; + } + boolean ok = u.validarContrasenia(pass); + if (ok){ + usuarioActual = u; + } + return ok; + } + + public void liberarMemoriaListaDeReproduccion(){ + idListaSeleccionada = 0; + } + + public void liberarMemoriaUsuario(){ + usuarioSeleccionado = null; + } + + public void liberarMemoriaUsuarioActual(){ + usuarioActual = null; + } + + public void liberarMemoriaVideo(){ + idVideoSeleccionado = 0; + } + + public ArrayList<String> listarCategorias(){ + /** + * Devuelve todas las categorias existentes en el sistema + */ + sincronizarCategoriasConBDD(); + ArrayList<String> ret = new ArrayList(); + for (Map.Entry<String, Categoria> c : categorias.entrySet()){ + ret.add(c.getValue().getNombre()); + } + return ret; + } + + public ArrayList<DtComentario> listarComentariosDeVideo(){ + /** + * Devuelve en forma ordenada (recursiva ) todos los comentarios de idVideoSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + return usuarioSeleccionado.listarComentariosDeVideo(idVideoSeleccionado); + } + + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionEnCategoria(String cat){ + /** + * Devuelve todos las listas de reproduccion del sistema que pertenezcan a la categoria indicada + */ + if (cat.equals("")){ + throw new RuntimeException("La categoria no puede ser vacia"); + } + sincronizarUsuariosConBDD(); + sincronizarCategoriasConBDD(); + ArrayList<DtListaDeReproduccion> ret = new ArrayList(); + for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ + ret.addAll(u.getValue().obtenerListasEnCategoria(cat)); + } + return ret; + } + + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeUsuario(String nickname){ + /** + * Devuelve todas las listas de reproduccion de usuarioSeleccionado o de usuarioActual segun el nickname indicado + */ + if (nickname.equals("")){ + throw new RuntimeException("El nickname del usuario no puede ser vacio"); + } + if (usuarioActual == null && usuarioSeleccionado == null){ + throw new RuntimeException("No hay usuarios seleccionados"); + } + + if (usuarioActual != null && usuarioActual.getNickname().equals(nickname)){ + return usuarioActual.listarListasDeReproduccionDeCanal(false); + } + if (usuarioSeleccionado != null && usuarioSeleccionado.getNickname().equals(nickname)){ + return usuarioSeleccionado.listarListasDeReproduccionDeCanal(false); + } + throw new RuntimeException("El nickname no coincide con los posibles usuarios seleccionados"); + } + + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionParticularesDeUsuario(){ + /** + * Devuelve las listas de reproduccion particulares de usuarioSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + return usuarioSeleccionado.listarListasDeReproduccionDeCanal(true); + } + + public ArrayList<DtUsuario> listarUsuarioSeguidores(){ + /** + * Devuelve todos los usuarios que siguen a usuarioSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + return usuarioSeleccionado.listarUsuariosSeguidores(); + } + + public ArrayList<DtUsuario> listarUsuarioNoSeguidos(){ + /** + * Devuelve todos los usuarios a quienes sigue usuarioSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + // creo el array de retorno y obtengo la lista de usuarios seguidos + ArrayList<DtUsuario> noSeguidos = new ArrayList(); + ArrayList<DtUsuario> seguidos = listarUsuarioSeguidos(); + // para saber si hay que agregar a la lista de retorno o no + boolean agregar; + + // no quiero que incluya al usuario seleccinado, asi que lo agrego para excluirlo + seguidos.add(usuarioSeleccionado.getDT()); + + // rrecorro los usuarios del sistema + for (Map.Entry<String, Usuario> u : usuarios.entrySet()) { + agregar = true; + // recorro los usuarios seguidos para ver si debo agregar a u al array de retorno + for (DtUsuario uSegido : seguidos){ + // si encuentra coincidencia, no debo agregarlo ya que es un usuario seguido + if (u.getKey().equals(uSegido.getNickname())){ + // lo saco del array para ahorrar procesamiento + seguidos.remove(uSegido); + agregar = false; + break; + } + } + if (agregar){ + noSeguidos.add(u.getValue().getDT()); + } + } + return noSeguidos; + } + + public ArrayList<DtUsuario> listarUsuarioSeguidos(){ + /** + * Devuelve todos los usuarios a quienes sigue usuarioSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + return usuarioSeleccionado.listarUsuariosSeguidos(); + } + + public ArrayList<DtUsuario> listarUsuarios(){ + /** + * Devuelve todos los datos de todos los usuarios + */ + sincronizarUsuariosConBDD(); + ArrayList<DtUsuario> ret = new ArrayList<>(); + for (Map.Entry<String, Usuario> usuario : usuarios.entrySet()) { + ret.add(usuario.getValue().getDT()); + } + return ret; + } + + public ArrayList<DtUsuario> listarUsuariosEliminados(){ + /** + * Devuelve todos los datos de todos los usuarios eliminados + */ + ArrayList<DtUsuario> ret = new ArrayList(); + try { + for (Usuario u : new UsuarioJpaController().findUsuarioEliminadoEntities()){ + ret.add(u.getDT()); + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + return ret; + } + + public ArrayList<DtVideo> listarVideosEnCategoria(String cat){ + /** + * Devuelve todos los videos del sistema que pertenezcan a la categoria indicada + */ + if (cat.equals("")){ + throw new RuntimeException("La categoria no puede ser vacia"); + } + sincronizarUsuariosConBDD(); + sincronizarCategoriasConBDD(); + ArrayList<DtVideo> ret = new ArrayList(); + for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ + ret.addAll(u.getValue().obtenerVideosEnCategoria(cat)); + } + return ret; + } + + public ArrayList<DtVideo> listarVideosDeUsuario(){ + /** + * Devuelve todos los videos de usuarioSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + return usuarioSeleccionado.listarVideosDeCanal(); + } + + public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(){ + /** + * Devuelve los videos de la lista de reproduccion idListaSeleccionada + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idListaSeleccionada == 0){ + throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionado"); + } + return usuarioSeleccionado.listarVideosDeListaDeReproduccion(idListaSeleccionada); + } + + public void modificarListaDeReproduccion(DtListaDeReproduccion lista){ + /** + * Se modifican los datos de la lista idListaSeleccionada + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idListaSeleccionada == 0){ + throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionado"); + } + if (lista == null){ + throw new RuntimeException("El DataType recibido es null"); + } + if ( ! existeCategoria(lista.getCategoria())){ + throw new RuntimeException("La categoria no existe"); + } + // no confio en que el DataType recibido venga con el id del video correcto, + // asi que creo otro y con el idVideoSeleccionado por las dudas + DtListaDeReproduccion dtl = new DtListaDeReproduccion( + idListaSeleccionada, + lista.getNombre(), + lista.getPrivacidad(), + lista.getTipo(), + lista.getCategoria()); + usuarioSeleccionado.modificarListaDeReproduccionDeCanal(dtl); + } + + public void modificarUsuarioYCanal(DtUsuario usr,DtCanal canal){ + /** + * Se modifican los datos de usuarioActual y su canal + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (usr == null){ + throw new RuntimeException("El DataType usuario no puede ser null"); + } + if (canal == null){ + throw new RuntimeException("El DataType canal no puede ser null"); + } + usuarioSeleccionado.modificar(usr, canal); + try { + new UsuarioJpaController().edit(usuarioSeleccionado); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public void modificarVideo(DtVideo video){ + /** + * Se modifican los datos del video idVideoSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + if (video == null){ + throw new RuntimeException("El DataType video no puede ser null"); + } + if ( ! existeCategoria(video.getCategoria())){ + throw new RuntimeException("La categoria no existe"); + } + // no confio en que el DataType recibido venga con el id del video correcto, + // asi que creo otro y con el idVideoSeleccionado por las dudas + DtVideo dtv = new DtVideo( + idVideoSeleccionado, + video.getNombre(), + video.getDescripcion(), + video.getDuracion(), + video.getFechaPublicacion(), + video.getUrlVideoOriginal(), + video.getPrivacidad(), + video.getCategoria(), + 0, 0); + + usuarioSeleccionado.modificarVideoDeCanal(dtv); + } + + public DtUsuario obtenerPropietarioDeVideo(int idVideo){ + /** + * Busca entre todos los usuarios al propietario del video con ese ID + */ + + sincronizarUsuariosConBDD(); + // Esto es un parche, pero de los que nunca se despegan... + // A tiempos desesperados, medidas desesperadas + for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ + try { + u.getValue().obtenerVideo(idVideo); + return u.getValue().getDT(); + } catch (Exception e) { + // a seguir buscando + } + } + throw new RuntimeException("El iID de video no crresponde a ningun usuario"); + } + + public DtCanal obtenerCanalDeUsuario(){ + /** + * Devuelve los datos del canal del usuario en memoria usuarioSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + return usuarioSeleccionado.obtenerCanal(); + } + + public ArrayList<DtValoracion> obtenerValoracionesDeVideo(){ + /** + * Devuelve las valoraciones de idVideoSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + return usuarioSeleccionado.listarValoracionesDeVideo(idVideoSeleccionado); + } + + public DtValoracion obtenerValoracionDada(){ + /** + * Devuelve la valoracion dada por usuarioActual al video idVideoSeleccionado + * + */ + if (this.usuarioActual == null) { + throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); + } + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + // si la funcion retorna null, significa que el usuario no lo ha valorado. Entonces no se considera error + return usuarioSeleccionado.obtenerValoracion(idVideoSeleccionado, usuarioActual.getNickname()); + } + + public void quitarVideoDeListaDeReproduccion(int idVideo){ + /** + * Quita el video idVideoSeleccionado de la lista idListaSeleccionada + */ + if (usuarioSeleccionado == null) { + throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); + } + if (idListaSeleccionada == 0){ + throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionado"); + } + if (idVideo == 0){ + throw new RuntimeException("El ID de video no es valido"); + } + usuarioSeleccionado.quitarVideoDeListaDeReproduccion(idListaSeleccionada, idVideo); + } + + public DtUsuario seleccionarUsuario(String nickname){ + /** + * El sistema recuerda un link al usuario como usuarioSeleccionado + * Devuelve los datos de usuarioSeleccionado + */ + sincronizarUsuariosConBDD(); + usuarioSeleccionado = usuarios.get(nickname); + if (usuarioSeleccionado == null){ + throw new RuntimeException("No se encontro ningun usuario con ese nickname"); + } + return usuarioSeleccionado.getDT(); + } + + public DtUsuario seleccionarUsuarioEliminado(String nickname){ + /** + * El sistema recuerda un link al usuario eliminado como usuarioActual Devuelve + * los datos de usuarioActual + */ + try { + usuarioSeleccionado = new UsuarioJpaController().findUsuario(nickname); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + if (usuarioSeleccionado == null){ + throw new RuntimeException("No se encontro ningun usuario con ese nickname"); + } + return usuarioSeleccionado.getDT(); + } + + public DtUsuario seleccionarUsuarioActual(String nickname){ + /** + * El sistema recuerda un link al usuario como usuarioActual Devuelve + * los datos de usuarioActual + */ + sincronizarUsuariosConBDD(); + usuarioActual = usuarios.get(nickname); + if (usuarioActual == null){ + throw new RuntimeException("No se encontro ningun usuario con ese nickname"); + } + return usuarioActual.getDT(); + } + + public DtVideo seleccionarVideo(int idVideo){ + /** + El sistema recuerda el ID del video como idVideoSeleccionado Devuelve + * los datos del video seleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + DtVideo ret = usuarioSeleccionado.obtenerVideoDeCanal(idVideo); + idVideoSeleccionado = idVideo; + return ret; + } + + public DtListaDeReproduccion seleccionarListaDeReproduccion(int idLista){ + /** + * El sistema recuerda el ID de la lista como idListaSeleccionada + * Devuelve los datos de la lista de reproduccion seleccionada perteneciente a usuarioSeleccionado + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + DtListaDeReproduccion ret = usuarioSeleccionado.obtenerListaDeReproduccion(idLista); + idListaSeleccionada = idLista; + return ret; + } + + public void seguirUsuario(){ + /** + * El usuario usuarioActual comienza a seguir a usuarioSeleccionado En + * caso de que este ya lo este siguiendo, lo deja de seguir + */ + if (this.usuarioActual == null) { + throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); + } + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + usuarioActual.agregarOQuitarSeguido(usuarioSeleccionado); + try { + new UsuarioJpaController().edit(usuarioSeleccionado); + new UsuarioJpaController().edit(usuarioActual); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + public boolean validarNuevaListaParticular(String nombre){ + /** + * Devuelve false si usuarioSeleccionado posee una lista de reproducion con ese nombre + */ + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + sincronizarListasPorDefectoConBDD(); + if (listasPorDefecto.containsKey(nombre)) { + return false; + } + return usuarioSeleccionado.validarListaParticular(nombre); + } + + public boolean validarNuevaListaPorDefecto(String nombre){ + /** + * Devuelve false si existe algun usuario en el sistema que posea una + * lista de reproduccion con ese nombre + */ + sincronizarListasPorDefectoConBDD(); + sincronizarUsuariosConBDD(); + if (listasPorDefecto.containsKey(nombre)) { + return false; + } + for (Map.Entry<String, Usuario> u : this.usuarios.entrySet()){ + if ( ! u.getValue().validarListaParticular(nombre)){ + return false; + } + } + return true; + } +} + diff --git a/UyTube_logica/src/Logica/Controladores/CUsuario.java b/UyTube_logica/src/Logica/Controladores/CUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..d1afc0a86edb837fcb6c10747f7543e544c7d83c --- /dev/null +++ b/UyTube_logica/src/Logica/Controladores/CUsuario.java @@ -0,0 +1,823 @@ +package Logica.Controladores; + +import JPAControllerClasses.BusquedaEnBDD; +import JPAControllerClasses.CategoriaJpaController; +import JPAControllerClasses.ListaPorDefectoJpaController; +import JPAControllerClasses.UsuarioJpaController; +import Logica.Clases.Categoria; +import Logica.Clases.ListaPorDefecto; +import Logica.Clases.Usuario; +import Logica.Clases.Video; +import Logica.DataType.DtCanal; +import Logica.DataType.DtComentario; +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtUsuario; +import Logica.DataType.DtValoracion; +import Logica.DataType.DtVideo; +import Logica.Enumerados.Filtrado; +import Logica.Enumerados.Ordenacion; +import Logica.Enumerados.Privacidad; +import Logica.Enumerados.TipoListaDeReproduccion; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import Logica.Interfaces.IUsuario; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +public class CUsuario implements IUsuario { + private static CUsuario instancia = null; + private Usuario usuarioActual; + private Usuario usuarioSeleccionado; + private int idListaSeleccionada; + private int idVideoSeleccionado; + + private CUsuario() { + this.usuarioActual = null; + this.usuarioSeleccionado = null; + this.idListaSeleccionada = 0; + this.idVideoSeleccionado = 0; + } + public static CUsuario getInstancia() { + if (instancia == null) { + instancia = new CUsuario(); + } + return instancia; + } + + //***************** Traer datos de la base de datos ******************* + /** + * Lista los usuarios no eliminados desde la base de datos + * @return Mapa de usuarios indexados por nickname + */ + private Map<String, Usuario> obtenerUsuarios(){ + Map<String, Usuario> usuarios = new TreeMap(); + try { + List<Usuario> usuariosEnBDD = new UsuarioJpaController().findUsuarioEntities(); + for (Usuario u : usuariosEnBDD){ + usuarios.put(u.getNickname(), u); + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + return usuarios; + } + + /** + * Lista las categorias desde la base de datos + * @return Mapa de categorias indexados por nombre + */ + private Map<String, Categoria> obtenerCategorias(){ + Map<String, Categoria> categorias = new TreeMap(); + try { + List<Categoria> categoriasEnBDD = new CategoriaJpaController().findCategoriaEntities(); + for (Categoria c : categoriasEnBDD){ + categorias.put(c.getNombre(), c); + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + return categorias; + } + + /** + * Lista los nombres de las listas por defecto desde la base de datos + * @return Mapa de listas por defecto indexados por nombre + */ + private Map<String, ListaPorDefecto> obtenerListasPorDefecto(){ + Map<String, ListaPorDefecto> ListasPorDefecto = new TreeMap(); + try { + List<ListaPorDefecto> listasPorDefectoEnBDD = new ListaPorDefectoJpaController().findListaPorDefectoEntities(); + for (ListaPorDefecto l : listasPorDefectoEnBDD){ + ListasPorDefecto.put(l.getNombre(), l); + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + return ListasPorDefecto; + } + + //******************** Funciones de la interfaz ************************ + @Override + public void agregarVideoAListaDeReproduccion(int idLista) { + if (usuarioActual == null){ + throw new RuntimeException("No se ha iniciado sesión"); + } + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + if (idLista == 0){ + throw new RuntimeException("El ID de la lista de reproduccion no es valido"); + } + usuarioActual.agregarVideoALista(idLista, idVideoSeleccionado, usuarioSeleccionado); + } + + @Override + public void altaComentario(DtComentario dtCom) { + if (usuarioActual == null){ + throw new RuntimeException("No se ha iniciado sesión"); + } + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (dtCom == null){ + throw new RuntimeException("El DataType comentario no puede ser null"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + usuarioSeleccionado.agregarComentarioAVideo(idVideoSeleccionado, dtCom, usuarioActual); + } + + @Override + public void altaComentario(DtComentario dtCom, int idComPadre) { + if (usuarioActual == null){ + throw new RuntimeException("No se ha iniciado sesión"); + } + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (dtCom == null){ + throw new RuntimeException("El DataType comentario no puede ser null"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + usuarioSeleccionado.agregarComentarioAVideo(idVideoSeleccionado, idComPadre, dtCom, usuarioActual); + } + + @Override + public void altaListaDeReproduccionParticular(DtListaDeReproduccion lista) { + if (usuarioActual == null) { + throw new RuntimeException("No se ha iniciado sesión"); + } + if (lista == null) { + throw new RuntimeException("El DataType recibido es null"); + } + if ( ! this.obtenerCategorias().containsKey(lista.getCategoria())) { + throw new RuntimeException("La categoria no existe"); + } + usuarioActual.agregarListaParticular(lista); + } + + @Override + public void altaUsuarioCanal(DtUsuario usr, DtCanal canal) { + // valida datos recibidos + if (usr == null){ + throw new RuntimeException("El DataType usuario no puede ser null"); + } + if (canal == null){ + throw new RuntimeException("El DataType canal no puede ser null"); + } + if (existeNickname(usr.getNickname())){ + throw new RuntimeException("El sistema ya tiene un usuario con ese nickname"); + } + if (existeEmail(usr.getCorreo())){ + throw new RuntimeException("El sistema ya tiene un usuario con ese correo"); + } + // obtiene las listas por defecto que el usuario debera crear + ArrayList<String> listasDefault = new ArrayList(); + for (Map.Entry<String, ListaPorDefecto> lpd : this.obtenerListasPorDefecto().entrySet()) { + listasDefault.add(lpd.getKey()); + } + // Crea al usuario + Usuario nuevoUsuario = new Usuario( + usr.getNickname(), + usr.getCorreo(), + usr.getFechaNacimiento(), + usr.getImagen(), + usr.getContrasenia(), + usr.getNombre(), + usr.getApellido(), + canal + ); + // persiste el usuario + try { + new UsuarioJpaController().create(nuevoUsuario); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + // Actualiza sus listas por defecto + nuevoUsuario.actualizarListasPorDefecto(listasDefault); + // Le inicia la sesion + this.iniciarSesionUsuario(usr.getNickname(), usr.getContrasenia()); + } + + @Override + public void altaVideo(DtVideo video) { + if(usuarioActual == null){ + throw new RuntimeException("No se a iniciado sesión"); + } + if (video == null) { + throw new RuntimeException("El video no puede ser null"); + } + if(!obtenerCategorias().containsKey(video.getCategoria())){ + throw new RuntimeException("La categoria no existe"); + } + usuarioActual.agregarVideoACanal(video); + } + + @Override + public void bajaUsuario() { + if(usuarioActual == null){ + throw new RuntimeException("No se a iniciado sesión"); + } + // Bienvenido al parche + // La verdad no sabia bien como implementar esta funcion, asi que mejor no reinventar la rueda, uso la que ya existe aunque implique llamar al otro controlador... + IAdmin ca = Fabrica.getInstancia().getIAdmin(); + ca.seleccionarUsuarioActual(usuarioActual.getNickname()); + cerrarSesion(); + ca.bajaUsuario(); + } + + @Override + public ArrayList<Object> buscar(String busqueda, Filtrado filtro, Ordenacion orden) { + //Cambiar la linea de abajo cuando se implemente la funcion de juan + // hecho + ArrayList<Object> ret = new BusquedaEnBDD().buscar(busqueda, filtro, orden); + + for (int i = 0; i < ret.size(); i++) { + + if (ret.get(i) instanceof DtVideo) { + DtVideo vid = (DtVideo) ret.get(i); + if (vid.getPrivacidad() == Privacidad.PRIVADO) { + try { + // Si el usuarioActual es null, o no posee un video con ese ID, se quita el elemento de la lista + this.usuarioActual.obtenerVideo(vid.getId()); + } catch (Exception e) { + ret.remove(i); + i--; + } + } + } else if (ret.get(i) instanceof DtListaDeReproduccion) { + DtListaDeReproduccion list = (DtListaDeReproduccion) ret.get(i); + if (list.getPrivacidad() == Privacidad.PRIVADO) { + if (list.getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { + ret.remove(i); + i--; + } else { + try { + // Si el usuarioActual es null, o no posee una lista con ese ID, se quita el elemento de la lista + this.usuarioActual.obtenerListaDeReproduccion(list.getId()); + } catch (Exception e) { + ret.remove(i); + i--; + } + } + } + } else if (ret.get(i) instanceof DtCanal) { + DtCanal canal = (DtCanal) ret.get(i); + if (canal.getPrivacidad() == Privacidad.PRIVADO) { // Si el canal es privado... + if (sesionIniciada()) { // Si hay una sesion iniciada + if (this.usuarioActual.obtenerCanal().getId() != canal.getId()) { // si el canal no es el propio, se remueve + ret.remove(i); + i--; + } + // si no entro al if, el canal esprivado pero es propio, entonces no se quita + } else { // Si no hay una sesion iniciada, se quita el canal + ret.remove(i); + i--; + } + } + } + } + return ret; + } + + @Override + public ArrayList<Object> buscar(String categoria) { + //Cambiar la linea de abajo cuando se implemente la funcion de juan + // hecho + ArrayList<Object> ret = new BusquedaEnBDD().buscarPorCategoria(categoria); + + for (int i = 0; i < ret.size(); i++) { + + if (ret.get(i) instanceof DtVideo) { + DtVideo vid = (DtVideo) ret.get(i); + if (vid.getPrivacidad() == Privacidad.PRIVADO) { + try { + // Si el usuarioActual es null, o no posee un video con ese ID, se quita el elemento de la lista + this.usuarioActual.obtenerVideo(vid.getId()); + } catch (Exception e) { + ret.remove(i); + i--; + } + } + } else if (ret.get(i) instanceof DtListaDeReproduccion) { + DtListaDeReproduccion list = (DtListaDeReproduccion) ret.get(i); + if (list.getPrivacidad() == Privacidad.PRIVADO) { + if (list.getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { + ret.remove(i); + i--; + } else { + try { + // Si el usuarioActual es null, o no posee una lista con ese ID, se quita el elemento de la lista + this.usuarioActual.obtenerListaDeReproduccion(list.getId()); + } catch (Exception e) { + ret.remove(i); + i--; + } + } + } + } + } + return ret; + } + + @Override + public void cerrarSesion() { + if(usuarioActual == null){ + throw new RuntimeException("No puedes cerrar sesión sin haberla iniciado"); + } + usuarioActual = null; + } + + + @Override + public boolean elUsuarioSeleccionadoEsElUsuarioActual(){ + if (usuarioActual == null || usuarioSeleccionado == null){ + return false; + } + return usuarioActual.getNickname().equals(usuarioSeleccionado.getNickname()); + } + + @Override + public boolean existeEmail(String email) { + if (email.equals("")){ + return false; + } + Map<String, Usuario> Usuarios = obtenerUsuarios(); + + for (Map.Entry<String, Usuario> u : Usuarios.entrySet()) { + if (u.getValue().getCorreo().equals(email)) { + return true; + } + } + + for (Usuario u : new UsuarioJpaController().findUsuarioEliminadoEntities()) { + if (u.getCorreo().equals(email)) { + return true; + } + } + return false; + } + + @Override + public boolean existeNickname(String nickname) { + if (nickname.equals("")){ + return false; + } + Map<String, Usuario> Usuarios = obtenerUsuarios(); + if (Usuarios.containsKey(nickname)) { + return true; + } + + for (Usuario u : new UsuarioJpaController().findUsuarioEliminadoEntities()) { + if (u.getNickname().equals(nickname)) { + return true; + } + } + return false; + } + + @Override + public boolean iniciarSesionUsuario(String nickOEmail, String contrasenia) { + if (usuarioActual != null){ + throw new RuntimeException("Ya hay un usuario con la sesión iniciada"); + } + Map<String, Usuario> usuarios = obtenerUsuarios(); + boolean usuarioEncontrado = false; + // Intenta obtener al usuario por nickname + usuarioActual = usuarios.get(nickOEmail); + if (usuarioActual == null){ // si NO lo encuentra por nickname + // Recorre todos los usuarios buscandolo por su correo + for (Map.Entry<String, Usuario> u : usuarios.entrySet()) { + // Si encuentra al usuario con ese correo + if (u.getValue().getCorreo().equals(nickOEmail)){ + usuarioActual = u.getValue(); + usuarioEncontrado = true; + break; + } + } + }else{ // si lo encuentra por nickname + usuarioEncontrado = true; + } + + if (usuarioEncontrado){ + if (usuarioActual.validarContrasenia(contrasenia)){ + return true; + }else{ + usuarioActual = null; + } + } + return false; + } + + @Override + public void liberarMemoriaListaDeReproduccion(){ + idListaSeleccionada = 0; + } + + @Override + public void liberarMemoriaUsuario(){ + usuarioSeleccionado = null; + } + + @Override + public void liberarMemoriaVideo(){ + idVideoSeleccionado = 0; + } + + @Override + public ArrayList<String> listarCategorias() { + Map<String, Categoria> categorias = obtenerCategorias(); + ArrayList<String> ret = new ArrayList<>(); + + for (Map.Entry<String, Categoria> entry : categorias.entrySet()) { + ret.add(entry.getKey()); + } + return ret; + } + + @Override + public ArrayList<DtComentario> listarComentariosDeVideo() { + if (this.usuarioSeleccionado == null) { + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + return usuarioSeleccionado.listarComentariosDeVideo(idVideoSeleccionado); + } + + @Override + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeUsuario(boolean incluirListasPorDefecto) { + if (this.usuarioSeleccionado == null) { + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + + ArrayList<DtListaDeReproduccion> ret = usuarioSeleccionado.listarListasDeReproduccionDeCanal(false); + + if (elUsuarioSeleccionadoEsElUsuarioActual()) { + // Se incluyen las privadas pero se quitan las POR_DEFECTO segun el parametro recibido + if (incluirListasPorDefecto) { + // se retorna todo + return ret; + } else { + // Se quitan las listas POR_DEFECTO + for (int i = 0; i < ret.size(); i++) { + if (ret.get(i).getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { + ret.remove(i); + i--; + } + } + return ret; + } + } else { + // si no se ha iniciado sesion, o si se inicio sesion pero el usuarioSeleccionado no es el usuarioActual + // Solo se incluyen las listas Publicas, osea que se quitan todas las Privadas + for (int i = 0; i < ret.size(); i++) { + if (ret.get(i).getPrivacidad() == Privacidad.PRIVADO) { + ret.remove(i); + i--; + } + } + return ret; + } + } + + @Override + public ArrayList<DtUsuario> listarUsuarioSeguidores() { + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + return usuarioSeleccionado.listarUsuariosSeguidores(); + } + + @Override + public ArrayList<DtUsuario> listarUsuarioSeguidos() { + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + return usuarioSeleccionado.listarUsuariosSeguidos(); + } + + @Override + public ArrayList<DtUsuario> listarUsuarios() { + ArrayList<DtUsuario> ret = new ArrayList<>(); + for (Map.Entry<String, Usuario> usuario : obtenerUsuarios().entrySet()) { + ret.add(usuario.getValue().getDT()); + } + return ret; + } + + @Override + public ArrayList<DtVideo> listarVideosDeListaDeReproduccion() { + if (this.usuarioSeleccionado == null) { + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + ArrayList<DtVideo> ret = this.usuarioSeleccionado.listarVideosDeListaDeReproduccion(idListaSeleccionada); + if (elUsuarioSeleccionadoEsElUsuarioActual()) { + // incluye los videos privados si y solo si son del usuario actual + // dicho de otra manera: quita los videos privados que no son del usuarioActual + for (int i = 0; i < ret.size(); i++) { + if (ret.get(i).getPrivacidad() == Privacidad.PRIVADO) { + try { + this.usuarioActual.obtenerVideo(ret.get(i).getId()); + } catch (Exception e) { + ret.remove(i); + i--; + } + } + } + return ret; + } else { + // Se devuelven solo los videos Publicos + for (int i = 0; i < ret.size(); i++) { + if (ret.get(i).getPrivacidad() == Privacidad.PRIVADO) { + ret.remove(i); + i--; + } + } + return ret; + } + } + + @Override + public ArrayList<DtVideo> listarVideosDeUsuario() { + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + + if(elUsuarioSeleccionadoEsElUsuarioActual()){ + // se incluyen todos los videos + return usuarioSeleccionado.listarVideosDeCanal(); + }else{ + // Se quitan los videos privados + ArrayList<DtVideo> ret = this.usuarioSeleccionado.listarVideosDeCanal(); + for (int i = 0 ; i < ret.size(); i++) { + if(ret.get(i).getPrivacidad() == Privacidad.PRIVADO){ + ret.remove(i); + i--; + } + } + return ret; + } + } + + @Override + public void modificarListaDeReproduccion(DtListaDeReproduccion lista) { + /** + * Se modifican los datos de la lista idListaSeleccionada + */ + if (this.usuarioActual == null){ + throw new RuntimeException("No se ha iniciado sesión"); + } + if (idListaSeleccionada == 0){ + throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionado"); + } + if (lista == null){ + throw new RuntimeException("El DataType recibido es null"); + } + if (!this.obtenerCategorias().containsKey(lista.getCategoria())) { + throw new RuntimeException("La categoria no existe"); + } + // no confio en que el DataType recibido venga con el id del video correcto, + // asi que creo otro y con el idVideoSeleccionado por las dudas + DtListaDeReproduccion dtl = new DtListaDeReproduccion( + idListaSeleccionada, + lista.getNombre(), + lista.getPrivacidad(), + lista.getTipo(), + lista.getCategoria()); + usuarioActual.modificarListaDeReproduccionDeCanal(dtl); + } + + @Override + public void modificarUsuarioYCanal(DtUsuario usr, DtCanal canal) { + if (usuarioActual == null) { + throw new RuntimeException("No se a iniciado la sesión"); + } + if (usr == null) { + throw new RuntimeException("Todos los datos del Usuario no pueden ser vacios"); + } + if (canal == null) { + throw new RuntimeException("Todos los datos del Canal no pueden ser vacios"); + } + usuarioActual.modificar(usr, canal); + + try { + new UsuarioJpaController().edit(usuarioActual); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + @Override + public void modificarVideo(DtVideo video) { + if (usuarioActual == null) { + throw new RuntimeException("No se a iniciado la sesión"); + } + if (video == null) { + throw new RuntimeException("Todos los datos del video no pueden ser vacios"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + if (!this.obtenerCategorias().containsKey(video.getCategoria())) { + throw new RuntimeException("La categoria no existe"); + } + + DtVideo dtv = new DtVideo( + idVideoSeleccionado, + video.getNombre(), + video.getDescripcion(), + video.getDuracion(), + video.getFechaPublicacion(), + video.getUrlVideoOriginal(), + video.getPrivacidad(), + video.getCategoria(), + 0, 0); + usuarioActual.modificarVideoDeCanal(dtv); + } + + @Override + public DtCanal obtenerCanalDeUsuario() { + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + return usuarioSeleccionado.obtenerCanal(); + } + + @Override + public DtUsuario obtenerPropietarioDeVideo(int idVideo) { + // Esto es un parche, pero de los que nunca se despegan... + // A tiempos desesperados, medidas desesperadas + for (Map.Entry<String, Usuario> u : this.obtenerUsuarios().entrySet()){ + try { + u.getValue().obtenerVideo(idVideo); + return u.getValue().getDT(); + } catch (Exception e) { + // a seguir buscando + } + } + throw new RuntimeException("El iID de video no crresponde a ningun usuario"); + } + + @Override + public DtUsuario obtenerPropietarioDeListaDeReproduccion(int idLista) { + // Esto es un parche, pero de los que nunca se despegan... + // A tiempos desesperados, medidas desesperadas + for (Map.Entry<String, Usuario> u : this.obtenerUsuarios().entrySet()){ + try { + u.getValue().obtenerListaDeReproduccion(idLista); + return u.getValue().getDT(); + } catch (Exception e) { + // a seguir buscando + } + } + throw new RuntimeException("El iID de video no crresponde a ningun usuario"); + } + + @Override + public DtValoracion obtenerValoracionDada() { + if (usuarioActual == null) { + throw new RuntimeException("No se a iniciado la sesión"); + } + if(usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + return usuarioSeleccionado.obtenerValoracion(idVideoSeleccionado, usuarioActual.getNickname()); + } + + @Override + public ArrayList<DtValoracion> obtenerValoracionesDeVideo() { + if(usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + return usuarioSeleccionado.listarValoracionesDeVideo(idVideoSeleccionado); + } + + @Override + public void quitarVideoDeListaDeReproduccion(int idVideo) { + if(usuarioActual == null){ + throw new RuntimeException("No se a iniciado la sesión"); + } + if (idListaSeleccionada == 0){ + throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionada"); + } + usuarioActual.quitarVideoDeListaDeReproduccion(idListaSeleccionada,idVideo); + + } + + @Override + public void seguirUsuario() { + if (this.usuarioActual == null){ + throw new RuntimeException("No se ha iniciado sesión"); + } + if (this.usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + usuarioActual.agregarOQuitarSeguido(usuarioSeleccionado); + try { + new UsuarioJpaController().edit(usuarioSeleccionado); + new UsuarioJpaController().edit(usuarioActual); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + + @Override + public DtUsuario seleccionarUsuario(String nickname) { + usuarioSeleccionado = obtenerUsuarios().get(nickname); + if (usuarioSeleccionado == null){ + throw new RuntimeException("No se encontro ningun usuario con ese nickname"); + } + return usuarioSeleccionado.getDT(); + } + + @Override + public DtListaDeReproduccion seleccionarListaDeReproduccion(int idLista) { + if (this.usuarioSeleccionado == null){ + String nick = this.obtenerPropietarioDeListaDeReproduccion(idLista).getNickname(); + this.seleccionarUsuario(nick); + } + DtListaDeReproduccion ret = usuarioSeleccionado.obtenerListaDeReproduccion(idLista); + idListaSeleccionada = idLista; + return ret; + } + + @Override + public DtVideo seleccionarVideo(int idVideo) { + if (this.usuarioSeleccionado == null){ + String nick = this.obtenerPropietarioDeVideo(idVideo).getNickname(); + this.seleccionarUsuario(nick); + } + DtVideo ret = usuarioSeleccionado.obtenerVideoDeCanal(idVideo); + idVideoSeleccionado = idVideo; + return ret; + } + + @Override + public boolean sesionIniciada(){ + return (usuarioActual != null); + } + + @Override + public boolean validarNuevaListaParticular(String nombre) { + if (this.usuarioActual == null){ + throw new RuntimeException("No se ha iniciado sesión"); + } + if (obtenerListasPorDefecto().containsKey(nombre)) { + return false; + } + if (idListaSeleccionada != 0){ + if (usuarioActual.obtenerListaDeReproduccion(idListaSeleccionada).getNombre().equals(nombre)){ + return true; + } + } + return usuarioActual.validarListaParticular(nombre); + } + + @Override + public boolean validarNuevoVideo(String nombre) { + if (this.usuarioActual == null){ + throw new RuntimeException("No se ha iniciado sesión"); + } + if (idVideoSeleccionado != 0){ + if (usuarioActual.obtenerVideo(idVideoSeleccionado).getNombre().equals(nombre)){ + return true; + } + } + return usuarioActual.validarListaParticular(nombre); + } + + @Override + public void valorarVideo(DtValoracion val) { + if (this.usuarioActual == null){ + throw new RuntimeException("No se ha iniciado sesión"); + } + if (usuarioSeleccionado == null){ + throw new RuntimeException("El sistema no tiene un usuario seleccionado"); + } + if (idVideoSeleccionado == 0){ + throw new RuntimeException("El sistema no tiene un video seleccionado"); + } + if (val == null){ + usuarioSeleccionado.quitarValoracion(idVideoSeleccionado, usuarioActual.getNickname()); + }else{ + usuarioSeleccionado.agregarModificarValoracionDeVideo(idVideoSeleccionado, val, usuarioActual); + } + } + +} diff --git a/UyTube_logica/src/Logica/DataType/DtCanal.java b/UyTube_logica/src/Logica/DataType/DtCanal.java new file mode 100644 index 0000000000000000000000000000000000000000..40408a02ecd46a0ee0a0b67219f5a7e60ea19773 --- /dev/null +++ b/UyTube_logica/src/Logica/DataType/DtCanal.java @@ -0,0 +1,40 @@ +package Logica.DataType; + +import Logica.Enumerados.Privacidad; + +public class DtCanal { + private int id; + private String nombre; + private String descripcion; + private Privacidad privacidad; + + public DtCanal(int id, String nombre, String descripcion,Privacidad privacidad) { + this.id = id; + this.nombre = nombre; + this.descripcion = descripcion; + this.privacidad = privacidad; + } + + public int getId() { + return id; + } + + public String getNombre() { + return nombre; + } + + public String getDescripcion() { + return descripcion; + } + + public Privacidad getPrivacidad() { + return privacidad; + } + + @Override + public String toString() { + return "DtCanal{" + "id=" + id + ", nombre=" + nombre + ", descripcion=" + descripcion + ", privacidad=" + privacidad + '}'; + } + + +} diff --git a/UyTube_logica/src/Logica/DataType/DtCategoria.java b/UyTube_logica/src/Logica/DataType/DtCategoria.java new file mode 100644 index 0000000000000000000000000000000000000000..21b7c92839262def00e043456c7d2856fac4fdf7 --- /dev/null +++ b/UyTube_logica/src/Logica/DataType/DtCategoria.java @@ -0,0 +1,19 @@ +package Logica.DataType; + +public class DtCategoria { + private String nombre; + + public DtCategoria(String nombre) { + this.nombre = nombre; + } + + public String getNombre() { + return nombre; + } + + @Override + public String toString() { + return "DtCategoria{" + "nombre=" + nombre + '}'; + } + +} diff --git a/UyTube_logica/src/Logica/DataType/DtComentario.java b/UyTube_logica/src/Logica/DataType/DtComentario.java new file mode 100644 index 0000000000000000000000000000000000000000..8df8fd39ffe3aa7578c966f6346c45b259eca1b0 --- /dev/null +++ b/UyTube_logica/src/Logica/DataType/DtComentario.java @@ -0,0 +1,46 @@ +package Logica.DataType; + +import java.sql.Date; + +public class DtComentario { + private int id; + private String nickname; + private Date fecha; + private String texto; + private int nivelSubComentario; + + public DtComentario(int id, String nickname, Date fecha, String texto, int nivelSubComentario) { + this.id = id; + this.nickname = nickname; + this.fecha = fecha; + this.texto = texto; + this.nivelSubComentario = nivelSubComentario; + } + + public int getId() { + return id; + } + + public String getNickname() { + return nickname; + } + + public Date getFecha() { + return fecha; + } + + public String getTexto() { + return texto; + } + + public int getNivelSubComentario() { + return nivelSubComentario; + } + + @Override + public String toString() { + return "DtComentario{" + "id=" + id + ", nickname=" + nickname + ", fecha=" + fecha + ", texto=" + texto + ", nivelSubComentario=" + nivelSubComentario + '}'; + } + + +} diff --git a/UyTube_logica/src/Logica/DataType/DtListaDeReproduccion.java b/UyTube_logica/src/Logica/DataType/DtListaDeReproduccion.java new file mode 100644 index 0000000000000000000000000000000000000000..d617e63e588c6ad5491b77a093c0e7b5217d60f4 --- /dev/null +++ b/UyTube_logica/src/Logica/DataType/DtListaDeReproduccion.java @@ -0,0 +1,56 @@ +package Logica.DataType; + +import Logica.Enumerados.Privacidad; +import Logica.Enumerados.TipoListaDeReproduccion; + +public class DtListaDeReproduccion { + private int id; + private String nombre; + private Privacidad privacidad; + private TipoListaDeReproduccion tipo; + private String categoria; + private String nombreDuenio; + + public DtListaDeReproduccion(int id, String nombre, Privacidad privacidad, TipoListaDeReproduccion tipo, String categoria) { + this.id = id; + this.nombre = nombre; + this.privacidad = privacidad; + this.tipo = tipo; + this.categoria = categoria; + } + + public DtListaDeReproduccion(int id, String nombre, Privacidad privacidad, TipoListaDeReproduccion tipo, String categoria, String nombreDuenio) { + this.id = id; + this.nombre = nombre; + this.privacidad = privacidad; + this.tipo = tipo; + this.categoria = categoria; + this.nombreDuenio = nombreDuenio; + } + + public int getId() { + return id; + } + + public String getNombre() { + return nombre; + } + + public Privacidad getPrivacidad() { + return privacidad; + } + + public TipoListaDeReproduccion getTipo() { + return tipo; + } + + public String getCategoria() { + return categoria; + } + + @Override + public String toString() { + return "DtListaDeReproduccion{" + "id=" + id + ", nombre=" + nombre + ", privacidad=" + privacidad + ", tipo=" + tipo + ", categoria=" + categoria + '}'; + } + +} diff --git a/UyTube_logica/src/Logica/DataType/DtPersona.java b/UyTube_logica/src/Logica/DataType/DtPersona.java new file mode 100644 index 0000000000000000000000000000000000000000..11ec6aa8588e5969b3788e4fcdf7ab998be88b2a --- /dev/null +++ b/UyTube_logica/src/Logica/DataType/DtPersona.java @@ -0,0 +1,33 @@ +package Logica.DataType; + +public abstract class DtPersona { + private String nombre; + private String apellido; + private String contrasenia; + + public DtPersona(String nombre, String apellido, String contrasenia) { + // esta clase es abstracta, eso se define arriba al hacer 'public abstract class...' + // aca se setean los valores recibidos + this.nombre = nombre; + this.apellido = apellido; + this.contrasenia = contrasenia; + } + + public String getNombre() { + return nombre; + } + + public String getApellido() { + return apellido; + } + + public String getContrasenia() { + return contrasenia; + } + + @Override + public String toString() { + return "DtPersona{" + "nombre=" + nombre + ", apellido=" + apellido + ", contrasenia=" + contrasenia + '}'; + } + +} diff --git a/UyTube_logica/src/Logica/DataType/DtUsuario.java b/UyTube_logica/src/Logica/DataType/DtUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..10f8db084d1efd87171278e46b34a50b74343795 --- /dev/null +++ b/UyTube_logica/src/Logica/DataType/DtUsuario.java @@ -0,0 +1,68 @@ +package Logica.DataType; + +import java.sql.Date; + +public class DtUsuario extends DtPersona{ + private String nickname; + private String correo; + private Date fechaNacimiento; + private Date fechaEliminado; + private String imagen; + private int cantSeguidores; + + public DtUsuario(String nickname, String contrasenia, String nombre, String apellido, String correo, Date fechaNacimiento, String imagen, int cantSeguidores) { + // Antes de leer esto, lee el constructor de DtPersona... + // para setear los atributos de la clase padre, se utiliza super(..) y + // sele asan los atributos que recibe el constructor de la clase padre + super(nombre, apellido, contrasenia); + // y ahora se setean los atributos propios + this.nickname = nickname; + this.correo = correo; + this.fechaNacimiento = fechaNacimiento; + this.imagen = imagen; + this.cantSeguidores = cantSeguidores; + } + + public DtUsuario(String nickname, String contrasenia, String nombre, String apellido, String correo, Date fechaNacimiento, Date fechaEliminado, String imagen, int cantSeguidores) { + // Antes de leer esto, lee el constructor de DtPersona... + // para setear los atributos de la clase padre, se utiliza super(..) y + // sele asan los atributos que recibe el constructor de la clase padre + super(nombre, apellido, contrasenia); + // y ahora se setean los atributos propios + this.nickname = nickname; + this.correo = correo; + this.fechaNacimiento = fechaNacimiento; + this.fechaEliminado = fechaEliminado; + this.imagen = imagen; + this.cantSeguidores = cantSeguidores; + } + + public String getNickname() { + return nickname; + } + + public String getCorreo() { + return correo; + } + + public Date getFechaNacimiento() { + return fechaNacimiento; + } + + public Date getFechaEliminado() { + return fechaEliminado; + } + + public String getImagen() { + return imagen; + } + + public int getCantSeguidores() { + return cantSeguidores; + } + + @Override + public String toString() { + return "DtUsuario{" + super.toString() + ", nickname=" + nickname + ", correo=" + correo + ", fechaNacimiento=" + fechaNacimiento + ", fechaEliminado=" + fechaEliminado + ", imagen=" + imagen + ", cantSeguidores=" + cantSeguidores + '}'; + } +} diff --git a/UyTube_logica/src/Logica/DataType/DtValoracion.java b/UyTube_logica/src/Logica/DataType/DtValoracion.java new file mode 100644 index 0000000000000000000000000000000000000000..bb167e88e9703dafa2773e0d16b5cec676e460de --- /dev/null +++ b/UyTube_logica/src/Logica/DataType/DtValoracion.java @@ -0,0 +1,25 @@ +package Logica.DataType; + +import Logica.Enumerados.TipoValoracion; + +public class DtValoracion { + private TipoValoracion val; + private String nickname; + + public DtValoracion(TipoValoracion val, String nickname) { + this.val = val; + this.nickname = nickname; + } + public String getNickname() { + return nickname; + } + public TipoValoracion getVal() { + return val; + } + + @Override + public String toString() { + return "DtValoracion{" + "val=" + val + ", nickname=" + nickname + '}'; + } + +} diff --git a/UyTube_logica/src/Logica/DataType/DtVideo.java b/UyTube_logica/src/Logica/DataType/DtVideo.java new file mode 100644 index 0000000000000000000000000000000000000000..e7d99e7a706e376c305ba1c55232674f9cd30b39 --- /dev/null +++ b/UyTube_logica/src/Logica/DataType/DtVideo.java @@ -0,0 +1,92 @@ +package Logica.DataType; + +import java.sql.Time; +import java.sql.Date; +import Logica.Enumerados.Privacidad; + +public class DtVideo { + private int id; + private String nombre; + private String descripcion; + private Time duracion; + private Date fechaPublicacion; + private String urlVideoOriginal; + private Privacidad privacidad; + private String categoria; + private int cantLikes; + private int cantDisLikes; + private String nombreDuenio; + + public DtVideo(int id, String nombre, String descripcion, Time duracion, Date fechaPublicacion, String urlVideoOriginal, Privacidad privacidad, String categoria, int cantLikes, int cantDisLikes) { + this.id = id; + this.nombre = nombre; + this.descripcion = descripcion; + this.duracion = duracion; + this.fechaPublicacion = fechaPublicacion; + this.urlVideoOriginal = urlVideoOriginal; + this.privacidad = privacidad; + this.categoria = categoria; + this.cantLikes = cantLikes; + this.cantDisLikes = cantDisLikes; + } + + public DtVideo(int id, String nombre, String descripcion, Time duracion, Date fechaPublicacion, String urlVideoOriginal, Privacidad privacidad, String categoria, int cantLikes, int cantDisLikes, String nombreDuenio) { + this.id = id; + this.nombre = nombre; + this.descripcion = descripcion; + this.duracion = duracion; + this.fechaPublicacion = fechaPublicacion; + this.urlVideoOriginal = urlVideoOriginal; + this.privacidad = privacidad; + this.categoria = categoria; + this.cantLikes = cantLikes; + this.cantDisLikes = cantDisLikes; + this.nombreDuenio = nombreDuenio; + } + + public int getId() { + return id; + } + + public String getNombre() { + return nombre; + } + + public String getDescripcion() { + return descripcion; + } + + public Time getDuracion() { + return duracion; + } + + public Date getFechaPublicacion() { + return fechaPublicacion; + } + + public String getUrlVideoOriginal() { + return urlVideoOriginal; + } + + public Privacidad getPrivacidad() { + return privacidad; + } + + public String getCategoria() { + return categoria; + } + + public int getCantLikes() { + return cantLikes; + } + + public int getCantDisLikes() { + return cantDisLikes; + } + + @Override + public String toString() { + return "DtVideo{" + "id=" + id + ", nombre=" + nombre + ", descripcion=" + descripcion + ", duracion=" + duracion + ", fechaPublicacion=" + fechaPublicacion + ", urlVideoOriginal=" + urlVideoOriginal + ", privacidad=" + privacidad + ", categoria=" + categoria + ", cantLikes=" + cantLikes + ", cantDisLikes=" + cantDisLikes + '}'; + } + +} diff --git a/UyTube_logica/src/Logica/DatosDePrueba.java b/UyTube_logica/src/Logica/DatosDePrueba.java new file mode 100644 index 0000000000000000000000000000000000000000..a5b672710f670331fb6baef631962bdd585e4843 --- /dev/null +++ b/UyTube_logica/src/Logica/DatosDePrueba.java @@ -0,0 +1,54 @@ +package Logica; + +import JPAControllerClasses.BusquedaEnBDD; +import Logica.Clases.Canal; +import Logica.Clases.ListaDeReproduccion; +import Logica.Clases.Video; +import Logica.DataType.DtCanal; +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtVideo; +import Logica.Enumerados.Filtrado; +import Logica.Enumerados.Ordenacion; +import Logica.Interfaces.IAdmin; +import Logica.Interfaces.IUsuario; +import java.util.ArrayList; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +public class DatosDePrueba { + private static IAdmin adminSys = null; + private static IUsuario usuSys = null; + + public static void main(String[] args) { + probar(); + System.exit(0); + } + + private static void probar(){ + Fabrica f = Fabrica.getInstancia(); + usuSys = f.getIUsuario(); + //CUsuario su = CUsuario.getInstancia(); + try { + + } catch (Exception e) { + System.out.println("//////////////////////////"); + System.out.println(e.getMessage()); + System.out.println("//////////////////////////"); + } + } + /* + private static void mostrarLista(ArrayList<Object> lst){ + // Prueba de búsqueda por categorÃa + for (Object o : lst){ + System.out.println("> " + o.toString()); + } + } + */ + private static void mostrarLista(Object lst){ + // Prueba de búsqueda por categorÃa + for (Object o : (ArrayList<Object>)lst){ + System.out.println("> " + o.toString()); + } + } +} diff --git a/UyTube_logica/src/Logica/Enumerados/Filtrado.java b/UyTube_logica/src/Logica/Enumerados/Filtrado.java new file mode 100644 index 0000000000000000000000000000000000000000..dd06c818f98badd67271d3bd71fefd3eb5a7dccb --- /dev/null +++ b/UyTube_logica/src/Logica/Enumerados/Filtrado.java @@ -0,0 +1,5 @@ +package Logica.Enumerados; + +public enum Filtrado { + CANALES, VIDEOS, LISTAS_DE_REPRODUCCION, TODO +} diff --git a/UyTube_logica/src/Logica/Enumerados/Ordenacion.java b/UyTube_logica/src/Logica/Enumerados/Ordenacion.java new file mode 100644 index 0000000000000000000000000000000000000000..0b06e2d1460137e6fa26e5640b234fb7ffae971e --- /dev/null +++ b/UyTube_logica/src/Logica/Enumerados/Ordenacion.java @@ -0,0 +1,5 @@ +package Logica.Enumerados; + +public enum Ordenacion { + ALFABETICA_ASCENDENTE, FECHA_DESCENDENTE +} diff --git a/UyTube_logica/src/Logica/Enumerados/Privacidad.java b/UyTube_logica/src/Logica/Enumerados/Privacidad.java new file mode 100644 index 0000000000000000000000000000000000000000..0c63d6170d85f6fb855421a86a53d43ba48ff4e7 --- /dev/null +++ b/UyTube_logica/src/Logica/Enumerados/Privacidad.java @@ -0,0 +1,5 @@ +package Logica.Enumerados; + +public enum Privacidad { + PUBLICO, PRIVADO +} diff --git a/UyTube_logica/src/Logica/Enumerados/TipoListaDeReproduccion.java b/UyTube_logica/src/Logica/Enumerados/TipoListaDeReproduccion.java new file mode 100644 index 0000000000000000000000000000000000000000..d5b5ca1a06b7afca03fd4e69fcddfe86d481feeb --- /dev/null +++ b/UyTube_logica/src/Logica/Enumerados/TipoListaDeReproduccion.java @@ -0,0 +1,5 @@ +package Logica.Enumerados; + +public enum TipoListaDeReproduccion { + POR_DEFECTO, PARTICULAR +} diff --git a/UyTube_logica/src/Logica/Enumerados/TipoValoracion.java b/UyTube_logica/src/Logica/Enumerados/TipoValoracion.java new file mode 100644 index 0000000000000000000000000000000000000000..7334f06676973b907ac36b783da8cfcb6dd6d442 --- /dev/null +++ b/UyTube_logica/src/Logica/Enumerados/TipoValoracion.java @@ -0,0 +1,5 @@ +package Logica.Enumerados; + +public enum TipoValoracion { + LIKE, DISLIKE +} diff --git a/UyTube_logica/src/Logica/Fabrica.java b/UyTube_logica/src/Logica/Fabrica.java new file mode 100644 index 0000000000000000000000000000000000000000..2405684b805827ab1ced98afd8aaaaf5b30a44ce --- /dev/null +++ b/UyTube_logica/src/Logica/Fabrica.java @@ -0,0 +1,33 @@ +package Logica; + +import Logica.Controladores.CAdmin; +import Logica.Controladores.CUsuario; +import Logica.Interfaces.IAdmin; +import Logica.Interfaces.IUsuario; + + +/* Clase Singleton */ +public class Fabrica { + private static Fabrica instancia = null; + + private Fabrica(){ + + } + + public static Fabrica getInstancia(){ + if( instancia == null ){ + instancia = new Fabrica(); + } + return instancia; + } + + /* Crea una unicia instancia del controlador CAdmin */ + public IAdmin getIAdmin(){ + return CAdmin.getInstancia(); + } + + /* Crea una unicia instancia del controlador CUsuario */ + public IUsuario getIUsuario(){ + return CUsuario.getInstancia(); + } +} diff --git a/UyTube_logica/src/Logica/Interfaces/IAdmin.java b/UyTube_logica/src/Logica/Interfaces/IAdmin.java new file mode 100644 index 0000000000000000000000000000000000000000..11e3c771c7026bd29dbf6fa62a36f387e7473ef9 --- /dev/null +++ b/UyTube_logica/src/Logica/Interfaces/IAdmin.java @@ -0,0 +1,361 @@ +package Logica.Interfaces; + +import Logica.DataType.*; +import java.util.ArrayList; + +public interface IAdmin { + + /** + * Agrega el video idVideoSeleccionado a la lista indicada + * + * @param idLista ID de la lista a la cual se agrega el video + */ + public void agregarVideoAListaDeReproduccion(int idLista); + + /** + * Crea la categoria con el nombre indicado + * + * @param categoria nombre de la categoria + */ + public void altaCategoria(String categoria); + + /** + * Comenta el video idVideoSeleccionado a nombre de usuarioActual + * + * @param dtCom Comentario a agregar + */ + public void altaComentario(DtComentario dtCom); + + /** + * Comenta el comentario con dicho ID a nombre de usuarioActual + * + * @param dtCom Comentario a agregar + * @param idComPadre ID del comentario a responder + */ + public void altaComentario(DtComentario dtCom, int idComPadre); + + /** + * Crea la lista de reproduccion para usuarioSeleccionado + * + * @param lista Lista particular a agregar + */ + public void altaListaDeReproduccionParticular(DtListaDeReproduccion lista); + + /** + * Crea la lista de reproduccion para todos los usuarios del sistema y la + * agrega listas por defecto (para que se creen al crear un usuario nuevo) + * + * @param lista Lista por defecto a agregar + */ + public void altaListaDeReproduccionPorDefecto(DtListaDeReproduccion lista); + + /** + * Crea un usuario y su canal a partir de los datos recibidos + * + * @param usr Datos del usuario a dar de alta + * @param canal Datos del canal del usuario + */ + public void altaUsuarioCanal(DtUsuario usr, DtCanal canal); + + /** + * Se ingresa la nueva valoracion dada por usuarioActual al video + * idVideoSeleccionado Si el usuario ya habia valorado, se actualiza la + * valoracion dada + * + * @param val Valoracion dada + */ + public void altaValoracion(DtValoracion val); + + /** + * Se crea un video nuevo en el canal de usuarioSeleccionado + * + * @param video Datos del video a dar de alta + */ + public void altaVideo(DtVideo video); + + /** + * Elimina el usuario actual seleccionado + */ + public void bajaUsuario(); + + /** + * Verifica si existe una categoria con el nombre recibido + * + * @param cat Nombre de la categoria a verificar + * @return true si la categoria ya existe + */ + public boolean existeCategoria(String cat); + + /** + * Verifica si existe un usuario con el mail recibido + * + * @param email Correo a verificar + * @return true si el correo ya esta en uso + */ + public boolean existeEmail(String email); + + /** + * Verifica si existe un usuario con el nickname recibido + * + * @param nickname Nickname a verificar + * @return true si el nickname ya esta en uso + */ + public boolean existeNickname(String nickname); + + /** + * Inicio de sesion para administradores + * + * @param id ID del administrador + * @param pass contraseña del administrador + * @return true si el ID existe y la contraseña es correcta + */ + public boolean iniciarSesionAdministrador(int id, String pass); + + /** + * Libera memoria de la lista de reproduccion seleccionada + */ + public void liberarMemoriaListaDeReproduccion(); + + /** + * Libera memoria del usuario seleccionado + */ + public void liberarMemoriaUsuario(); + + /** + * Libera memoria del usuario actual seleccionado + */ + public void liberarMemoriaUsuarioActual(); + + /** + * Libera memoria del video seleccionado + */ + public void liberarMemoriaVideo(); + + /** + * Devuelve todas las categorias existentes en el sistema + * + * @return Conjunto de nombres de categorÃas + */ + public ArrayList<String> listarCategorias(); + + /** + * Devuelve en forma ordenada (recursiva ) todos los comentarios de + * idVideoSeleccionado + * + * @return Conjunto de comentarios + */ + public ArrayList<DtComentario> listarComentariosDeVideo(); + + /** + * Devuelve todos las listas de reproduccion del sistema que pertenezcan a + * la categoria indicada + * + * @param cat Nombre de categorÃa + * @return Conjunto de listas de reproduccion + */ + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionEnCategoria(String cat); + + /** + * Devuelve todas las listas de reproduccion de usuarioSeleccionado o de + * usuarioActual segun el nickname indicado + * + * @param nickname Nickname del usuario seleccionado o del usuario actual + * @return Conjunto de listas de reproduccion + */ + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeUsuario(String nickname); + + /** + * Devuelve las listas de reproduccion particulares de usuarioSeleccionado + * + * @return Conjunto de listas de reproduccion + */ + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionParticularesDeUsuario(); + + /** + * Devuelve todos los usuarios que siguen a usuarioSeleccionado + * + * @return Conjunto de usuarios + */ + public ArrayList<DtUsuario> listarUsuarioSeguidores(); + + /** + * Devuelve todos los usuarios a quienes NO sigue usuarioSeleccionado + * + * @return Conjunto de usuarios + */ + public ArrayList<DtUsuario> listarUsuarioNoSeguidos(); + + /** + * Devuelve todos los usuarios a quienes sigue usuarioSeleccionado + * + * @return Conjunto de usuarios + */ + public ArrayList<DtUsuario> listarUsuarioSeguidos(); + + /** + * Devuelve todos los datos de todos los usuarios + * + * @return Conjunto de usuarios + */ + public ArrayList<DtUsuario> listarUsuarios(); + + /** + * Devuelve todos los datos de todos los usuarios eliminados + * + * @return Conjunto de usuarios + */ + public ArrayList<DtUsuario> listarUsuariosEliminados(); + + /** + * Devuelve todos los videos del sistema que pertenezcan a la categoria + * indicada + * + * @param cat Nombre de categorÃa + * @return Conjunto de videos + */ + public ArrayList<DtVideo> listarVideosEnCategoria(String cat); + + /** + * Devuelve todos los videos de usuarioSeleccionado + * + * @return Conjunto de videos + */ + public ArrayList<DtVideo> listarVideosDeUsuario(); + + /** + * Devuelve los videos de la lista de reproduccion idListaSeleccionada + * + * @return Conjunto de videos + */ + public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(); + + /** + * Se modifican los datos de la lista idListaSeleccionada + * + * @param lista Datos de la lista de reproduccion + */ + public void modificarListaDeReproduccion(DtListaDeReproduccion lista); + + /** + * Se modifican los datos de usuarioActual y su canal + * + * @param usr Datos del usuario + * @param canal Datos del canal + */ + public void modificarUsuarioYCanal(DtUsuario usr, DtCanal canal); + + /** + * Se modifican los datos del video idVideoSeleccionado + * + * @param video Datos del video + */ + public void modificarVideo(DtVideo video); + + /** + * Busca entre todos los usuarios al propietario del video con ese ID + * + * @param idVideo ID del video + * @return Datos del usuario + */ + public DtUsuario obtenerPropietarioDeVideo(int idVideo); + + /** + * Devuelve los datos del canal del usuario en memoria usuarioSeleccionado + * + * @return Datos del canal + */ + public DtCanal obtenerCanalDeUsuario(); + + /** + * Devuelve las valoraciones de idVideoSeleccionado + * + * @return Conjunto de valoraciones + */ + public ArrayList<DtValoracion> obtenerValoracionesDeVideo(); + + /** + * Devuelve la valoracion dada por usuarioActual al video + * idVideoSeleccionado + * + * @return Valoracion dada o null si no ha valorado + */ + public DtValoracion obtenerValoracionDada(); + + /** + * Quita el video idVideoSeleccionado de la lista idListaSeleccionada + * @param idVideo ID del video + */ + public void quitarVideoDeListaDeReproduccion(int idVideo); + + /** + * Quita el video idVideoSeleccionado de la lista idListaSeleccionada + * + * @param nickname Nickname del usuario + * @return Datos del usuario + */ + public DtUsuario seleccionarUsuario(String nickname); + + /** + * El sistema recuerda un link al usuario como usuarioActual Devuelve los + * datos de usuarioActual + * + * @param nickname Nickname del usuario + * @return Datos del usuario + */ + public DtUsuario seleccionarUsuarioActual(String nickname); + + /** + * El sistema recuerda un link al usuario eliminado como usuarioSeleccionado + * Devuelve los datos de usuarioActual + * + * @param nickname Nickname del usuario + * @return Datos del usuario + */ + public DtUsuario seleccionarUsuarioEliminado(String nickname); + + /** + * El sistema recuerda el ID del video como idVideoSeleccionado Devuelve los + * datos del video seleccionado + * + * @param idVideo ID del video + * @return Datos del video + */ + public DtVideo seleccionarVideo(int idVideo); + + /** + * El sistema recuerda el ID de la lista como idListaSeleccionada Devuelve + * los datos de la lista de reproduccion seleccionada perteneciente a + * usuarioSeleccionado + * + * @param idLista ID de la lista de reproduccion + * @return Datos de la lista de reproduccion + */ + public DtListaDeReproduccion seleccionarListaDeReproduccion(int idLista); + + /** + * El usuario usuarioActual comienza a seguir a usuarioSeleccionado En caso + * de que este ya lo este siguiendo, lo deja de seguir + */ + public void seguirUsuario(); + + /** + * Devuelve false si usuarioSeleccionado posee una lista de reproducion con + * ese nombre + * + * @param nombre Nombre de la lista de reproduccion + * @return true si el usuario no posee ya una lista de reproduccion con ese + * nombre + */ + public boolean validarNuevaListaParticular(String nombre); + + /** + * Devuelve false si existe algun usuario en el sistema que posea una lista + * de reproduccion con ese nombre + * + * @param nombre Nombre de la lista de reproduccion + * @return true si ningun usuario posee una lista con ese nombre, y ademas + * no existen listas por defecto con ese nombre + */ + public boolean validarNuevaListaPorDefecto(String nombre); + +} diff --git a/UyTube_logica/src/Logica/Interfaces/IUsuario.java b/UyTube_logica/src/Logica/Interfaces/IUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..e94a4890cd0f6967ead47bf3d409c278ad116e5e --- /dev/null +++ b/UyTube_logica/src/Logica/Interfaces/IUsuario.java @@ -0,0 +1,361 @@ +package Logica.Interfaces; + +import Logica.DataType.*; +import Logica.Enumerados.*; +import java.util.ArrayList; + +public interface IUsuario { + + /** + * Agrega el video idVideoSeleccionado que pertenece a usuarioSeleccionado, + * a la lista indicada perteneciente a usuarioActual + * + * @param idLista ID de la lista de reproduccon + */ + public void agregarVideoAListaDeReproduccion(int idLista); + + /** + * Comenta el video idVideoSeleccionado perteneciente a usuarioSeleccionado, + * a nombre de usuarioActual + * + * @param dtCom Comentario a agregar + */ + public void altaComentario(DtComentario dtCom); + + /** + * Comenta a nombre de usuarioActual, el comentario con el ID indicado, que + * pertenece al video idVideoSeleccionado, que pertenece a + * usuarioSeleccionado + * + * @param dtCom Comentario a agregar + * @param idComPadre ID del comentario a responder + */ + public void altaComentario(DtComentario dtCom, int idComPadre); + + /** + * Da de alta la lista de reproduccion particular para usuarioActual + * + * @param lista Lista particular a dar de alta + */ + public void altaListaDeReproduccionParticular(DtListaDeReproduccion lista); + + /** + * Da de alta un usuario y su canal a partir de los datos recibidos + * Luego de darlo de alta, el usuario queda con la sesión iniciada + * + * @param usr Datos del usuario a dar de alta + * @param canal Datos del canal del usuario + */ + public void altaUsuarioCanal(DtUsuario usr, DtCanal canal); + + /** + * Da de alta un video en el canal de usuarioActual + * + * @param video Datos del video a dar de alta + */ + public void altaVideo(DtVideo video); + + /** + * Da de baja al usuarioActual + * En el proceso se cierra la sesion + */ + public void bajaUsuario(); + + /** + * Busca contenido por coincidencia de texto en nombre o descripcion de los + * contenidos del sistema En el resultado se incluirán (si corresponde segun + * el filtrado) los videos privados del usuarioActual + * Si no se ha iniciado sesión, se muestran sólo los contenidos públicos + * + * @param busqueda Texto a buscar (si es vacÃo incluye todo el contenido) + * @param filtro Tipo de contenido en el cual se realizará la búsqueda + * @param orden Manera de ordenar el resultado de la búsqueda + * @return Resultado de la busqueda. Puede contener DtVideo, + * DtListaDeReproduccion y/o DtCanal. (para usar los elementos devueltos hay + * que castearlos) + */ + public ArrayList<Object> buscar(String busqueda, Filtrado filtro, Ordenacion orden); + + /** + * Busca contenido que pertenezcan a la categoria indicada El Resultado + * contendrá todos los contenidos publicos, y los contenidos privados del + * usuarioActual + * Si no se ha iniciado sesión, se muestran sólo los contenidos públicos + * + * @param categoria Nombre de la categoria a buscar + * @return Resultado de la busqueda. Puede contener DtVideo y + * DtListaDeReproduccion. (para usar los elementos devueltos hay que + * castearlos) + */ + public ArrayList<Object> buscar(String categoria); + + /** + * Cierra la sesión del usuarioActual (lo quita de memoria) + */ + public void cerrarSesion(); + + /** + * Como el nombre de la funcion lo indica, es para saber si el usuario que + * se ha seleccionado, es el usuario que tiene la inicion sesiada + * + * @return true si el usuario seleccionado es el usuario que inicio la + * sesion + */ + public boolean elUsuarioSeleccionadoEsElUsuarioActual(); + + /** + * Verifica si existe un usuario con el email indicado + * + * @param email Email a verificar + * @return true si el email ya esta en uso + */ + public boolean existeEmail(String email); + + /** + * Verifica si existe un usuario con el nickname indicado + * + * @param nickname Nickname a verificar + * @return true si el nickname ya esta en uso + */ + public boolean existeNickname(String nickname); + + /** + * Inicia la sesión del usuario. Si los datos son correctos se guarda al + * usuario como usuarioActual + * + * @param nickOEmail Nickname o email del usuario + * @param contrasenia Contraseña del usuario + * @return true si el usuario con el nickname o email existe y ademas la + * contrasenia es correcta + */ + public boolean iniciarSesionUsuario(String nickOEmail, String contrasenia); + + /** + * Libera memoria de la lista de reproduccion seleccionada + */ + public void liberarMemoriaListaDeReproduccion(); + + /** + * Libera memoria del usuario seleccionado + */ + public void liberarMemoriaUsuario(); + + /** + * Libera memoria del video seleccionado + */ + public void liberarMemoriaVideo(); + + /** + * Devuelve todas las categorias existentes en el sistema + * + * @return Conjunto de nombres de categorÃas + */ + public ArrayList<String> listarCategorias(); + + /** + * Devuelve en forma ordenada (recursiva) todos los comentarios de + * idVideoSeleccionado perteneciente a usuarioSeleccionado + * + * @return Conjunto de comentarios + */ + public ArrayList<DtComentario> listarComentariosDeVideo(); + + /** + * Devuelve las listas de reproduccion del usuarioSeleccionado Si el + * usuarioSeleccionado es el usuarioActual, y se incluyen las listas por + * defecto: devuelve todas las listas del usuarioSeleccionado. Si el + * usuarioSeleccionado es el usuarioActual, y NO se incluyen las listas por + * defecto: devuelve las listas particulares (privadas y publicas) del + * usuarioSeleccionado Si el usuarioSeleccionado NO ES el usuarioActual: + * devuelve solo las listas publicas + * + * @param incluirListasPorDefecto True si se desea incluir en el listado las + * listas por defecto + * @return Conjunto de listas de reproduccion + */ + public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeUsuario(boolean incluirListasPorDefecto); + + /** + * Devuelve todos los usuarios que siguen a usuarioSeleccionado + * + * @return Conjunto de usuarios + */ + public ArrayList<DtUsuario> listarUsuarioSeguidores(); + + /** + * Devuelve todos los usuarios a los que sigue usuarioSeleccionado + * + * @return Conjunto de usuarios + */ + public ArrayList<DtUsuario> listarUsuarioSeguidos(); + + /** + * Devuelve todos los datos de todos los usuarios del sistema + * + * @return Conjunto de usuarios + */ + public ArrayList<DtUsuario> listarUsuarios(); + + /** + * Lista los videos contenidos en la lista idListaSeleccionada perteneciente + * al usuarioSeleccionado Si la lista contiene video privado que no + * pertenezca a usuarioActual, estos no se incluiran en el resultado + * Si no se ha iniciado sesion solo lista los videos publicos + * + * @return Conjunto de videos + */ + public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(); + + /** + * Devuelve los videos públicos del usuarioSeleccionado Si el + * usuarioSeleccionado es el usuarioActual: Se incluirán los videos privados + * + * @return Conjunto de videos + */ + public ArrayList<DtVideo> listarVideosDeUsuario(); + + /** + * Se modifican los datos de la lista idListaSeleccionada que pertenece a + * usuarioActual + * + * @param lista Nuevos datos de la lista de reproduccion + */ + public void modificarListaDeReproduccion(DtListaDeReproduccion lista); + + /** + * Se modifican los datos de usuarioActual y su canal + * + * @param usr Nuevos datos del usuario + * @param canal Nuevos datos del canal + */ + public void modificarUsuarioYCanal(DtUsuario usr, DtCanal canal); + + /** + * Se modifican los datos del video idVideoSeleccionado que pertenece a + * usuarioActual + * + * @param video Nuevos datos del video + */ + public void modificarVideo(DtVideo video); + + /** + * Devuelve los datos del canal del usuarioSeleccionado + * + * @return Datos del canal + */ + public DtCanal obtenerCanalDeUsuario(); + + /** + * Busca entre todos los usuarios al propietario del video con el ID indicado + * + * @param idVideo ID del video + * @return Datos del usuario + */ + public DtUsuario obtenerPropietarioDeVideo(int idVideo); + + /** + * Busca entre todos los usuarios al propietario de la lista de reproduccion con el ID indicado + * + * @param idLista ID de la lista de reproduccion + * @return Datos del usuario + */ + public DtUsuario obtenerPropietarioDeListaDeReproduccion(int idLista); + + /** + * Devuelve la valoracion dada por usuarioActual al video + * idVideoSeleccionado perteneciente al usuarioSeleccionado + * + * @return Valoracion dada o null si no ha valorado + */ + public DtValoracion obtenerValoracionDada(); + + /** + * Devuelve las valoraciones de idVideoSeleccionado perteneciente a + * usuarioSeleccionado + * + * @return Conjunto de valoraciones + */ + public ArrayList<DtValoracion> obtenerValoracionesDeVideo(); + + /** + * Quita el video indicado de la lista idListaSeleccionada perteneciente al + * usuarioActual + * + * @param idVideo ID del video a quitar + */ + public void quitarVideoDeListaDeReproduccion(int idVideo); + + /** + * El usuarioActual comienza a seguir a usuarioSeleccionado En caso de que + * este ya lo esté siguiendo, lo deja de seguir + */ + public void seguirUsuario(); + + /** + * Selecciona un usuario del sistema El sistema recuerda el usuario como + * usuarioSeleccionado Devuelve los datos de usuarioSeleccionado + * + * @param nickname Nickname del usuario + * @return Datos del usuario + */ + public DtUsuario seleccionarUsuario(String nickname); + + /** + * Selecciona una lista de reproduccion del usuarioSeleccionado El sistema + * recuerda el ID de la lista como idListaSeleccionada. Si no hay un + * usuarioSeleccionado, el sistema busca al propietario de la lista y lo + * selecciona + * + * @param idLista ID de la lista de reproduccion + * @return Datos de la lista de reproduccion seleccionada + */ + public DtListaDeReproduccion seleccionarListaDeReproduccion(int idLista); + + /** + * Selecciona un video del usuarioSeleccionado El sistema recuerda el ID del + * video como idVideoSeleccionado. Si no hay un usuarioSeleccionado, el + * sistema busca al propietario del video y lo selecciona + * + * @param idVideo ID del video + * @return Datos del video seleccionado + */ + public DtVideo seleccionarVideo(int idVideo); + + /** + * Permite saber si hay una sesion iniciada + * @return true si hay una sesion iniciada + */ + public boolean sesionIniciada(); + + /** + * Verifica si el usuarioActual puede agregar una lista de reproduccion con + * el nombre indicado (Si hay una idListaSeleccionada y su nombre coincide + * con el nombre a verificar, retorna true) + * + * @param nombre Nombre de la lista de reproduccion + * @return true si el usuarioActual puede agregar una lista de reproduccion + * con ese nombre + */ + public boolean validarNuevaListaParticular(String nombre); + + /** + * Verifica si el usuarioActual puede agregar un video con el nombre + * indicado (Si hay un idVideoSeleccionado y su nombre coincide con el + * nombre a verificar, retorna true) + * + * @param nombre Nombre del video + * @return true si el usuarioActual puede agregar un video con ese nombre + */ + public boolean validarNuevoVideo(String nombre); + + /** + * Se ingresa la nueva valoracion dada por usuarioActual al video + * idVideoSeleccionado perteneciente a usuarioSeleccionado Si el usuario ya + * habia valorado, se actualiza la valoracion dada Si la valoracion recibida + * es null, se quita la valoracion dada + * + * @param val Valoracion dada (puede ser null) + */ + public void valorarVideo(DtValoracion val); + +} diff --git a/UyTube_logica/src/META-INF/persistence.xml b/UyTube_logica/src/META-INF/persistence.xml new file mode 100644 index 0000000000000000000000000000000000000000..aa020d7a75891bd8952307dfcedf3e57ed4a037b --- /dev/null +++ b/UyTube_logica/src/META-INF/persistence.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> + <persistence-unit name="UyTubePU" transaction-type="RESOURCE_LOCAL"> + <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> + <class>Logica.Clases.Administrador</class> + <class>Logica.Clases.Canal</class> + <class>Logica.Clases.Categoria</class> + <class>Logica.Clases.Comentario</class> + <class>Logica.Clases.ListaDeReproduccion</class> + <class>Logica.Clases.ListaPorDefecto</class> + <class>Logica.Clases.Persona</class> + <class>Logica.Clases.Usuario</class> + <class>Logica.Clases.Valoracion</class> + <class>Logica.Clases.Video</class> + <properties> + <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/UyTube"/> + <property name="javax.persistence.jdbc.user" value="postgres"/> + <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/> + <property name="javax.persistence.jdbc.password" value="1234"/> + <property name="javax.persistence.schema-generation.database.action" value="create"/> + </properties> + </persistence-unit> +</persistence> diff --git a/UyTube_logica/src/Presentacion/Categoria/frmAltaCategoria.form b/UyTube_logica/src/Presentacion/Categoria/frmAltaCategoria.form new file mode 100644 index 0000000000000000000000000000000000000000..c576cb392ef127780d12b97cf89b45e04250d0e0 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Categoria/frmAltaCategoria.form @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Alta categoria"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/> + </Events> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel23" min="-2" pref="350" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jPanel23" min="-2" pref="212" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel23"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="txtNombre"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtNombreFocusGained"/> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtNombreKeyPressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="80" width="290" height="30"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="200" y="150" width="120" height="40"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="150" width="120" height="40"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMensaje"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="120" width="290" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Alta Categoría"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="110" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel122"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Ingrese una nueva Categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="60" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Categoria/frmAltaCategoria.java b/UyTube_logica/src/Presentacion/Categoria/frmAltaCategoria.java new file mode 100644 index 0000000000000000000000000000000000000000..1f513d6f336315e268548ea3b3e0cf8e6d4d6eaa --- /dev/null +++ b/UyTube_logica/src/Presentacion/Categoria/frmAltaCategoria.java @@ -0,0 +1,236 @@ + +package Presentacion.Categoria; + +import Logica.DataType.DtCategoria; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.awt.Color; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import javax.swing.border.Border; +import javax.swing.plaf.ColorUIResource; + +public class frmAltaCategoria extends javax.swing.JDialog { + + IAdmin sys; + Border bordeDefault; + Color colorOK = new ColorUIResource(40,167,69); + Color colorError = new ColorUIResource(220,53,69); + Pattern patronCategoria= Pattern.compile("^([A-Za-zÑñÃáÉéÃÃÓóÚú\\d\\-_]+)\\s*([A-Za-zÑñÃáÉéÃÃÓóÚú\\d\\-_]+)\\s*" + + "([A-Za-zÑñÃáÉéÃÃÓóÚú\\d\\-_]+)\\s*([A-Za-zÑñÃáÉéÃÃÓóÚú\\d\\-_]+)\\s*([A-Za-zÑñÃáÉéÃÃÓóÚú\\d\\-_]+)\\s*([A-Za-zÑñÃáÉéÃÃÓóÚú\\d\\-_]+)$"); + String nuevaCategoria = new String(); + + public frmAltaCategoria(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + bordeDefault = txtNombre.getBorder(); + sys = Fabrica.getInstancia().getIAdmin(); + } + + private boolean validarCategoria(){ + nuevaCategoria = txtNombre.getText().trim().toUpperCase(); + if(nuevaCategoria.equals("")){ + lbMensaje.setText(" El campo nombre está vacÃo");//mensaje de error al adminstrador + cambiarColoresError(); + return false; + }else if(nuevaCategoria.length() > 30){ + lbMensaje.setText(" El nombre excede los 30 caracteres");//mensaje de error al adminstrador + cambiarColoresError(); + return false; + } + else if(!validarFormatoCategoria(nuevaCategoria)){ + lbMensaje.setText(" El fomrato es alfanumérico");//mensaje de error al adminstrador + cambiarColoresError(); + return false; + } + else{ + //Recorre todas las categorias existentes + try{ + for(String item : sys.listarCategorias()) { + //Si la categoria ya existe avisa al administrador + if(nuevaCategoria.equals(item)){ + lbMensaje.setText(" "+nuevaCategoria + " ya existe");//mensaje de error al adminstrador + cambiarColoresError(); + nuevaCategoria = ""; + return false; + } + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + } + return true; + } + + private boolean validarFormatoCategoria(String cat){ + Matcher mather = patronCategoria.matcher(cat); + if (mather.find() == true) { + return true; + } + return false; + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel23 = new javax.swing.JPanel(); + txtNombre = new javax.swing.JTextField(); + btnAceptar = new javax.swing.JButton(); + btnCancelar = new javax.swing.JButton(); + lbMensaje = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel122 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Alta categoria"); + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + + jPanel23.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + txtNombre.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + txtNombre.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + txtNombreFocusGained(evt); + } + }); + txtNombre.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtNombreKeyPressed(evt); + } + }); + jPanel23.add(txtNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 80, 290, 30)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel23.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 150, 120, 40)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + jPanel23.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 150, 120, 40)); + + lbMensaje.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jPanel23.add(lbMensaje, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 120, 290, 20)); + + jLabel1.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N + jLabel1.setText("Alta CategorÃa"); + jPanel23.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 20, -1, -1)); + + jLabel122.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel122.setText("Ingrese una nueva CategorÃa:"); + jPanel23.add(jLabel122, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, -1, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + //Si la categoria supera la validacion la ingresa + if (validarCategoria()) { + try { + sys.altaCategoria(nuevaCategoria); + txtNombre.setText(""); + cambiarColoresOK(); + nuevaCategoria = ""; + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + } + }//GEN-LAST:event_btnAceptarActionPerformed + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + txtNombre.setText(""); + lbMensaje.setText(""); + lbMensaje.setOpaque(false); + this.setVisible(false); + }//GEN-LAST:event_btnCancelarActionPerformed + + private void txtNombreFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNombreFocusGained + // Cuando obtiene el foco los colores se resetean + txtNombre.setText(""); + lbMensaje.setText(""); + lbMensaje.setOpaque(false); + txtNombre.setBorder(bordeDefault); + }//GEN-LAST:event_txtNombreFocusGained + + private void cambiarColoresOK(){ + lbMensaje.setForeground(Color.white); //texto en rojo + lbMensaje.setBackground(colorOK); + lbMensaje.setText(" CategorÃa \"" + nuevaCategoria + "\" ingresada. OK");// + lbMensaje.setOpaque(true); + txtNombre.setBorder(bordeDefault); //Pone el borde con sus valores por default + } + + private void cambiarColoresError() { + lbMensaje.setBackground(colorError); + lbMensaje.setOpaque(true); + lbMensaje.setForeground(Color.WHITE); //texto en rojo + txtNombre.setBorder(BorderFactory.createLineBorder(colorError, 1));//color del borde rojo + } + + private void txtNombreKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreKeyPressed + // Al presionar ENTER + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + //Si la categoria supera la validacion la ingresa + if (validarCategoria()) { + try { + sys.altaCategoria(nuevaCategoria); + txtNombre.setText(""); + cambiarColoresOK(); + nuevaCategoria = ""; + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + } + } + }//GEN-LAST:event_txtNombreKeyPressed + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + // Al cerrar el formulario se limpian los campos + txtNombre.setText(""); + lbMensaje.setText(""); + lbMensaje.setOpaque(false); + }//GEN-LAST:event_formWindowClosing + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JButton btnCancelar; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel122; + private javax.swing.JPanel jPanel23; + private javax.swing.JLabel lbMensaje; + private javax.swing.JTextField txtNombre; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Categoria/frmConsultaCategoria.form b/UyTube_logica/src/Presentacion/Categoria/frmConsultaCategoria.form new file mode 100644 index 0000000000000000000000000000000000000000..de103ca506ea9387bdbf95ba7a62b528788c86e5 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Categoria/frmConsultaCategoria.form @@ -0,0 +1,178 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Consultar categoria"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel25" min="-2" pref="790" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel25" min="-2" pref="410" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel25"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="cmdAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="cmdAceptarMouseClicked"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="543" y="323" width="220" height="70"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel123"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Categorías:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane47"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="40" width="220" height="350"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstCategorias"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstCategoriasValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel124"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Videos:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane48"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="280" y="40" width="240" height="350"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListaReproducion"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel125"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="List. Reproducción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="280" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane49"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="40" width="210" height="280"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideos"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Categoria/frmConsultaCategoria.java b/UyTube_logica/src/Presentacion/Categoria/frmConsultaCategoria.java new file mode 100644 index 0000000000000000000000000000000000000000..4f1660beff2bc7e8b9b59536d2c3686939f0a187 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Categoria/frmConsultaCategoria.java @@ -0,0 +1,163 @@ + +package Presentacion.Categoria; + +import Logica.DataType.*; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmConsultaCategoria extends javax.swing.JDialog { + Fabrica f = Fabrica.getInstancia(); + IAdmin Sys = f.getIAdmin(); + String CategoriaActual; + public frmConsultaCategoria(java.awt.Frame parent, boolean modal) { + super(parent, modal); + try { + initComponents(); + this.setLocationRelativeTo(null); + ArrayList<String> ListaCategorias = Sys.listarCategorias(); + DefaultListModel modelo = new DefaultListModel(); + + for (String it : ListaCategorias) { + modelo.addElement(it); + } + lstCategorias.setModel(modelo); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + + + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel25 = new javax.swing.JPanel(); + cmdAceptar = new javax.swing.JButton(); + jLabel123 = new javax.swing.JLabel(); + jScrollPane47 = new javax.swing.JScrollPane(); + lstCategorias = new javax.swing.JList<>(); + jLabel124 = new javax.swing.JLabel(); + jScrollPane48 = new javax.swing.JScrollPane(); + lstListaReproducion = new javax.swing.JList<>(); + jLabel125 = new javax.swing.JLabel(); + jScrollPane49 = new javax.swing.JScrollPane(); + lstVideos = new javax.swing.JList<>(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Consultar categoria"); + setResizable(false); + + jPanel25.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + cmdAceptar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + cmdAceptar.setText("Aceptar"); + cmdAceptar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + cmdAceptarMouseClicked(evt); + } + }); + cmdAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmdAceptarActionPerformed(evt); + } + }); + jPanel25.add(cmdAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(543, 323, 220, 70)); + + jLabel123.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel123.setText("CategorÃas:"); + jPanel25.add(jLabel123, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1)); + + lstCategorias.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstCategoriasValueChanged(evt); + } + }); + jScrollPane47.setViewportView(lstCategorias); + + jPanel25.add(jScrollPane47, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 220, 350)); + + jLabel124.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel124.setText("Videos:"); + jPanel25.add(jLabel124, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 10, -1, -1)); + + jScrollPane48.setViewportView(lstListaReproducion); + + jPanel25.add(jScrollPane48, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 40, 240, 350)); + + jLabel125.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel125.setText("List. Reproducción:"); + jPanel25.add(jLabel125, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 10, -1, -1)); + + jScrollPane49.setViewportView(lstVideos); + + jPanel25.add(jScrollPane49, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 40, 210, 280)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel25, javax.swing.GroupLayout.PREFERRED_SIZE, 790, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel25, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void cmdAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAceptarActionPerformed + + }//GEN-LAST:event_cmdAceptarActionPerformed + + private void cmdAceptarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdAceptarMouseClicked + dispose(); + }//GEN-LAST:event_cmdAceptarMouseClicked + + private void lstCategoriasValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstCategoriasValueChanged + try { + CategoriaActual = lstCategorias.getSelectedValue(); + + //Lista la listas de reproduccion de la categoria seleccionada + ArrayList<DtListaDeReproduccion> ListaRDeCategoria = Sys.listarListasDeReproduccionEnCategoria(CategoriaActual); + DefaultListModel modeloLR = new DefaultListModel(); + + for (DtListaDeReproduccion it : ListaRDeCategoria) { + modeloLR.addElement(it.getNombre()); + } + lstListaReproducion.setModel(modeloLR); + + //Lista los Videos de la categoria + ArrayList<DtVideo> VideosCategoria = Sys.listarVideosEnCategoria(CategoriaActual); + DefaultListModel modeloV = new DefaultListModel(); + + for (DtVideo it : VideosCategoria) { + modeloV.addElement(it.getNombre()); + } + lstVideos.setModel(modeloV); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null,(String)e.getMessage(), "Error:", JOptionPane.ERROR_MESSAGE); + } + + }//GEN-LAST:event_lstCategoriasValueChanged + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton cmdAceptar; + private javax.swing.JLabel jLabel123; + private javax.swing.JLabel jLabel124; + private javax.swing.JLabel jLabel125; + private javax.swing.JPanel jPanel25; + private javax.swing.JScrollPane jScrollPane47; + private javax.swing.JScrollPane jScrollPane48; + private javax.swing.JScrollPane jScrollPane49; + private javax.swing.JList<String> lstCategorias; + private javax.swing.JList<String> lstListaReproducion; + private javax.swing.JList<String> lstVideos; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Categoria/frmListarCategorias.form b/UyTube_logica/src/Presentacion/Categoria/frmListarCategorias.form new file mode 100644 index 0000000000000000000000000000000000000000..7e699ed185b9ecb3446da81f28aaa4180d67dc26 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Categoria/frmListarCategorias.form @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Listar categoria"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel26" min="-2" pref="290" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel26" min="-2" pref="380" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel26"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="133" y="333" width="140" height="40"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane46"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="40" width="250" height="280"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstCategorias"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel122"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Categorías:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Categoria/frmListarCategorias.java b/UyTube_logica/src/Presentacion/Categoria/frmListarCategorias.java new file mode 100644 index 0000000000000000000000000000000000000000..cac7c5b6b71c44e2ad495b486edc3b73ba17cd0e --- /dev/null +++ b/UyTube_logica/src/Presentacion/Categoria/frmListarCategorias.java @@ -0,0 +1,85 @@ + +package Presentacion.Categoria; + +import Logica.Controladores.CAdmin; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmListarCategorias extends javax.swing.JDialog { + + public frmListarCategorias(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + + try { + DefaultListModel modelo2 = new DefaultListModel(); + for (int i = 0; i < CAdmin.getInstancia().listarCategorias().size(); i++) { + modelo2.add(i, CAdmin.getInstancia().listarCategorias().get(i)); + } + lstCategorias.setModel(modelo2); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel26 = new javax.swing.JPanel(); + btnAceptar = new javax.swing.JButton(); + jScrollPane46 = new javax.swing.JScrollPane(); + lstCategorias = new javax.swing.JList<>(); + jLabel122 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Listar categoria"); + setResizable(false); + + jPanel26.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel26.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(133, 333, 140, 40)); + + jScrollPane46.setViewportView(lstCategorias); + + jPanel26.add(jScrollPane46, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, 250, 280)); + + jLabel122.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel122.setText("CategorÃas:"); + jPanel26.add(jLabel122, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel26, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel26, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + dispose(); + }//GEN-LAST:event_btnAceptarActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JLabel jLabel122; + private javax.swing.JPanel jPanel26; + private javax.swing.JScrollPane jScrollPane46; + private javax.swing.JList<String> lstCategorias; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.form b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.form new file mode 100644 index 0000000000000000000000000000000000000000..1643af78e163c7217cb6d90b11e81d27e4470c8a --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.form @@ -0,0 +1,255 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Agregar video a lista de reproduccion"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="790" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel21" min="-2" pref="790" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="410" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel21" min="-2" pref="410" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel21"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane40"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="200" width="220" height="130"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuariosL"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosLValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane41"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="280" y="40" width="210" height="290"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideos"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstVideosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane42"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="520" y="40" width="240" height="290"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListasRep"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstListasRepValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel115"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seleccionar propietario de lista:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="180" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel116"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Listas del usuario seleccionado:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="520" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel117"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Videos del usuario seleccionado:"/> + <Property name="toolTipText" type="java.lang.String" value=""/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="280" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="350" width="220" height="40"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Agregar"/> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="520" y="350" width="240" height="40"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane43"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="40" width="220" height="130"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuariosV"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosVValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel118"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seleccionar propietario del video:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.java b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.java new file mode 100644 index 0000000000000000000000000000000000000000..227d5b28473807b9f1948cc749b7dc1753633920 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAgregarVideoAListaDeReproduccion.java @@ -0,0 +1,334 @@ +package Presentacion.ListaDeReproduccion; + +import Logica.DataType.DtCanal; +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtUsuario; +import Logica.DataType.DtVideo; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + + +public class frmAgregarVideoAListaDeReproduccion extends javax.swing.JDialog { + IAdmin sys; + ArrayList<DtVideo> listaDeVideos; + ArrayList<DtListaDeReproduccion> listaDeListasRep; + ArrayList<DtVideo> dtv; + boolean liberarMemoria; + public frmAgregarVideoAListaDeReproduccion(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + + + try { + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // lista usuarios en el JList + listarUsuarios(sys.listarUsuarios()); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + + + } + private void listarUsuarios(ArrayList<DtUsuario> ListaUsuarios){ + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + } + lstUsuariosV.setModel(modelo); + lstUsuariosL.setModel(modelo); + + } + + private boolean habilitarAceptar(){ + if(!(lstListasRep.isSelectionEmpty() || + lstVideos.isSelectionEmpty() || + lstUsuariosL.isSelectionEmpty() || + lstUsuariosV.isSelectionEmpty())) + { + return true; + }else{ + return false; + } + } + + + + private void listarVideos(ArrayList<DtVideo> ListaVideos){ + DefaultListModel modelo = new DefaultListModel(); + for (DtVideo it : ListaVideos) { + modelo.addElement(it.getNombre()); + } + lstVideos.setModel(modelo); + } + + private void listarListassRep(ArrayList<DtListaDeReproduccion> listaListasRep){ + DefaultListModel modelo = new DefaultListModel(); + for (DtListaDeReproduccion it : listaListasRep) { + modelo.addElement(it.getNombre()); + } + lstListasRep.setModel(modelo); + } + + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel21 = new javax.swing.JPanel(); + jScrollPane40 = new javax.swing.JScrollPane(); + lstUsuariosL = new javax.swing.JList<>(); + jScrollPane41 = new javax.swing.JScrollPane(); + lstVideos = new javax.swing.JList<>(); + jScrollPane42 = new javax.swing.JScrollPane(); + lstListasRep = new javax.swing.JList<>(); + jLabel115 = new javax.swing.JLabel(); + jLabel116 = new javax.swing.JLabel(); + jLabel117 = new javax.swing.JLabel(); + btnCancelar = new javax.swing.JButton(); + btnAceptar = new javax.swing.JButton(); + jScrollPane43 = new javax.swing.JScrollPane(); + lstUsuariosV = new javax.swing.JList<>(); + jLabel118 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Agregar video a lista de reproduccion"); + setResizable(false); + + jPanel21.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + lstUsuariosL.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosLValueChanged(evt); + } + }); + jScrollPane40.setViewportView(lstUsuariosL); + + jPanel21.add(jScrollPane40, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 200, 220, 130)); + + lstVideos.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstVideosValueChanged(evt); + } + }); + jScrollPane41.setViewportView(lstVideos); + + jPanel21.add(jScrollPane41, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 40, 210, 290)); + + lstListasRep.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstListasRepValueChanged(evt); + } + }); + jScrollPane42.setViewportView(lstListasRep); + + jPanel21.add(jScrollPane42, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 40, 240, 290)); + + jLabel115.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel115.setText("Seleccionar propietario de lista:"); + jPanel21.add(jLabel115, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 180, -1, -1)); + + jLabel116.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel116.setText("Listas del usuario seleccionado:"); + jPanel21.add(jLabel116, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 20, -1, -1)); + + jLabel117.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel117.setText("Videos del usuario seleccionado:"); + jLabel117.setToolTipText(""); + jPanel21.add(jLabel117, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 20, -1, -1)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + jPanel21.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 350, 220, 40)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnAceptar.setText("Agregar"); + btnAceptar.setEnabled(false); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel21.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 350, 240, 40)); + + lstUsuariosV.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosVValueChanged(evt); + } + }); + jScrollPane43.setViewportView(lstUsuariosV); + + jPanel21.add(jScrollPane43, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 220, 130)); + + jLabel118.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel118.setText("Seleccionar propietario del video:"); + jPanel21.add(jLabel118, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 790, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, 790, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 410, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + + dispose(); + }//GEN-LAST:event_btnCancelarActionPerformed + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + try { + if (lstUsuariosL.isSelectionEmpty() && lstUsuariosV.isSelectionEmpty()) { + JOptionPane.showMessageDialog(null, "No ha indicado ningun usuario", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (lstUsuariosL.isSelectionEmpty()) { + JOptionPane.showMessageDialog(null, "Debe seleccionar el usuario propietario de la lista", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (lstUsuariosV.isSelectionEmpty()) { + JOptionPane.showMessageDialog(null, "Debe seleccionar el usuario propietario del video", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (lstVideos.isSelectionEmpty()) { + JOptionPane.showMessageDialog(null, "Debe seleccionar un video para agregar", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (lstListasRep.isSelectionEmpty()) { + JOptionPane.showMessageDialog(null, "Debe seleccionar una lista para agregarle el video", "Error", JOptionPane.WARNING_MESSAGE); + } else { + + + int idLista = listaDeListasRep.get(lstListasRep.getSelectedIndex()).getId(); + String nombreVideo = listaDeVideos.get(lstVideos.getSelectedIndex()).getNombre(); + String nombreLista = listaDeListasRep.get(lstListasRep.getSelectedIndex()).getNombre(); + sys.agregarVideoAListaDeReproduccion(idLista); + JOptionPane.showMessageDialog(null, "Se ha añadido el video '" + nombreVideo + "' a la lista '" + nombreLista + "'", "Listo", JOptionPane.INFORMATION_MESSAGE); + DefaultListModel model = (DefaultListModel) lstListasRep.getModel(); + model.clear(); + DefaultListModel model1 = (DefaultListModel) lstVideos.getModel(); + model1.clear(); + lstUsuariosL.clearSelection(); + lstUsuariosV.clearSelection(); + if(liberarMemoria){ + sys.liberarMemoriaUsuario(); + } + + sys.liberarMemoriaUsuarioActual(); + sys.liberarMemoriaVideo(); + } + } + } + } + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } //listaRep->agregarVideo->aceptar + }//GEN-LAST:event_btnAceptarActionPerformed + + + private void lstUsuariosVValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosVValueChanged + if (evt.getValueIsAdjusting()) return; + if (lstUsuariosV.getSelectedIndex()<0) return; + + try { + String nick = lstUsuariosV.getSelectedValue(); + DtUsuario dtu = sys.seleccionarUsuario(nick); + + listaDeVideos = sys.listarVideosDeUsuario(); + listarVideos(listaDeVideos); + btnAceptar.setEnabled(habilitarAceptar()); + + + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + + } // TODO add your handling code heres: + }//GEN-LAST:event_lstUsuariosVValueChanged + + private void lstUsuariosLValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosLValueChanged +if (evt.getValueIsAdjusting()) return; + if (lstUsuariosL.getSelectedIndex()<0) return; + + try { + String nick = lstUsuariosL.getSelectedValue(); + DtUsuario dtu = sys.seleccionarUsuarioActual(nick); + + listaDeListasRep = sys.listarListasDeReproduccionDeUsuario(nick); + listarListassRep(listaDeListasRep); + btnAceptar.setEnabled(habilitarAceptar()); + + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + + } // TODO add your handling code here: + }//GEN-LAST:event_lstUsuariosLValueChanged + + private void lstVideosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstVideosValueChanged + try { + if(!(lstVideos.isSelectionEmpty())){ + int idVideo = listaDeVideos.get(lstVideos.getSelectedIndex()).getId(); + btnAceptar.setEnabled(habilitarAceptar()); + + sys.seleccionarVideo(idVideo); + + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } // TODO add your handling code here: + }//GEN-LAST:event_lstVideosValueChanged + + private void lstListasRepValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstListasRepValueChanged + btnAceptar.setEnabled(habilitarAceptar()); + + + // TODO add your handling code here: }//GEN-LAST:event_lstListasRepValueChanged + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JButton btnCancelar; + private javax.swing.JLabel jLabel115; + private javax.swing.JLabel jLabel116; + private javax.swing.JLabel jLabel117; + private javax.swing.JLabel jLabel118; + private javax.swing.JPanel jPanel21; + private javax.swing.JScrollPane jScrollPane40; + private javax.swing.JScrollPane jScrollPane41; + private javax.swing.JScrollPane jScrollPane42; + private javax.swing.JScrollPane jScrollPane43; + private javax.swing.JList<String> lstListasRep; + private javax.swing.JList<String> lstUsuariosL; + private javax.swing.JList<String> lstUsuariosV; + private javax.swing.JList<String> lstVideos; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.form b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.form new file mode 100644 index 0000000000000000000000000000000000000000..3d948e6a1f4b16ddf3eb2ed56bf9ba249fab9c9d --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.form @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="GrupoTipo"> + </Component> + <Component class="javax.swing.ButtonGroup" name="GrupoPublicoPrivado"> + </Component> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Nueva lista de reproduccion"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="810" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel17" min="-2" pref="810" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="430" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel17" min="-2" pref="430" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel17"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel100"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Nombre:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="410" y="40" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtNombre"> + <Events> + <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtNombreKeyReleased"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="470" y="40" width="310" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel18"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo"> + <EtchetBorder/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="80" width="750" height="270"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel101"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane31"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="40" width="340" height="180"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstCategorias"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JRadioButton" name="rbPublica"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="GrupoPublicoPrivado"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Pública"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rbPublicaActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="12"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="230" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbPrivada"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="GrupoPublicoPrivado"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Privada"/> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="490" y="230" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel102"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane32"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="40" width="320" height="180"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarios"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="410" y="370" width="370" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnCancelarMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="370" width="350" height="50"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="pnlTipo"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder title="Tipo"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="32" y="10" width="330" height="60"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JRadioButton" name="rbPorDefecto"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="GrupoTipo"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Por defecto"/> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="rbPorDefectoItemStateChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="200" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbParticular"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="GrupoTipo"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Particular"/> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="50" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.java b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.java new file mode 100644 index 0000000000000000000000000000000000000000..b9d49b42bfee86e40ca7992439be90940c34c980 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmAltaListaDeReproduccion.java @@ -0,0 +1,344 @@ +package Presentacion.ListaDeReproduccion; + +import Logica.DataType.*; +import Logica.Enumerados.Privacidad; +import Logica.Enumerados.TipoListaDeReproduccion; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmAltaListaDeReproduccion extends javax.swing.JDialog { + + Fabrica f = Fabrica.getInstancia(); + IAdmin Sys = f.getIAdmin(); + + public frmAltaListaDeReproduccion(java.awt.Frame parent, boolean modal) { + super(parent, modal); + + try { + initComponents(); + this.setLocationRelativeTo(null); + ArrayList<DtUsuario> ListaUsuarios = Sys.listarUsuarios(); + DefaultListModel modeloUsuario = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modeloUsuario.addElement(it.getNickname()); + } + lstUsuarios.setModel(modeloUsuario); + ArrayList<String> ListaCategoria = Sys.listarCategorias(); + DefaultListModel modeloCategoria = new DefaultListModel(); + for (String it : ListaCategoria) { + modeloCategoria.addElement(it); + } + lstCategorias.setModel(modeloCategoria); + lstCategorias.setSelectedValue("UNDEFINED", true); + rbParticular.setSelected(true); + rbPublica.setSelected(true); + + btnAceptar.setEnabled(false); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + GrupoTipo = new javax.swing.ButtonGroup(); + GrupoPublicoPrivado = new javax.swing.ButtonGroup(); + jPanel17 = new javax.swing.JPanel(); + jLabel100 = new javax.swing.JLabel(); + txtNombre = new javax.swing.JTextField(); + jPanel18 = new javax.swing.JPanel(); + jLabel101 = new javax.swing.JLabel(); + jScrollPane31 = new javax.swing.JScrollPane(); + lstCategorias = new javax.swing.JList<>(); + rbPublica = new javax.swing.JRadioButton(); + rbPrivada = new javax.swing.JRadioButton(); + jLabel102 = new javax.swing.JLabel(); + jScrollPane32 = new javax.swing.JScrollPane(); + lstUsuarios = new javax.swing.JList<>(); + btnAceptar = new javax.swing.JButton(); + btnCancelar = new javax.swing.JButton(); + pnlTipo = new javax.swing.JPanel(); + rbPorDefecto = new javax.swing.JRadioButton(); + rbParticular = new javax.swing.JRadioButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Nueva lista de reproduccion"); + setResizable(false); + + jPanel17.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel100.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel100.setText("Nombre:"); + jPanel17.add(jLabel100, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 40, -1, -1)); + + txtNombre.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + txtNombreKeyReleased(evt); + } + }); + jPanel17.add(txtNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 40, 310, -1)); + + jPanel18.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jPanel18.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel101.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel101.setText("Usuarios:"); + jPanel18.add(jLabel101, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1)); + + jScrollPane31.setViewportView(lstCategorias); + + jPanel18.add(jScrollPane31, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 40, 340, 180)); + + GrupoPublicoPrivado.add(rbPublica); + rbPublica.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + rbPublica.setText("Pública"); + rbPublica.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rbPublicaActionPerformed(evt); + } + }); + jPanel18.add(rbPublica, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 230, -1, -1)); + + GrupoPublicoPrivado.add(rbPrivada); + rbPrivada.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + rbPrivada.setText("Privada"); + jPanel18.add(rbPrivada, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 230, -1, -1)); + + jLabel102.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel102.setText("CategorÃa:"); + jPanel18.add(jLabel102, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 10, -1, -1)); + + lstUsuarios.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosValueChanged(evt); + } + }); + jScrollPane32.setViewportView(lstUsuarios); + + jPanel18.add(jScrollPane32, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 320, 180)); + + jPanel17.add(jPanel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 80, 750, 270)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel17.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 370, 370, 50)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + btnCancelarMouseClicked(evt); + } + }); + jPanel17.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 370, 350, 50)); + + pnlTipo.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo")); + pnlTipo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + pnlTipo.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + GrupoTipo.add(rbPorDefecto); + rbPorDefecto.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + rbPorDefecto.setText("Por defecto"); + rbPorDefecto.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + rbPorDefectoItemStateChanged(evt); + } + }); + pnlTipo.add(rbPorDefecto, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 20, -1, -1)); + + GrupoTipo.add(rbParticular); + rbParticular.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + rbParticular.setText("Particular"); + pnlTipo.add(rbParticular, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 20, -1, -1)); + + jPanel17.add(pnlTipo, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 10, 330, 60)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 810, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, 810, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 430, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, 430, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnCancelarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarMouseClicked + try { + Sys.liberarMemoriaUsuario(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + dispose(); + }//GEN-LAST:event_btnCancelarMouseClicked + + private void rbPorDefectoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbPorDefectoItemStateChanged + if (rbPorDefecto.isSelected() == true) { + txtNombre.setText(""); + rbPublica.setEnabled(false); + rbPrivada.setSelected(true); + lstUsuarios.setEnabled(false); + lstCategorias.setEnabled(false); + lstCategorias.setSelectedValue("UNDEFINED", true); + lstUsuarios.clearSelection(); + btnAceptar.setEnabled(false); + } else { + txtNombre.setText(""); + rbPublica.setEnabled(true); + lstUsuarios.setEnabled(true); + lstCategorias.setEnabled(true); + lstCategorias.clearSelection(); + lstUsuarios.clearSelection(); + lstCategorias.setSelectedValue("UNDEFINED", true); + btnAceptar.setEnabled(false); + } + }//GEN-LAST:event_rbPorDefectoItemStateChanged + + private void txtNombreKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreKeyReleased + // mientras se escrbe el nombre de la lista + habilitarDeshabilitarBotonAceptar(); + }//GEN-LAST:event_txtNombreKeyReleased + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + DtListaDeReproduccion lst = null; + Privacidad Priv = null; + + if (txtNombre.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "El nombre de la lista de reproduccion no puede ser vacio", "Avertencia:", JOptionPane.WARNING_MESSAGE); + return; + } + if (rbPrivada.isSelected() == true) { + Priv = Privacidad.PRIVADO; + } + if (rbPublica.isSelected() == true) { + Priv = Privacidad.PUBLICO; + } + + try { + + if (rbParticular.isSelected() == true) { + + if (lstUsuarios.getSelectedValue().isEmpty()) { + JOptionPane.showMessageDialog(null, "Debe seleccionar un usuario para continuar", "Avertencia:", JOptionPane.WARNING_MESSAGE); + return; + } + + Sys.seleccionarUsuario(lstUsuarios.getSelectedValue()); + + if (Sys.obtenerCanalDeUsuario().getPrivacidad() == Privacidad.PRIVADO && rbPublica.isSelected() == true) { + JOptionPane.showMessageDialog(null, "Un canal privado no puede tener una lista de reproducion publica", "Avertencia:", JOptionPane.WARNING_MESSAGE); + return; + } + + lst = new DtListaDeReproduccion(0, txtNombre.getText(), Priv, TipoListaDeReproduccion.PARTICULAR, lstCategorias.getSelectedValue()); + + + if (!Sys.validarNuevaListaParticular(lst.getNombre())) { + JOptionPane.showMessageDialog(null, "El usuario ya posee una lista de reproduccion con ese nombre", "Avertencia:", JOptionPane.WARNING_MESSAGE); + return; + } + + Sys.altaListaDeReproduccionParticular(lst); + JOptionPane.showMessageDialog(null, "Lista particular creada", "Informacion:", JOptionPane.INFORMATION_MESSAGE); + } + + if (rbPorDefecto.isSelected() == true) { + + lst = new DtListaDeReproduccion(0, txtNombre.getText(), Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); + + if (!Sys.validarNuevaListaPorDefecto(lst.getNombre())) { + JOptionPane.showMessageDialog(null, "El nombre para la lista de reproduccion ya esta usado", "Avertencia:", JOptionPane.WARNING_MESSAGE); + return; + } + + Sys.altaListaDeReproduccionPorDefecto(lst); + JOptionPane.showMessageDialog(null, "Lista por defecto creada", "Informacion:", JOptionPane.INFORMATION_MESSAGE); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + + try { + Sys.liberarMemoriaUsuario(); + txtNombre.setText(""); + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnAceptarActionPerformed + + private void lstUsuariosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosValueChanged + // al seleccionar un usuario + habilitarDeshabilitarBotonAceptar(); + }//GEN-LAST:event_lstUsuariosValueChanged + + private void rbPublicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbPublicaActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_rbPublicaActionPerformed + + private void habilitarDeshabilitarBotonAceptar(){ + // si se selecciono para crear lista particular + if (rbParticular.isSelected()) { + if (lstUsuarios.getSelectedIndex() < 0 || lstCategorias.getSelectedIndex() < 0 || txtNombre.getText().isEmpty()) { + btnAceptar.setEnabled(false); + return; + } + btnAceptar.setEnabled(true); + } else { // si se selecciono para crear lista particular + if (txtNombre.getText().isEmpty()) { + btnAceptar.setEnabled(false); + return; + } + btnAceptar.setEnabled(true); + } + } + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.ButtonGroup GrupoPublicoPrivado; + private javax.swing.ButtonGroup GrupoTipo; + private javax.swing.JButton btnAceptar; + private javax.swing.JButton btnCancelar; + private javax.swing.JLabel jLabel100; + private javax.swing.JLabel jLabel101; + private javax.swing.JLabel jLabel102; + private javax.swing.JPanel jPanel17; + private javax.swing.JPanel jPanel18; + private javax.swing.JScrollPane jScrollPane31; + private javax.swing.JScrollPane jScrollPane32; + private javax.swing.JList<String> lstCategorias; + private javax.swing.JList<String> lstUsuarios; + private javax.swing.JPanel pnlTipo; + public static javax.swing.JRadioButton rbParticular; + public static javax.swing.JRadioButton rbPorDefecto; + public static javax.swing.JRadioButton rbPrivada; + protected static javax.swing.JRadioButton rbPublica; + private javax.swing.JTextField txtNombre; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.form b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.form new file mode 100644 index 0000000000000000000000000000000000000000..80e89cb2576ff3a0de09dcb9e8740ab39b9dbe2e --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.form @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Consultar lista de reproduccion"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="850" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel20" min="-2" pref="850" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="450" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel20" min="-2" pref="450" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel20"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="20" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnAceptarMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="580" y="380" width="240" height="60"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel106"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuario"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel107"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Listas de Reproducción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="290" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane37"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="50" width="240" height="320"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarios"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane38"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="580" y="50" width="240" height="320"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideos"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Doble clic para ver mas informacion de video"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lstVideosMouseClicked"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel108"> + <Properties> + <Property name="text" type="java.lang.String" value="Categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="420" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel109"> + <Properties> + <Property name="text" type="java.lang.String" value="Privacidad:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="400" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel110"> + <Properties> + <Property name="text" type="java.lang.String" value="Tipo:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="380" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel111"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Videos:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="580" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane39"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="290" y="50" width="260" height="320"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListasRep"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstListasRepValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="lbTipo"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="380" width="150" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCategoria"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="420" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbPrivacidad"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="400" width="150" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.java b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.java new file mode 100644 index 0000000000000000000000000000000000000000..da802ad74ee8f34832dc9c0f5b7b0cbb02ac2e92 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccion.java @@ -0,0 +1,287 @@ +package Presentacion.ListaDeReproduccion; + +import Logica.DataType.*; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import Presentacion.Video.frmConsultaVideo; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmConsultaListaDeReproduccion extends javax.swing.JDialog { + + Fabrica f = Fabrica.getInstancia(); + IAdmin Sys = f.getIAdmin(); + ArrayList<DtListaDeReproduccion> ListasDeReproducion; + ArrayList<DtVideo> Listavideos; + boolean liberarMemoria; + + public frmConsultaListaDeReproduccion(java.awt.Frame parent, boolean modal) { + super(parent, modal); + liberarMemoria = true; + try { + initComponents(); + this.setLocationRelativeTo(null); + + ArrayList<DtUsuario> ListaUsuarios = Sys.listarUsuarios(); + DefaultListModel modeloUsuario = new DefaultListModel(); + + for (DtUsuario it : ListaUsuarios) { + modeloUsuario.addElement(it.getNickname()); + } + lstUsuarios.setModel(modeloUsuario); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + } + + public frmConsultaListaDeReproduccion(javax.swing.JDialog parent, boolean modal,String nickname, int idListaVideo) { + super(parent, modal); + liberarMemoria = false; + try { + initComponents(); + this.setLocationRelativeTo(null); + + ArrayList<DtUsuario> ListaUsuarios = Sys.listarUsuarios(); + DefaultListModel modeloUsuario = new DefaultListModel(); + + for (DtUsuario it : ListaUsuarios) { + modeloUsuario.addElement(it.getNickname()); + } + lstUsuarios.setModel(modeloUsuario); + + lstUsuarios.setSelectedValue(nickname, true); + + lstListasRep.setSelectedValue(Sys.seleccionarListaDeReproduccion(idListaVideo).getNombre(), true); + lstListasRep.setEnabled(false); + lstUsuarios.setEnabled(false); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + + } + + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel20 = new javax.swing.JPanel(); + btnAceptar = new javax.swing.JButton(); + jLabel106 = new javax.swing.JLabel(); + jLabel107 = new javax.swing.JLabel(); + jScrollPane37 = new javax.swing.JScrollPane(); + lstUsuarios = new javax.swing.JList<>(); + jScrollPane38 = new javax.swing.JScrollPane(); + lstVideos = new javax.swing.JList<>(); + jLabel108 = new javax.swing.JLabel(); + jLabel109 = new javax.swing.JLabel(); + jLabel110 = new javax.swing.JLabel(); + jLabel111 = new javax.swing.JLabel(); + jScrollPane39 = new javax.swing.JScrollPane(); + lstListasRep = new javax.swing.JList<>(); + lbTipo = new javax.swing.JLabel(); + lbCategoria = new javax.swing.JLabel(); + lbPrivacidad = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Consultar lista de reproduccion"); + setResizable(false); + + jPanel20.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + btnAceptarMouseClicked(evt); + } + }); + jPanel20.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 380, 240, 60)); + + jLabel106.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel106.setText("Usuario"); + jPanel20.add(jLabel106, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1)); + + jLabel107.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel107.setText("Listas de Reproducción:"); + jPanel20.add(jLabel107, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 20, -1, -1)); + + lstUsuarios.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosValueChanged(evt); + } + }); + jScrollPane37.setViewportView(lstUsuarios); + + jPanel20.add(jScrollPane37, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 50, 240, 320)); + + lstVideos.setToolTipText("Doble clic para ver mas informacion de video"); + lstVideos.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + lstVideosMouseClicked(evt); + } + }); + jScrollPane38.setViewportView(lstVideos); + + jPanel20.add(jScrollPane38, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 50, 240, 320)); + + jLabel108.setText("CategorÃa:"); + jPanel20.add(jLabel108, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 420, -1, -1)); + + jLabel109.setText("Privacidad:"); + jPanel20.add(jLabel109, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 400, -1, -1)); + + jLabel110.setText("Tipo:"); + jPanel20.add(jLabel110, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 380, -1, -1)); + + jLabel111.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel111.setText("Videos:"); + jPanel20.add(jLabel111, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 20, -1, -1)); + + lstListasRep.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstListasRepValueChanged(evt); + } + }); + jScrollPane39.setViewportView(lstListasRep); + + jPanel20.add(jScrollPane39, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 50, 260, 320)); + + lbTipo.setText(" "); + jPanel20.add(lbTipo, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 380, 150, -1)); + + lbCategoria.setText(" "); + jPanel20.add(lbCategoria, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 420, 200, -1)); + + lbPrivacidad.setText(" "); + jPanel20.add(lbPrivacidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 400, 150, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 850, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, 850, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 450, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAceptarMouseClicked + if (liberarMemoria){ + Sys.liberarMemoriaUsuario(); + } + Sys.liberarMemoriaListaDeReproduccion(); + Sys.liberarMemoriaVideo(); + + lstListasRep.clearSelection(); + lstUsuarios.clearSelection(); + lstVideos.clearSelection(); + lbCategoria.setText(""); + lbPrivacidad.setText(""); + lbTipo.setText(""); + + dispose(); + + }//GEN-LAST:event_btnAceptarMouseClicked + + private void lstUsuariosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosValueChanged + //Cuando se seleccione algo el lstUsuarios + if (evt.getValueIsAdjusting()) return; + if (lstUsuarios.getSelectedIndex()<0) return; + lstVideos.setModel(new DefaultListModel()); + try { + DtUsuario dtUsu = Sys.seleccionarUsuario(lstUsuarios.getSelectedValue()); + + ListasDeReproducion = Sys.listarListasDeReproduccionDeUsuario(dtUsu.getNickname()); + + DefaultListModel modelo = new DefaultListModel(); + + for (DtListaDeReproduccion it : ListasDeReproducion) { + modelo.addElement(it.getNombre()); + } + lstListasRep.setModel(modelo); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstUsuariosValueChanged + + private void lstListasRepValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstListasRepValueChanged + if (evt.getValueIsAdjusting()) return; + if (lstListasRep.getSelectedIndex()<0) return; + + + try { + + DtListaDeReproduccion dtLista = ListasDeReproducion.get(lstListasRep.getSelectedIndex()); + int IDLista = dtLista.getId(); + Sys.seleccionarListaDeReproduccion(IDLista); + lbCategoria.setText(" " + dtLista.getCategoria()); + lbPrivacidad.setText(" " + dtLista.getPrivacidad().toString()); + if (dtLista.getTipo().toString() == "POR_DEFECTO") { + lbTipo.setText(" " + "POR DEFECTO"); + } + if (dtLista.getTipo().toString() == "PARTICULAR") { + lbTipo.setText(" " + "PARTICULAR"); + } + + Listavideos = Sys.listarVideosDeListaDeReproduccion(); + DefaultListModel modelo = new DefaultListModel(); + for (DtVideo it : Listavideos) { + modelo.addElement(it.getNombre()); + } + lstVideos.setModel(modelo); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + }//GEN-LAST:event_lstListasRepValueChanged + + private void lstVideosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstVideosMouseClicked + if (evt.getClickCount() != 2) return; + if (lstVideos.getSelectedIndex()<0) return; + + int indexSeleccionado = lstVideos.getSelectedIndex(); + int idVideo = Listavideos.get(indexSeleccionado).getId(); + + DtUsuario Usu = Sys.obtenerPropietarioDeVideo(idVideo); + + new frmConsultaVideo(this, true, Usu.getNickname(), idVideo).setVisible(true); + }//GEN-LAST:event_lstVideosMouseClicked + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JLabel jLabel106; + private javax.swing.JLabel jLabel107; + private javax.swing.JLabel jLabel108; + private javax.swing.JLabel jLabel109; + private javax.swing.JLabel jLabel110; + private javax.swing.JLabel jLabel111; + private javax.swing.JPanel jPanel20; + private javax.swing.JScrollPane jScrollPane37; + private javax.swing.JScrollPane jScrollPane38; + private javax.swing.JScrollPane jScrollPane39; + private javax.swing.JLabel lbCategoria; + private javax.swing.JLabel lbPrivacidad; + private javax.swing.JLabel lbTipo; + private javax.swing.JList<String> lstListasRep; + private javax.swing.JList<String> lstUsuarios; + private javax.swing.JList<String> lstVideos; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.form b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.form new file mode 100644 index 0000000000000000000000000000000000000000..74ed9c1302a20b7cf15d6fc7f299d00fb5913d44 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.form @@ -0,0 +1,181 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Consultar lista de reproduccion"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel20" min="-2" pref="333" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel20" min="-2" pref="450" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel20"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="20" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnAceptarMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="370" width="290" height="60"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane38"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="140" width="290" height="210"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideos"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Doble clic para ver mas informacion de video"/> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel108"> + <Properties> + <Property name="text" type="java.lang.String" value="Categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="80" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel109"> + <Properties> + <Property name="text" type="java.lang.String" value="Privacidad:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="60" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel110"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel111"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Videos de la lista:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="110" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbTipo"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="40" width="210" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCategoria"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="80" width="210" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbPrivacidad"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="60" width="210" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel112"> + <Properties> + <Property name="text" type="java.lang.String" value="Tipo:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="40" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbNombre"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="20" width="210" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.java b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.java new file mode 100644 index 0000000000000000000000000000000000000000..9e98ff9d5fadee327819a2a98d721a52b7f78da5 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmConsultaListaDeReproduccionEliminada.java @@ -0,0 +1,151 @@ +package Presentacion.ListaDeReproduccion; + +import Logica.DataType.*; +import Logica.Enumerados.TipoListaDeReproduccion; +import Logica.Enumerados.TipoValoracion; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import Presentacion.Video.frmConsultaVideo; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmConsultaListaDeReproduccionEliminada extends javax.swing.JDialog { + + Fabrica f = Fabrica.getInstancia(); + IAdmin Sys = f.getIAdmin(); + ArrayList<DtVideo> Listavideos; + + public frmConsultaListaDeReproduccionEliminada(javax.swing.JDialog parent, boolean modal, int idLista) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + + try { + // obtiene los datos de la lista a mostrar + DtListaDeReproduccion dtLista = Sys.seleccionarListaDeReproduccion(idLista); + ArrayList<DtVideo> listaVideos = Sys.listarVideosDeListaDeReproduccion(); + + // Lista los videos que contiene la lista de reproduccion + DefaultListModel modeloUsuario = new DefaultListModel(); + for (DtVideo it : listaVideos) { + modeloUsuario.addElement(it.getNombre()); + } + lstVideos.setModel(modeloUsuario); + + // carga los datos de la lista en los labels + lbNombre.setText(dtLista.getNombre()); + lbCategoria.setText(dtLista.getCategoria()); + lbPrivacidad.setText(dtLista.getPrivacidad().toString()); + if (dtLista.getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { + lbTipo.setText("POR DEFECTO"); + } + if (dtLista.getTipo() == TipoListaDeReproduccion.PARTICULAR) { + lbTipo.setText("PARTICULAR"); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + + } + + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel20 = new javax.swing.JPanel(); + btnAceptar = new javax.swing.JButton(); + jScrollPane38 = new javax.swing.JScrollPane(); + lstVideos = new javax.swing.JList<>(); + jLabel108 = new javax.swing.JLabel(); + jLabel109 = new javax.swing.JLabel(); + jLabel110 = new javax.swing.JLabel(); + jLabel111 = new javax.swing.JLabel(); + lbTipo = new javax.swing.JLabel(); + lbCategoria = new javax.swing.JLabel(); + lbPrivacidad = new javax.swing.JLabel(); + jLabel112 = new javax.swing.JLabel(); + lbNombre = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Consultar lista de reproduccion"); + setResizable(false); + + jPanel20.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + btnAceptarMouseClicked(evt); + } + }); + jPanel20.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 370, 290, 60)); + + lstVideos.setToolTipText("Doble clic para ver mas informacion de video"); + jScrollPane38.setViewportView(lstVideos); + + jPanel20.add(jScrollPane38, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 140, 290, 210)); + + jLabel108.setText("CategorÃa:"); + jPanel20.add(jLabel108, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 80, -1, -1)); + + jLabel109.setText("Privacidad:"); + jPanel20.add(jLabel109, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 60, -1, -1)); + + jLabel110.setText("Nombre:"); + jPanel20.add(jLabel110, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1)); + + jLabel111.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel111.setText("Videos de la lista:"); + jPanel20.add(jLabel111, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 110, -1, -1)); + + lbTipo.setText(" "); + jPanel20.add(lbTipo, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 40, 210, -1)); + + lbCategoria.setText(" "); + jPanel20.add(lbCategoria, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 80, 210, -1)); + + lbPrivacidad.setText(" "); + jPanel20.add(lbPrivacidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 60, 210, -1)); + + jLabel112.setText("Tipo:"); + jPanel20.add(jLabel112, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, -1, -1)); + + lbNombre.setText(" "); + jPanel20.add(lbNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 20, 210, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAceptarMouseClicked + dispose(); + }//GEN-LAST:event_btnAceptarMouseClicked + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JLabel jLabel108; + private javax.swing.JLabel jLabel109; + private javax.swing.JLabel jLabel110; + private javax.swing.JLabel jLabel111; + private javax.swing.JLabel jLabel112; + private javax.swing.JPanel jPanel20; + private javax.swing.JScrollPane jScrollPane38; + private javax.swing.JLabel lbCategoria; + private javax.swing.JLabel lbNombre; + private javax.swing.JLabel lbPrivacidad; + private javax.swing.JLabel lbTipo; + private javax.swing.JList<String> lstVideos; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.form b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.form new file mode 100644 index 0000000000000000000000000000000000000000..52f6cf289c1676b260f6a3384622e6c00395feb7 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.form @@ -0,0 +1,246 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="rbGrupo"> + </Component> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Modificar lista de reproduccion"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="810" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel19" min="-2" pref="810" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="430" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel19" min="-2" pref="430" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel19"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane33"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="50" width="240" height="270"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarios"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel103"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane34"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="50" width="240" height="270"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstCategorias"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel104"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbPrivada"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="rbGrupo"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Privada"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="410" y="340" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbPublica"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="rbGrupo"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Pública"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="340" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="350" width="240" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="350" width="240" height="50"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane35"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="280" y="50" width="250" height="270"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListasRep"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstListasRepValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel106"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="List. Reproducción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="280" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.java b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.java new file mode 100644 index 0000000000000000000000000000000000000000..19c425b56aabf187b0a4c13264b4d8edba2560a4 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmModificarListaDeReproduccion.java @@ -0,0 +1,343 @@ +package Presentacion.ListaDeReproduccion; + +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtUsuario; +import Logica.Enumerados.Privacidad; +import Logica.Enumerados.TipoListaDeReproduccion; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmModificarListaDeReproduccion extends javax.swing.JDialog { + + IAdmin sys; + ArrayList<DtListaDeReproduccion> listaDeListas; + boolean liberarMemoria; + + public frmModificarListaDeReproduccion(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + liberarMemoria = true; + try { + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // lista usuarios y categorias en JList + mostrarListaDeUsuarios(sys.listarUsuarios()); + mostrarListaDeCategorias(sys.listarCategorias()); + limpiarElementosDeVentana(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + } + + public frmModificarListaDeReproduccion(javax.swing.JDialog parent, boolean modal, String nickname) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + liberarMemoria = false; + try { + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // Limpio la ventana + limpiarElementosDeVentana(); + + // lista usuarios y categorias en JList + mostrarListaDeUsuarios(sys.listarUsuarios()); + mostrarListaDeCategorias(sys.listarCategorias()); + // Selecciono el usuario en la lista de usuarios + lstUsuarios.setSelectedValue(nickname, true); + // deshabilito la lista de usuarios para que no lo cambien + lstUsuarios.setEnabled(false); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + rbGrupo = new javax.swing.ButtonGroup(); + jPanel19 = new javax.swing.JPanel(); + jScrollPane33 = new javax.swing.JScrollPane(); + lstUsuarios = new javax.swing.JList<>(); + jLabel103 = new javax.swing.JLabel(); + jScrollPane34 = new javax.swing.JScrollPane(); + lstCategorias = new javax.swing.JList<>(); + jLabel104 = new javax.swing.JLabel(); + rbPrivada = new javax.swing.JRadioButton(); + rbPublica = new javax.swing.JRadioButton(); + btnCancelar = new javax.swing.JButton(); + btnAceptar = new javax.swing.JButton(); + jScrollPane35 = new javax.swing.JScrollPane(); + lstListasRep = new javax.swing.JList<>(); + jLabel106 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Modificar lista de reproduccion"); + setResizable(false); + + jPanel19.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + lstUsuarios.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosValueChanged(evt); + } + }); + jScrollPane33.setViewportView(lstUsuarios); + + jPanel19.add(jScrollPane33, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 50, 240, 270)); + + jLabel103.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel103.setText("Usuarios:"); + jPanel19.add(jLabel103, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1)); + + jScrollPane34.setViewportView(lstCategorias); + + jPanel19.add(jScrollPane34, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 50, 240, 270)); + + jLabel104.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel104.setText("CategorÃa:"); + jPanel19.add(jLabel104, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 20, -1, -1)); + + rbGrupo.add(rbPrivada); + rbPrivada.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + rbPrivada.setText("Privada"); + jPanel19.add(rbPrivada, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 340, -1, -1)); + + rbGrupo.add(rbPublica); + rbPublica.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + rbPublica.setText("Pública"); + jPanel19.add(rbPublica, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 340, -1, -1)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + jPanel19.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 350, 240, 50)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel19.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 350, 240, 50)); + + lstListasRep.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstListasRepValueChanged(evt); + } + }); + jScrollPane35.setViewportView(lstListasRep); + + jPanel19.add(jScrollPane35, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 50, 250, 270)); + + jLabel106.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel106.setText("List. Reproducción:"); + jPanel19.add(jLabel106, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 20, -1, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 810, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, 810, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 430, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, 430, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + // Boton Cancelar + try { + if (liberarMemoria) { + sys.liberarMemoriaUsuario(); + } + sys.liberarMemoriaListaDeReproduccion(); + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnCancelarActionPerformed + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + // Boton Aceptar + try { + // si se puso como publico pero el canal es privado, muestra error + if (rbPublica.isSelected() && sys.obtenerCanalDeUsuario().getPrivacidad() == Privacidad.PRIVADO) { + JOptionPane.showMessageDialog(null, "Un canal privado no puede tener listas de reproduccion públicas", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + + // obtiene los datos para llenar el DataType y lo crea con ellos + int idLista; + String nuevoNombre = ""; + Privacidad nuevaPrivacidad; + String nuevaCat; + + idLista = listaDeListas.get(lstListasRep.getSelectedIndex()).getId(); + nuevoNombre = listaDeListas.get(lstListasRep.getSelectedIndex()).getNombre(); + + if (rbPublica.isSelected()){ + nuevaPrivacidad = Privacidad.PUBLICO; + }else{ + nuevaPrivacidad = Privacidad.PRIVADO; + } + nuevaCat = lstCategorias.getSelectedValue(); + + + DtListaDeReproduccion nuevosDatos = new DtListaDeReproduccion( + idLista, nuevoNombre, nuevaPrivacidad, TipoListaDeReproduccion.PARTICULAR, nuevaCat + ); + + sys.modificarListaDeReproduccion(nuevosDatos); + + if (liberarMemoria) { + sys.liberarMemoriaUsuario(); + } + sys.liberarMemoriaListaDeReproduccion(); + + JOptionPane.showMessageDialog(null, "Datos modificados correctamente", "OK", JOptionPane.INFORMATION_MESSAGE); + + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnAceptarActionPerformed + + private void lstUsuariosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosValueChanged + // seleccionar usuario + if (evt.getValueIsAdjusting()) return; + if (lstUsuarios.getSelectedIndex()<0) return; + try { + limpiarElementosDeVentana(); + + String nick = lstUsuarios.getSelectedValue(); + sys.seleccionarUsuario(nick); + listaDeListas = sys.listarListasDeReproduccionParticularesDeUsuario(); + mostrarListaDeListasRep(listaDeListas); + //limpiarElementosDeVentana(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstUsuariosValueChanged + + private void lstListasRepValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstListasRepValueChanged + // Al seleccionar una Lista de reproduccion + if (evt.getValueIsAdjusting()) return; + if (lstListasRep.getSelectedIndex()<0) return; + try { + int indexSeleccionado = lstListasRep.getSelectedIndex(); + int idLista = listaDeListas.get(indexSeleccionado).getId(); + DtListaDeReproduccion dtl = sys.seleccionarListaDeReproduccion(idLista); + mostrarDatosDeListaRep(dtl); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstListasRepValueChanged + + /////////////////////////////////////////////////////////////////////////////////////////// + private void mostrarListaDeUsuarios(ArrayList<DtUsuario> ListaUsuarios){ + DefaultListModel modelo = new DefaultListModel(); + ListaUsuarios.forEach((it) -> { + modelo.addElement(it.getNickname()); + // a que te dejo re loco este for + }); + lstUsuarios.setModel(modelo); + + } + private void mostrarListaDeCategorias(ArrayList<String> l){ + DefaultListModel modelo = new DefaultListModel(); + l.forEach((it) -> { + modelo.addElement(it); + // a que te dejo re loco este for + }); + lstCategorias.setModel(modelo); + } + private void mostrarListaDeListasRep(ArrayList<DtListaDeReproduccion> l){ + DefaultListModel modelo = new DefaultListModel(); + for (DtListaDeReproduccion it : l) { + modelo.addElement(it.getNombre()); + } + lstListasRep.setModel(modelo); + } + private void mostrarDatosDeListaRep(DtListaDeReproduccion dtl) { + rbPublica.setEnabled(true); + rbPrivada.setEnabled(true); + + if (dtl.getPrivacidad() == Privacidad.PUBLICO) { + rbPublica.setSelected(true); + rbPrivada.setSelected(false); + } else { + rbPublica.setSelected(false); + rbPrivada.setSelected(true); + } + lstCategorias.setEnabled(true); + lstCategorias.setSelectedValue(dtl.getCategoria(), true); + btnAceptar.setEnabled(true); + } + private void limpiarElementosDeVentana(){ + // limpieza de radiobuttoms + rbGrupo.clearSelection(); + rbPublica.setEnabled(false); + rbPrivada.setEnabled(false); + + // limpieza de listas + lstListasRep.setModel(new DefaultListModel()); + + // desseleccionado de listas + lstCategorias.clearSelection(); + lstCategorias.setEnabled(false); + btnAceptar.setEnabled(false); + } + + /////////////////////////////////////////////////////////////////////////////////////////// + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JButton btnCancelar; + private javax.swing.JLabel jLabel103; + private javax.swing.JLabel jLabel104; + private javax.swing.JLabel jLabel106; + private javax.swing.JPanel jPanel19; + private javax.swing.JScrollPane jScrollPane33; + private javax.swing.JScrollPane jScrollPane34; + private javax.swing.JScrollPane jScrollPane35; + private javax.swing.JList<String> lstCategorias; + private javax.swing.JList<String> lstListasRep; + private javax.swing.JList<String> lstUsuarios; + private javax.swing.ButtonGroup rbGrupo; + private javax.swing.JRadioButton rbPrivada; + private javax.swing.JRadioButton rbPublica; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.form b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.form new file mode 100644 index 0000000000000000000000000000000000000000..ad46cb510db6e0f2b78d6864ed63553127946b05 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.form @@ -0,0 +1,223 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Quitar video de lista de reproduccion"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="790" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel22" min="-2" pref="790" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="410" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel22" min="-2" pref="410" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel22"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel118"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane43"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="30" width="180" height="300"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarios"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="350" width="180" height="40"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel119"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Videos:"/> + <Property name="toolTipText" type="java.lang.String" value=""/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="440" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane44"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="30" width="200" height="300"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListasRep"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstListasRepValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel120"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Listas de Reproducción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane45"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="440" y="30" width="320" height="300"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideos"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstVideosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnQuitar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Quitar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuitarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="440" y="350" width="320" height="40"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.java b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.java new file mode 100644 index 0000000000000000000000000000000000000000..dfd892946c2003eff53d5d549f47f76edd054737 --- /dev/null +++ b/UyTube_logica/src/Presentacion/ListaDeReproduccion/frmQuitarVideoDeListaDeReproduccion.java @@ -0,0 +1,282 @@ +package Presentacion.ListaDeReproduccion; + +import Logica.Fabrica; +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtUsuario; +import Logica.DataType.DtVideo; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmQuitarVideoDeListaDeReproduccion extends javax.swing.JDialog { + + private ArrayList<Integer> indexListRes = new ArrayList(); + private ArrayList<Integer> indexVideos = new ArrayList(); + IAdmin sys; + private String usrSeleccionado = "", nombreVideo=""; + private int idVideo, idListaRep; + + public frmQuitarVideoDeListaDeReproduccion(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + try { + sys = Fabrica.getInstancia().getIAdmin(); + cargarListaUsuarios();// Carga los usuarios al abrir el formulario + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + private void limpiarLstVideos(){ + DefaultListModel modelo = new DefaultListModel(); + lstVideos.setModel(modelo); + indexVideos.clear(); + } + + private void cargarListaUsuarios(){ + DefaultListModel modelo = new DefaultListModel(); + try { + if(!sys.listarUsuarios().isEmpty()){ + for(DtUsuario elem: sys.listarUsuarios()){ + modelo.addElement(elem.getNickname()); + } + lstUsuarios.setModel(modelo); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + + } + + private void cargarListaReproducion(ArrayList<DtListaDeReproduccion> dts){ + indexListRes.clear(); + DefaultListModel modelo = new DefaultListModel(); + if(!dts.isEmpty()){ + for (DtListaDeReproduccion elem : dts) { + modelo.addElement(elem.getNombre()); + indexListRes.add(elem.getId());//guarda todos los id en la misma posicion que el modelo + } + lstListasRep.setModel(modelo); + } + limpiarLstVideos(); + } + + private void cargarListaVideos(){ + indexVideos.clear(); + DefaultListModel modelo = new DefaultListModel(); + try { + for (DtVideo elem : sys.listarVideosDeListaDeReproduccion()) { + modelo.addElement(elem.getNombre()); + indexVideos.add(elem.getId());//guarda todos los id en la misma posicion que el modelo + } + lstVideos.setModel(modelo); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel22 = new javax.swing.JPanel(); + jLabel118 = new javax.swing.JLabel(); + jScrollPane43 = new javax.swing.JScrollPane(); + lstUsuarios = new javax.swing.JList<>(); + btnCancelar = new javax.swing.JButton(); + jLabel119 = new javax.swing.JLabel(); + jScrollPane44 = new javax.swing.JScrollPane(); + lstListasRep = new javax.swing.JList<>(); + jLabel120 = new javax.swing.JLabel(); + jScrollPane45 = new javax.swing.JScrollPane(); + lstVideos = new javax.swing.JList<>(); + btnQuitar = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Quitar video de lista de reproduccion"); + setResizable(false); + + jPanel22.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel118.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel118.setText("Usuarios:"); + jPanel22.add(jLabel118, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1)); + + lstUsuarios.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + lstUsuarios.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosValueChanged(evt); + } + }); + jScrollPane43.setViewportView(lstUsuarios); + + jPanel22.add(jScrollPane43, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, 180, 300)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + jPanel22.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 350, 180, 40)); + + jLabel119.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel119.setText("Videos:"); + jLabel119.setToolTipText(""); + jPanel22.add(jLabel119, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 10, -1, -1)); + + lstListasRep.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + lstListasRep.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstListasRepValueChanged(evt); + } + }); + jScrollPane44.setViewportView(lstListasRep); + + jPanel22.add(jScrollPane44, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 30, 200, 300)); + + jLabel120.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel120.setText("Listas de Reproducción:"); + jPanel22.add(jLabel120, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 10, -1, -1)); + + lstVideos.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + lstVideos.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstVideosValueChanged(evt); + } + }); + jScrollPane45.setViewportView(lstVideos); + + jPanel22.add(jScrollPane45, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 30, 320, 300)); + + btnQuitar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnQuitar.setText("Quitar"); + btnQuitar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnQuitarActionPerformed(evt); + } + }); + jPanel22.add(btnQuitar, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 350, 320, 40)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 790, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, 790, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 410, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + //listaRep->quitarVideo->cancelar + try { + sys.liberarMemoriaUsuario(); + sys.liberarMemoriaListaDeReproduccion(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + }finally{ + dispose(); + } + }//GEN-LAST:event_btnCancelarActionPerformed + + private void btnQuitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarActionPerformed + if (lstUsuarios.getSelectedIndex() < 0) { + JOptionPane.showMessageDialog(null, "Debe seleccionar un usuario", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + if (lstListasRep.getSelectedIndex() < 0) { + JOptionPane.showMessageDialog(null, "Debe seleccionar una lista de reproducción", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + if (lstVideos.getSelectedIndex() < 0) { + JOptionPane.showMessageDialog(null, "Debe seleccionar un video", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + + try { + int opcion = JOptionPane.showConfirmDialog(null, + "¿Realmente desea quitar de la lista el video: \"" + nombreVideo + "\"?", + "Confirmar quitar Video", + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (opcion == 0) { + sys.quitarVideoDeListaDeReproduccion(idVideo);//Elimina el video de la lista de reproduccion + cargarListaVideos(); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnQuitarActionPerformed + + private void lstUsuariosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosValueChanged + + if (evt.getValueIsAdjusting()) return; + if (lstUsuarios.getSelectedIndex()<0) return; + usrSeleccionado = lstUsuarios.getSelectedValue(); // El sistema selecciona al usuario actual con el nickname seleccionado de la lista + try { + sys.seleccionarUsuario(usrSeleccionado); //Selecciona el usuarioSeleccionado + ArrayList<DtListaDeReproduccion> dtListRep = sys.listarListasDeReproduccionDeUsuario(usrSeleccionado); + cargarListaReproducion(dtListRep); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstUsuariosValueChanged + + private void lstListasRepValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstListasRepValueChanged + if (evt.getValueIsAdjusting()) return; + if (lstListasRep.getSelectedIndex()<0) return; + try { + idListaRep=indexListRes.get(lstListasRep.getSelectedIndex()); + DtListaDeReproduccion dt = sys.seleccionarListaDeReproduccion(idListaRep);//Selecciona la lista de reproduccion + cargarListaVideos(); //Carga los videos de la lista seleccionada + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstListasRepValueChanged + + private void lstVideosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstVideosValueChanged + if (evt.getValueIsAdjusting()) return; + if (lstVideos.getSelectedIndex()<0) return; + idVideo = indexVideos.get(lstVideos.getSelectedIndex()); + nombreVideo = lstVideos.getSelectedValue(); + }//GEN-LAST:event_lstVideosValueChanged + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancelar; + private javax.swing.JButton btnQuitar; + private javax.swing.JLabel jLabel118; + private javax.swing.JLabel jLabel119; + private javax.swing.JLabel jLabel120; + private javax.swing.JPanel jPanel22; + private javax.swing.JScrollPane jScrollPane43; + private javax.swing.JScrollPane jScrollPane44; + private javax.swing.JScrollPane jScrollPane45; + private javax.swing.JList<String> lstListasRep; + private javax.swing.JList<String> lstUsuarios; + private javax.swing.JList<String> lstVideos; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Usuario/frmAltaUsuario.form b/UyTube_logica/src/Presentacion/Usuario/frmAltaUsuario.form new file mode 100644 index 0000000000000000000000000000000000000000..147db8cc008ce08ce9336b7c5d6135680bee41aa --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmAltaUsuario.form @@ -0,0 +1,463 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="GrupoPrivacidad"> + </Component> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Alta usuario"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/> + <EventHandler event="windowActivated" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowActivated"/> + </Events> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="980" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel2" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="550" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel2" min="-2" pref="550" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="txtNikname"> + <Events> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtNiknameFocusGained"/> + <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtNiknameFocusLost"/> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtNiknameKeyPressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="50" width="270" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtNombre"> + <Events> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtNombreFocusGained"/> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtNombreKeyPressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="90" width="270" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtApellido"> + <Events> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtApellidoFocusGained"/> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtApellidoKeyPressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="130" width="270" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtEmail"> + <Events> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtEmailFocusGained"/> + <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtEmailKeyTyped"/> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtEmailKeyPressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="170" width="300" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btSeleccionar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Selecionar Imágen"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btSeleccionarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="170" y="290" width="200" height="60"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtNombreCanal"> + <Events> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtNombreCanalKeyPressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="540" y="60" width="280" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="540" y="120" width="400" height="190"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtDescripcion"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JRadioButton" name="rdPrivado"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="GrupoPrivacidad"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="text" type="java.lang.String" value="Privado"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="710" y="350" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCargar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value=" Cargar "/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCargarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="580" y="460" width="360" height="60"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="463" width="340" height="60"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" value="Nickname"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="90" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="text" type="java.lang.String" value="Apellido"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="130" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuario"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="text" type="java.lang.String" value="Seleccione la fecha de nacimiento"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="220" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Canal"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="60" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel13"> + <Properties> + <Property name="text" type="java.lang.String" value="Descripción"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="120" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator1"> + <Properties> + <Property name="orientation" type="int" value="1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="420" y="0" width="10" height="560"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel14"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="(Opcional)"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="840" y="60" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rdPublico"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="GrupoPrivacidad"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Público"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="540" y="350" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="30" width="980" height="10"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="text" type="java.lang.String" value="Imágen"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="270" width="-1" height="20"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="pnlImagen"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.BevelBorderInfo"> + <BevelBorder/> + </Border> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlImagenMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="290" width="130" height="130"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lbImg"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="5" width="120" height="120"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel42"> + <Properties> + <Property name="text" type="java.lang.String" value="Email"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="170" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel50"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="(Opcional)"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="270" width="90" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjNikname"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="70" width="270" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjNombre"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="110" width="270" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjApellido"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="150" width="270" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjEmail"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="190" width="300" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjFecha"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="240" width="350" height="15"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnQuitarImagen"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Quitar Imágen"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuitarImagenActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="170" y="360" width="200" height="60"/> + </Constraint> + </Constraints> + </Component> + <Component class="com.toedter.calendar.JDateChooser" name="jDateChooser1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="265" y="220" width="130" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Usuario/frmAltaUsuario.java b/UyTube_logica/src/Presentacion/Usuario/frmAltaUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..f10d56fc834f3a782dbea303dc89cfd06b0ac029 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmAltaUsuario.java @@ -0,0 +1,723 @@ +package Presentacion.Usuario; + +import Logica.DataType.DtCanal; +import Logica.DataType.DtUsuario; +import Logica.Enumerados.Privacidad; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import com.sun.glass.events.KeyEvent; +import java.awt.Color; +import java.awt.Image; +import java.io.File; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.border.Border; +import javax.swing.plaf.ColorUIResource; + + +public class frmAltaUsuario extends javax.swing.JDialog { + + // Patrón para validar el email + Pattern patronEmail = Pattern.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"); + + Pattern patronNombres= Pattern.compile("^([A-Za-zÑñÃáÉéÃÃÓóÚú]+)\\s*([A-Za-zÑñÃáÉéÃÃÓóÚú]+)\\s*" + + "([A-Za-zÑñÃáÉéÃÃÓóÚú]+)$"); + IAdmin sys; + Border bordeDefault; + Color colorOK = new ColorUIResource(40,167,69); + Color colorError = new ColorUIResource(220,53,69); + String nickname = new String(); + String email = new String(); + String nombre = new String(); + String apellido = new String(); + String nombreCanal = new String(); + String descripcion = new String(); + Privacidad privacidad = Privacidad.PRIVADO; + String ruta = ""; + + java.sql.Date fecha = null; + + public frmAltaUsuario(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + sys = Fabrica.getInstancia().getIAdmin(); + bordeDefault = txtNombre.getBorder(); + cargarImagenEnJlabel(lbImg, ""); + } + + private boolean validarFormatoEmail(String _email){ + Matcher mather = patronEmail.matcher(_email); + if (mather.find() == true) { + return true; + } + return false; + } + + private boolean validarNombres(String _nombre){ + Matcher mather = patronNombres.matcher(_nombre); + if (mather.find() == true) { + return true; + } + return false; + } + + private String convertirPrimeraEnMayusculas(String cadena){ + if (cadena.isEmpty()){ + return ""; + } + char[] caracteres = cadena.toCharArray(); + caracteres[0] = Character.toUpperCase(caracteres[0]);//Convierte el primer caracter de la primer palabra + // el -2 es para evitar una excepción al caernos del arreglo + for (int i = 0; i < cadena.length() - 2; i++) { // Es 'palabra' + if (caracteres[i] == ' ' || caracteres[i] == '.' || caracteres[i] == ',') { // Reemplazamos + caracteres[i + 1] = Character.toUpperCase(caracteres[i + 1]); + } + } + return new String(caracteres); + } + + private boolean validarTxt(JTextField txt, int largo,JLabel lb,String nombreCampo){ + try{ + if (txt.getText().isEmpty() || txt.getText().equals("")){ + lb.setText(" El campo "+nombreCampo+" es obligatorio"); + cambiarColoresError(txt, lb); + return false; + } + else if(txt.getText().length() > largo ){ + lb.setText(" El campo supera los "+largo+" caracteres"); + cambiarColoresError(txt, lb); + return false; + } + else if(nombreCampo.equals("Nickname")){ + if (sys.existeNickname(nickname)) { + lb.setText(" El nickname \"" + nickname + "\" ya existe"); + cambiarColoresError(txt, lb); + return false; + } + } + else if(nombreCampo.equals("Nombre") ){ + if(!validarNombres(nombre)){ + lb.setText(" El nombre \"" + nombre + "\" no es válido"); + cambiarColoresError(txt, lb); + return false; + } + } + else if(nombreCampo.equals("Apellido") ){ + if(!validarNombres(apellido)){ + lb.setText(" El apellido \"" + apellido + "\" no es válido"); + cambiarColoresError(txt, lb); + return false; + } + } + else if(nombreCampo.equals("Email")){ + if(!validarFormatoEmail(email)){ + lb.setText(" El Email no es válido"); + cambiarColoresError(txt, lb); + return false; + } + if(sys.existeEmail(email)){ + lb.setText(" El Email ya existe"); + cambiarColoresError(txt, lb); + return false; + } + } + + else{ + txt.setBorder(bordeDefault); + lb.setText(""); + lb.setOpaque(false); + } + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + return true; + } + + private void cambiarColoresError(JTextField txt, JLabel lb){ + lb.setOpaque(true); + lb.setForeground(Color.WHITE); + lb.setBackground(colorError); + txt.setBorder(BorderFactory.createLineBorder(colorError, 1)); + } + + private void limpiarCampos(){ + txtNikname.setText(""); + txtNombre.setText(""); + txtApellido.setText(""); + txtEmail.setText(""); + txtDescripcion.setText(""); + txtNombreCanal.setText(""); + jDateChooser1.setDate(null); + lbImg.setIcon(null); + ruta = ""; + cargarImagenEnJlabel(lbImg, ruta); + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + GrupoPrivacidad = new javax.swing.ButtonGroup(); + jPanel2 = new javax.swing.JPanel(); + txtNikname = new javax.swing.JTextField(); + txtNombre = new javax.swing.JTextField(); + txtApellido = new javax.swing.JTextField(); + txtEmail = new javax.swing.JTextField(); + btSeleccionar = new javax.swing.JButton(); + txtNombreCanal = new javax.swing.JTextField(); + jScrollPane1 = new javax.swing.JScrollPane(); + txtDescripcion = new javax.swing.JTextArea(); + rdPrivado = new javax.swing.JRadioButton(); + btnCargar = new javax.swing.JButton(); + btCancelar = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel13 = new javax.swing.JLabel(); + jSeparator1 = new javax.swing.JSeparator(); + jLabel14 = new javax.swing.JLabel(); + rdPublico = new javax.swing.JRadioButton(); + jSeparator2 = new javax.swing.JSeparator(); + jLabel10 = new javax.swing.JLabel(); + pnlImagen = new javax.swing.JPanel(); + lbImg = new javax.swing.JLabel(); + jLabel42 = new javax.swing.JLabel(); + jLabel50 = new javax.swing.JLabel(); + lbMsjNikname = new javax.swing.JLabel(); + lbMsjNombre = new javax.swing.JLabel(); + lbMsjApellido = new javax.swing.JLabel(); + lbMsjEmail = new javax.swing.JLabel(); + lbMsjFecha = new javax.swing.JLabel(); + btnQuitarImagen = new javax.swing.JButton(); + jDateChooser1 = new com.toedter.calendar.JDateChooser(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Alta usuario"); + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosed(java.awt.event.WindowEvent evt) { + formWindowClosed(evt); + } + public void windowActivated(java.awt.event.WindowEvent evt) { + formWindowActivated(evt); + } + }); + + jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + txtNikname.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + txtNiknameFocusGained(evt); + } + public void focusLost(java.awt.event.FocusEvent evt) { + txtNiknameFocusLost(evt); + } + }); + txtNikname.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtNiknameKeyPressed(evt); + } + }); + jPanel2.add(txtNikname, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 50, 270, -1)); + + txtNombre.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + txtNombreFocusGained(evt); + } + }); + txtNombre.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtNombreKeyPressed(evt); + } + }); + jPanel2.add(txtNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 90, 270, -1)); + + txtApellido.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + txtApellidoFocusGained(evt); + } + }); + txtApellido.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtApellidoKeyPressed(evt); + } + }); + jPanel2.add(txtApellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 130, 270, -1)); + + txtEmail.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + txtEmailFocusGained(evt); + } + }); + txtEmail.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + txtEmailKeyTyped(evt); + } + public void keyPressed(java.awt.event.KeyEvent evt) { + txtEmailKeyPressed(evt); + } + }); + jPanel2.add(txtEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 170, 300, -1)); + + btSeleccionar.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + btSeleccionar.setText("Selecionar Imágen"); + btSeleccionar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btSeleccionarActionPerformed(evt); + } + }); + jPanel2.add(btSeleccionar, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 290, 200, 60)); + + txtNombreCanal.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtNombreCanalKeyPressed(evt); + } + }); + jPanel2.add(txtNombreCanal, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 60, 280, -1)); + + txtDescripcion.setColumns(20); + txtDescripcion.setRows(5); + jScrollPane1.setViewportView(txtDescripcion); + + jPanel2.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 120, 400, 190)); + + GrupoPrivacidad.add(rdPrivado); + rdPrivado.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + rdPrivado.setSelected(true); + rdPrivado.setText("Privado"); + jPanel2.add(rdPrivado, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 350, -1, -1)); + + btnCargar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnCargar.setText(" Cargar "); + btnCargar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCargarActionPerformed(evt); + } + }); + jPanel2.add(btnCargar, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 460, 360, 60)); + + btCancelar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btCancelar.setText("Cancelar"); + btCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btCancelarActionPerformed(evt); + } + }); + jPanel2.add(btCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 463, 340, 60)); + + jLabel1.setText("Nickname"); + jPanel2.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 50, -1, -1)); + + jLabel3.setText("Nombre"); + jPanel2.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 90, -1, -1)); + + jLabel6.setText("Apellido"); + jPanel2.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 130, -1, -1)); + + jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + jLabel8.setText("Usuario"); + jPanel2.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1)); + + jLabel9.setText("Seleccione la fecha de nacimiento"); + jPanel2.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 220, -1, -1)); + + jLabel11.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + jLabel11.setText("Canal"); + jPanel2.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 10, -1, -1)); + + jLabel12.setText("Nombre"); + jPanel2.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 60, -1, -1)); + + jLabel13.setText("Descripción"); + jPanel2.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 120, -1, -1)); + + jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL); + jPanel2.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 0, 10, 560)); + + jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel14.setText("(Opcional)"); + jPanel2.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 60, -1, -1)); + + GrupoPrivacidad.add(rdPublico); + rdPublico.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + rdPublico.setText("Público"); + jPanel2.add(rdPublico, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 350, -1, -1)); + jPanel2.add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 30, 980, 10)); + + jLabel10.setText("Imágen"); + jPanel2.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 270, -1, 20)); + + pnlImagen.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); + pnlImagen.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + pnlImagenMouseClicked(evt); + } + }); + pnlImagen.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + pnlImagen.add(lbImg, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 5, 120, 120)); + + jPanel2.add(pnlImagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 290, 130, 130)); + + jLabel42.setText("Email"); + jPanel2.add(jLabel42, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 170, -1, -1)); + + jLabel50.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel50.setText("(Opcional)"); + jPanel2.add(jLabel50, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 270, 90, -1)); + jPanel2.add(lbMsjNikname, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 70, 270, -1)); + jPanel2.add(lbMsjNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 110, 270, -1)); + jPanel2.add(lbMsjApellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 150, 270, -1)); + jPanel2.add(lbMsjEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 190, 300, -1)); + jPanel2.add(lbMsjFecha, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 240, 350, 15)); + + btnQuitarImagen.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N + btnQuitarImagen.setText("Quitar Imágen"); + btnQuitarImagen.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnQuitarImagenActionPerformed(evt); + } + }); + jPanel2.add(btnQuitarImagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 360, 200, 60)); + jPanel2.add(jDateChooser1, new org.netbeans.lib.awtextra.AbsoluteConstraints(265, 220, 130, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 980, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 550, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 550, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btSeleccionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSeleccionarActionPerformed + //cargarImagen(lbImagen); + String rutaAnterior = ruta; + ruta = seleccionarImagen(); + if (ruta.isEmpty()) { + ruta = rutaAnterior; + } + cargarImagenEnJlabel(lbImg, ruta); + }//GEN-LAST:event_btSeleccionarActionPerformed + + private void cargarImagenEnJlabel(javax.swing.JLabel jLabelx, String Ruta) { + jLabelx.setText(null); + if (Ruta == null || Ruta.isEmpty()){ + Ruta = "Imagenes\\ukp.png"; + } + // Carga la imagen a la variable de tipo Image + Image img = new ImageIcon(Ruta).getImage(); + // Crea un ImageIcon a partir de la imagen (obtiene las dimenciones del jLbel y escala la imagen para que entre en el mismo) + ImageIcon icono = new ImageIcon( + img.getScaledInstance(jLabelx.getWidth(), jLabelx.getHeight(), Image.SCALE_SMOOTH) + ); + // establece la imagen en el label + jLabelx.setIcon(icono); + } + + private String seleccionarImagen() { + // Crea un JFileChooser + JFileChooser JFC = new JFileChooser(); + // crea un filtro para aceptar solo algunas extensiones + FileNameExtensionFilter filtroImagen = new FileNameExtensionFilter("JPG", "JPEG", "PNG", "jpg", "jpeg", "png"); + // Agrega el filtro al JFileChooser + JFC.setFileFilter(filtroImagen); + + // archivo seleccionado + File archivo; + // para saber si se selecciono algo o se cancelo + int resultado; + + while (true) { + // muestra el JFileChooser + resultado = JFC.showOpenDialog(this); + + // Si pasa algo que no sea el aceptar + if (resultado != JFileChooser.APPROVE_OPTION) { + return ""; + } + + // obtiene el archivo seleccionado + archivo = JFC.getSelectedFile(); + + // Si se selecciono algun archivo + if (archivo != null) { + // obtiene la ruta del archivo + String rutaArchivo = archivo.getAbsolutePath(); + // obtiene el archivo como imagen a partir de la ruta + Image img = new ImageIcon(rutaArchivo).getImage(); + + // verifica que tanto se deformará la imagen al mostrarla en un cuadrado + float deformacion; + if (img.getHeight(null) > img.getWidth(null)) { + deformacion = img.getHeight(null) / img.getWidth(null); + } else { + deformacion = img.getWidth(null) / img.getHeight(null); + } + + if (deformacion < 1.3 && deformacion >= 1) { + // si no se deforma demasiado + // devuelve la ruta absoluta + return rutaArchivo; + } else { + // si se deforma demasiado, lo avisa al usuario para que escoja otra + JOptionPane.showMessageDialog(null, + "La imagen es demasiado alta o demasiado ancha.\n" + img.getWidth(null) + "x" + img.getHeight(null), + "Problemas con la imagen", + JOptionPane.WARNING_MESSAGE + ); + } + } else { + // sino devuelve un string vacio + return ""; + } + } + } + + private void btnCargarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCargarActionPerformed + jDateChooser1.setBorder(bordeDefault); + lbMsjFecha.setText(""); + lbMsjFecha.setOpaque(false); + nombre = convertirPrimeraEnMayusculas(txtNombre.getText().trim()); + nickname = txtNikname.getText().trim(); + apellido = convertirPrimeraEnMayusculas(txtApellido.getText().trim()); + email = txtEmail.getText().toLowerCase().trim(); + descripcion = txtDescripcion.getText().trim(); + nombreCanal = txtNombreCanal.getText().trim(); + //Verifica la opcion seleccionada por los radioButton (Privado o Publico) + if(rdPublico.isSelected()){ + privacidad = Privacidad.PUBLICO; + } + //Verifica que la fecha no sea nula + if( jDateChooser1.getDate() != null){ + java.util.Date utilDate = jDateChooser1.getDate();//Obtiene la fecha del JDateChooser en formato Date + fecha = new java.sql.Date(utilDate.getTime());//Lo combierte al tipo Date sql + } + //Arrays para validaciones + JTextField v1[] = {txtNikname,txtNombre,txtApellido,txtEmail}; + int[] v2= {30,30,30,35}; + JLabel[] v3= {lbMsjNikname, lbMsjNombre, lbMsjApellido, lbMsjEmail}; + String[] v4 ={"Nickname","Nombre","Apellido","Email"}; + int[] v5 ={0,0,0,0}; + + for (int i = 0; i < v5.length; i++) { + if (validarTxt(v1[i], v2[i], v3[i], v4[i])) { + v5[i] = 1; + } + } + if (fecha == null) { + jDateChooser1.setBorder(BorderFactory.createLineBorder(colorError, 1)); + lbMsjFecha.setText(" La fecha de nacimiento es obligatoria"); + lbMsjFecha.setOpaque(true); + lbMsjFecha.setForeground(Color.WHITE); + lbMsjFecha.setBackground(colorError); + }else { + java.util.Date hoy = new java.util.Date(); + if (hoy.compareTo(fecha) <= 0){ + jDateChooser1.setBorder(BorderFactory.createLineBorder(colorError, 1)); + lbMsjFecha.setText(" La fecha es posterior a la actual"); + lbMsjFecha.setOpaque(true); + lbMsjFecha.setForeground(Color.WHITE); + lbMsjFecha.setBackground(colorError); + return; + } + } + if(v5[0]==0 || v5[1]==0 || v5[2]==0 || v5[3]==0){ + return; + } + + if(txtNombreCanal.getText().equals("")){ + nombreCanal = nickname; + txtNombreCanal.setText(nickname); + } + + try { + DtUsuario dtUsuario = new DtUsuario(nickname, nickname, nombre, apellido, email, fecha, ruta, 0); + DtCanal dtCanal = new DtCanal(0, nombreCanal, descripcion, privacidad); + sys.altaUsuarioCanal(dtUsuario, dtCanal); + JOptionPane.showMessageDialog(null, "Se ha creado el usuario "+nickname, "Alta de usuario", JOptionPane.INFORMATION_MESSAGE); + limpiarCampos(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnCargarActionPerformed + + private void pnlImagenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlImagenMouseClicked + //cargar imagen en nuevo usuario + //cargarImagen(jLabel34); + }//GEN-LAST:event_pnlImagenMouseClicked + + private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed + //usuario->nuevo usuario->cancelar + limpiarCampos(); + this.setVisible(false); + }//GEN-LAST:event_btCancelarActionPerformed + + private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed + // TODO add your handling code here: + limpiarCampos(); + }//GEN-LAST:event_formWindowClosed + + private void txtNiknameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNiknameKeyPressed + if(evt.getKeyCode() == KeyEvent.VK_ENTER){ + txtNombre.requestFocus(); + } + }//GEN-LAST:event_txtNiknameKeyPressed + + private void txtNiknameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNiknameFocusGained + //Al recibir el foco restaura los valores + txtNikname.setBorder(bordeDefault); + lbMsjNikname.setText(""); + lbMsjNikname.setOpaque(false); + }//GEN-LAST:event_txtNiknameFocusGained + + private void txtEmailFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtEmailFocusGained + //Al recibir el foco restaura los valores + txtEmail.setBorder(bordeDefault); + lbMsjEmail.setText(""); + lbMsjEmail.setOpaque(false); + }//GEN-LAST:event_txtEmailFocusGained + + private void txtEmailKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEmailKeyTyped + // Al presionar enter + if(evt.getKeyChar() == KeyEvent.VK_ENTER){ + jDateChooser1.requestFocus(); + } + }//GEN-LAST:event_txtEmailKeyTyped + + private void txtNombreFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNombreFocusGained + //Al recibir el foco restaura los valores + txtNombre.setBorder(bordeDefault); + lbMsjNombre.setText(""); + lbMsjNombre.setOpaque(false); + }//GEN-LAST:event_txtNombreFocusGained + + private void txtNombreKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreKeyPressed + // TODO add your handling code here: + if(evt.getKeyCode() == KeyEvent.VK_ENTER){ + txtApellido.requestFocus(); + } + }//GEN-LAST:event_txtNombreKeyPressed + + private void txtApellidoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellidoKeyPressed + // TODO add your handling code here: + if(evt.getKeyCode() == KeyEvent.VK_ENTER){ + txtEmail.requestFocus(); + } + }//GEN-LAST:event_txtApellidoKeyPressed + + private void txtEmailKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEmailKeyPressed + // TODO add your handling code here: + if(evt.getKeyCode() == KeyEvent.VK_ENTER){ + jDateChooser1.requestFocus(); + } + }//GEN-LAST:event_txtEmailKeyPressed + + private void txtNombreCanalKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreCanalKeyPressed + // TODO add your handling code here: + if(evt.getKeyCode() == KeyEvent.VK_ENTER){ + txtDescripcion.requestFocus(); + } + }//GEN-LAST:event_txtNombreCanalKeyPressed + + private void txtApellidoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtApellidoFocusGained + //Al recibir el foco restaura los valores + txtApellido.setBorder(bordeDefault); + lbMsjApellido.setText(""); + lbMsjApellido.setOpaque(false); + }//GEN-LAST:event_txtApellidoFocusGained + + private void txtNiknameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNiknameFocusLost + // Al perder el foco + if(txtNombreCanal.getText().equals("")){ + nombreCanal = txtNikname.getText().trim(); + txtNombreCanal.setText(txtNikname.getText().trim()); + } + }//GEN-LAST:event_txtNiknameFocusLost + + private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated + // Fecha actual del sistema + Calendar c = new GregorianCalendar();//Objeto de tipo calendario con la fecha actual + java.util.Date fechaActual = new Date(c.get(Calendar.YEAR)-1900,c.get(Calendar.MONTH),c.get(Calendar.DATE));//Obtiene la fecha actual del calendario + jDateChooser1.setDate(fechaActual);//Setea el JDateChooser con la fecha actual + }//GEN-LAST:event_formWindowActivated + + private void btnQuitarImagenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarImagenActionPerformed + // Quitar imagen + ruta = ""; + cargarImagenEnJlabel(lbImg, ruta); + }//GEN-LAST:event_btnQuitarImagenActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.ButtonGroup GrupoPrivacidad; + private javax.swing.JButton btCancelar; + private javax.swing.JButton btSeleccionar; + private javax.swing.JButton btnCargar; + private javax.swing.JButton btnQuitarImagen; + private com.toedter.calendar.JDateChooser jDateChooser1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel42; + private javax.swing.JLabel jLabel50; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JSeparator jSeparator2; + private javax.swing.JLabel lbImg; + private javax.swing.JLabel lbMsjApellido; + private javax.swing.JLabel lbMsjEmail; + private javax.swing.JLabel lbMsjFecha; + private javax.swing.JLabel lbMsjNikname; + private javax.swing.JLabel lbMsjNombre; + private javax.swing.JPanel pnlImagen; + private javax.swing.JRadioButton rdPrivado; + private javax.swing.JRadioButton rdPublico; + private javax.swing.JTextField txtApellido; + private javax.swing.JTextArea txtDescripcion; + private javax.swing.JTextField txtEmail; + private javax.swing.JTextField txtNikname; + private javax.swing.JTextField txtNombre; + private javax.swing.JTextField txtNombreCanal; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Usuario/frmBajaUsuario.form b/UyTube_logica/src/Presentacion/Usuario/frmBajaUsuario.form new file mode 100644 index 0000000000000000000000000000000000000000..f4ecc9906282d129897bfbab71b64428231a5092 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmBajaUsuario.form @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="lbListarUasario" pref="361" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="lbListarUasario" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="lbListarUasario"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane10"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="30" width="360" height="250"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListaDeUsuario"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstListaDeUsuarioValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel60"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Dar de baja"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnAceptarMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="150" y="290" width="210" height="70"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnCancelarMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="290" width="140" height="70"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Usuario/frmBajaUsuario.java b/UyTube_logica/src/Presentacion/Usuario/frmBajaUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..183a3fc05a3b20a862c2ff03d48615552014c750 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmBajaUsuario.java @@ -0,0 +1,156 @@ +package Presentacion.Usuario; + +import Logica.DataType.DtUsuario; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmBajaUsuario extends javax.swing.JDialog { + + IAdmin sys; + + public frmBajaUsuario(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + btnAceptar.setEnabled(false); + + try { + sys = Fabrica.getInstancia().getIAdmin(); + ArrayList<DtUsuario> ListaUsuarios = sys.listarUsuarios(); + mostrarListaDeUsuarios(ListaUsuarios); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + lbListarUasario = new javax.swing.JPanel(); + jScrollPane10 = new javax.swing.JScrollPane(); + lstListaDeUsuario = new javax.swing.JList<>(); + jLabel60 = new javax.swing.JLabel(); + btnAceptar = new javax.swing.JButton(); + btnCancelar = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + lbListarUasario.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + lstListaDeUsuario.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstListaDeUsuarioValueChanged(evt); + } + }); + jScrollPane10.setViewportView(lstListaDeUsuario); + + lbListarUasario.add(jScrollPane10, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 30, 360, 250)); + + jLabel60.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel60.setText("Usuarios:"); + lbListarUasario.add(jLabel60, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, -1, -1)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N + btnAceptar.setText("Dar de baja"); + btnAceptar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + btnAceptarMouseClicked(evt); + } + }); + lbListarUasario.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 290, 210, 70)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + btnCancelarMouseClicked(evt); + } + }); + lbListarUasario.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 290, 140, 70)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(lbListarUasario, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(lbListarUasario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAceptarMouseClicked + // Clic en boton Dar de baja + if (lstListaDeUsuario.getSelectedIndex() < 0) { + JOptionPane.showMessageDialog(null, "Seleccione un usuario para dar de baja", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + try { + sys.bajaUsuario(); + sys.liberarMemoriaUsuarioActual(); + mostrarListaDeUsuarios(sys.listarUsuarios()); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnAceptarMouseClicked + + private void btnCancelarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarMouseClicked + // Clic en boton Cancelar + try { + sys.liberarMemoriaUsuarioActual(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + dispose(); + }//GEN-LAST:event_btnCancelarMouseClicked + + private void lstListaDeUsuarioValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstListaDeUsuarioValueChanged + // Al seleccionar un usuario de la lista + if (evt.getValueIsAdjusting()) return; + if (lstListaDeUsuario.getSelectedIndex()<0) { + btnAceptar.setEnabled(false); + return; + } + btnAceptar.setEnabled(true); + try { + sys.seleccionarUsuarioActual(lstListaDeUsuario.getSelectedValue()); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstListaDeUsuarioValueChanged + + private void mostrarListaDeUsuarios(ArrayList<DtUsuario> l){ + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : l) { + modelo.addElement(it.getNickname()); + } + lstListaDeUsuario.setModel(modelo); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JButton btnCancelar; + private javax.swing.JLabel jLabel60; + private javax.swing.JScrollPane jScrollPane10; + private javax.swing.JPanel lbListarUasario; + private javax.swing.JList<String> lstListaDeUsuario; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuario.form b/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuario.form new file mode 100644 index 0000000000000000000000000000000000000000..e89cf57532a0e1fa18d190b82050162e0b2d86c5 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuario.form @@ -0,0 +1,521 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Consulta usuario"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel6" min="-2" pref="980" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel6" min="-2" pref="550" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel6"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel17"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seleccione un usuario:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane4"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="60" width="170" height="250"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarios"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel18"> + <Properties> + <Property name="text" type="java.lang.String" value="Usuario:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="60" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel19"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="90" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel20"> + <Properties> + <Property name="text" type="java.lang.String" value="Apellido:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="120" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel21"> + <Properties> + <Property name="text" type="java.lang.String" value="Email:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="150" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel22"> + <Properties> + <Property name="text" type="java.lang.String" value="Nacimiento: "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="180" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel23"> + <Properties> + <Property name="text" type="java.lang.String" value="Imágen:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="210" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="215" width="110" height="110"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lbImagen"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="5" width="100" height="100"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="lbFechaN"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="180" width="200" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbEmail"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="150" width="200" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbApellido"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="120" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbNombre"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="90" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCantSeguidores"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="630" y="20" width="100" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="340" width="530" height="10"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel30"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Canal:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="360" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel32"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Descripción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="420" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane5"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="120" y="430" width="390" height="100"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtDescripcion"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="columns" type="int" value="20"/> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JSeparator" name="jSeparator4"> + <Properties> + <Property name="orientation" type="int" value="1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="0" width="10" height="560"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbPrivacidad"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="110" y="390" width="110" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbNombreCanal"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="110" y="360" width="110" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="230" width="460" height="10"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel39"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seguidores:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel40"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seguidos:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="770" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane8"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="770" y="50" width="180" height="150"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstSeguidos"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane9"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="50" width="190" height="150"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstSeguidores"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="553" y="480" width="410" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel79"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Videos:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="240" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel80"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Listas de Reproducción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="770" y="240" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane20"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="270" width="200" height="190"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideos"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Doble clic para ver mas informacion del video"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lstVideosMouseClicked"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane21"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="770" y="272" width="190" height="190"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListaReproduccion"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Doble clic para ver mas informacion de la lista"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lstListaReproduccionMouseClicked"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="lbNickName"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="60" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCantSeguidos"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="840" y="20" width="100" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel31"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Privacidad:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="390" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuario.java b/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..022a893a1178d7fd88e200d8b642361b9843ea0c --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuario.java @@ -0,0 +1,425 @@ +package Presentacion.Usuario; + +import Presentacion.ListaDeReproduccion.*; +import Logica.DataType.DtCanal; +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtUsuario; +import Logica.DataType.DtVideo; +import Logica.Enumerados.Privacidad; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import Presentacion.Video.frmConsultaVideo; +import java.awt.Image; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JOptionPane; + +public class frmConsultaUsuario extends javax.swing.JDialog { + + IAdmin sys; + ArrayList<DtVideo> listaDeVideos; + ArrayList<DtListaDeReproduccion> listaDeListasRep; + + public frmConsultaUsuario(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + + try { + cargarImagenEnJlabel(lbImagen, ""); + lbImagen.setEnabled(false); + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // lista usuarios en el JList + listarUsuarios(sys.listarUsuarios()); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel6 = new javax.swing.JPanel(); + jLabel17 = new javax.swing.JLabel(); + jScrollPane4 = new javax.swing.JScrollPane(); + lstUsuarios = new javax.swing.JList<>(); + jLabel18 = new javax.swing.JLabel(); + jLabel19 = new javax.swing.JLabel(); + jLabel20 = new javax.swing.JLabel(); + jLabel21 = new javax.swing.JLabel(); + jLabel22 = new javax.swing.JLabel(); + jLabel23 = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + lbImagen = new javax.swing.JLabel(); + lbFechaN = new javax.swing.JLabel(); + lbEmail = new javax.swing.JLabel(); + lbApellido = new javax.swing.JLabel(); + lbNombre = new javax.swing.JLabel(); + lbCantSeguidores = new javax.swing.JLabel(); + jSeparator3 = new javax.swing.JSeparator(); + jLabel30 = new javax.swing.JLabel(); + jLabel32 = new javax.swing.JLabel(); + jScrollPane5 = new javax.swing.JScrollPane(); + txtDescripcion = new javax.swing.JTextArea(); + jSeparator4 = new javax.swing.JSeparator(); + lbPrivacidad = new javax.swing.JLabel(); + lbNombreCanal = new javax.swing.JLabel(); + jSeparator5 = new javax.swing.JSeparator(); + jLabel39 = new javax.swing.JLabel(); + jLabel40 = new javax.swing.JLabel(); + jScrollPane8 = new javax.swing.JScrollPane(); + lstSeguidos = new javax.swing.JList<>(); + jScrollPane9 = new javax.swing.JScrollPane(); + lstSeguidores = new javax.swing.JList<>(); + btnAceptar = new javax.swing.JButton(); + jLabel79 = new javax.swing.JLabel(); + jLabel80 = new javax.swing.JLabel(); + jScrollPane20 = new javax.swing.JScrollPane(); + lstVideos = new javax.swing.JList<>(); + jScrollPane21 = new javax.swing.JScrollPane(); + lstListaReproduccion = new javax.swing.JList<>(); + lbNickName = new javax.swing.JLabel(); + lbCantSeguidos = new javax.swing.JLabel(); + jLabel31 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Consulta usuario"); + setResizable(false); + + jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel17.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel17.setText("Seleccione un usuario:"); + jPanel6.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1)); + + lstUsuarios.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosValueChanged(evt); + } + }); + jScrollPane4.setViewportView(lstUsuarios); + + jPanel6.add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 170, 250)); + + jLabel18.setText("Usuario:"); + jPanel6.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 60, -1, -1)); + + jLabel19.setText("Nombre:"); + jPanel6.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 90, -1, -1)); + + jLabel20.setText("Apellido:"); + jPanel6.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 120, -1, -1)); + + jLabel21.setText("Email:"); + jPanel6.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 150, -1, -1)); + + jLabel22.setText("Nacimiento: "); + jPanel6.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 180, -1, -1)); + + jLabel23.setText("Imágen:"); + jPanel6.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 210, -1, -1)); + + jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + jPanel1.add(lbImagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 5, 100, 100)); + + jPanel6.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 215, 110, 110)); + jPanel6.add(lbFechaN, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 180, 200, 20)); + + lbEmail.setText(" "); + jPanel6.add(lbEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 150, 200, 20)); + + lbApellido.setText(" "); + jPanel6.add(lbApellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 120, 200, -1)); + + lbNombre.setText(" "); + jPanel6.add(lbNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 90, 200, -1)); + + lbCantSeguidores.setText(" "); + jPanel6.add(lbCantSeguidores, new org.netbeans.lib.awtextra.AbsoluteConstraints(630, 20, 100, -1)); + jPanel6.add(jSeparator3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 340, 530, 10)); + + jLabel30.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel30.setText("Canal:"); + jPanel6.add(jLabel30, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 360, -1, -1)); + + jLabel32.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel32.setText("Descripción:"); + jPanel6.add(jLabel32, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 420, -1, -1)); + + txtDescripcion.setEditable(false); + txtDescripcion.setColumns(20); + txtDescripcion.setLineWrap(true); + txtDescripcion.setRows(5); + jScrollPane5.setViewportView(txtDescripcion); + + jPanel6.add(jScrollPane5, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 430, 390, 100)); + + jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL); + jPanel6.add(jSeparator4, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 0, 10, 560)); + + lbPrivacidad.setText(" "); + jPanel6.add(lbPrivacidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 390, 110, -1)); + + lbNombreCanal.setText(" "); + jPanel6.add(lbNombreCanal, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 360, 110, -1)); + jPanel6.add(jSeparator5, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 230, 460, 10)); + + jLabel39.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel39.setText("Seguidores:"); + jPanel6.add(jLabel39, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 20, -1, -1)); + + jLabel40.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel40.setText("Seguidos:"); + jPanel6.add(jLabel40, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 20, -1, -1)); + + jScrollPane8.setViewportView(lstSeguidos); + + jPanel6.add(jScrollPane8, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 50, 180, 150)); + + jScrollPane9.setViewportView(lstSeguidores); + + jPanel6.add(jScrollPane9, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 50, 190, 150)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel6.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(553, 480, 410, 50)); + + jLabel79.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel79.setText("Videos:"); + jPanel6.add(jLabel79, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 240, -1, -1)); + + jLabel80.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel80.setText("Listas de Reproducción:"); + jPanel6.add(jLabel80, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 240, -1, -1)); + + lstVideos.setToolTipText("Doble clic para ver mas informacion del video"); + lstVideos.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + lstVideosMouseClicked(evt); + } + }); + jScrollPane20.setViewportView(lstVideos); + + jPanel6.add(jScrollPane20, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 270, 200, 190)); + + lstListaReproduccion.setToolTipText("Doble clic para ver mas informacion de la lista"); + lstListaReproduccion.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + lstListaReproduccionMouseClicked(evt); + } + }); + jScrollPane21.setViewportView(lstListaReproduccion); + + jPanel6.add(jScrollPane21, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 272, 190, 190)); + + lbNickName.setText(" "); + jPanel6.add(lbNickName, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 60, 200, -1)); + + lbCantSeguidos.setText(" "); + jPanel6.add(lbCantSeguidos, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 20, 100, -1)); + + jLabel31.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel31.setText("Privacidad:"); + jPanel6.add(jLabel31, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 390, -1, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 980, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 550, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void lstUsuariosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosValueChanged + // Al seleccionar un usuario + if (evt.getValueIsAdjusting()) return; + if (lstUsuarios.getSelectedIndex()<0) return; + + try { + String nick = lstUsuarios.getSelectedValue(); + DtUsuario dtu = sys.seleccionarUsuario(nick); + cargarLabelsConDatosDelUsuario(dtu); + DtCanal dtc = sys.obtenerCanalDeUsuario(); + cargarLabelsConDatosDelCanal(dtc); + + listaDeVideos = sys.listarVideosDeUsuario(); + listarVideos(listaDeVideos); + listaDeListasRep = sys.listarListasDeReproduccionDeUsuario(nick); + listarListassRep(listaDeListasRep); + listarUsuariosSeguidores(sys.listarUsuarioSeguidores()); + listarUsuariosSeguidos(sys.listarUsuarioSeguidos()); + + sys.liberarMemoriaUsuario(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + + } + }//GEN-LAST:event_lstUsuariosValueChanged + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + try { + sys.liberarMemoriaUsuario(); + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnAceptarActionPerformed + + private void lstVideosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstVideosMouseClicked + // Doble clic en la lista de videos + if (evt.getClickCount() != 2) return; + if (lstVideos.getSelectedIndex()<0) return; + + int indexSeleccionado = lstVideos.getSelectedIndex(); + int idVideo = listaDeVideos.get(indexSeleccionado).getId(); + new frmConsultaVideo(this, true, lstUsuarios.getSelectedValue(), idVideo).setVisible(true); + }//GEN-LAST:event_lstVideosMouseClicked + + private void lstListaReproduccionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstListaReproduccionMouseClicked + // Doble clic en la lista de Listas de reproduccion + if (evt.getClickCount() != 2) return; + if (lstListaReproduccion.getSelectedIndex()<0) return; + + int indexSeleccionado = lstListaReproduccion.getSelectedIndex(); + int idLista = listaDeListasRep.get(indexSeleccionado).getId(); + new frmConsultaListaDeReproduccion(this, true, lstUsuarios.getSelectedValue(), idLista).setVisible(true); + }//GEN-LAST:event_lstListaReproduccionMouseClicked + + /////////////////////////////////////////////////////////////////////////////////////////// + private void listarUsuarios(ArrayList<DtUsuario> ListaUsuarios){ + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + } + lstUsuarios.setModel(modelo); + + } + private void listarVideos(ArrayList<DtVideo> ListaVideos){ + DefaultListModel modelo = new DefaultListModel(); + for (DtVideo it : ListaVideos) { + modelo.addElement(it.getNombre()); + } + lstVideos.setModel(modelo); + } + private void listarListassRep(ArrayList<DtListaDeReproduccion> listaListasRep){ + DefaultListModel modelo = new DefaultListModel(); + for (DtListaDeReproduccion it : listaListasRep) { + modelo.addElement(it.getNombre()); + } + lstListaReproduccion.setModel(modelo); + } + + private void listarUsuariosSeguidos(ArrayList<DtUsuario> ListaUsuarios){ + lbCantSeguidos.setText(String.valueOf(ListaUsuarios.size())); + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + } + lstSeguidos.setModel(modelo); + } + private void listarUsuariosSeguidores(ArrayList<DtUsuario> ListaUsuarios){ + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + } + lstSeguidores.setModel(modelo); + } + private void cargarLabelsConDatosDelUsuario(DtUsuario u){ + lbNickName.setText(u.getNickname()); + lbNombre.setText(u.getNombre()); + lbApellido.setText(u.getApellido()); + lbEmail.setText(u.getCorreo()); + lbFechaN.setText(new SimpleDateFormat("dd-MM-yyyy").format(u.getFechaNacimiento())); + lbCantSeguidores.setText(String.valueOf(u.getCantSeguidores())); + cargarImagenEnJlabel(lbImagen, u.getImagen()); + lbImagen.setEnabled(true); + } + private void cargarLabelsConDatosDelCanal(DtCanal c){ + lbNombreCanal.setText(c.getNombre()); + txtDescripcion.setText(c.getDescripcion()); + if (c.getPrivacidad() == Privacidad.PUBLICO){ + lbPrivacidad.setText("Publico"); + }else{ + lbPrivacidad.setText("Privado"); + } + } + private void cargarImagenEnJlabel(javax.swing.JLabel jLabelx, String Ruta){ + jLabelx.setText(null); + if (Ruta == null || Ruta.isEmpty()){ + Ruta = "Imagenes\\ukp.png"; + } + // Carga la imagen a la variable de tipo Image + Image img = new ImageIcon(Ruta).getImage(); + // Crea un ImageIcon a partir de la imagen (obtiene las dimenciones del jLbel y escala la imagen para que entre en el mismo) + ImageIcon icono = new ImageIcon( + img.getScaledInstance(jLabelx.getWidth(), jLabelx.getHeight(), Image.SCALE_SMOOTH) + ); + // establece la imagen en el label + jLabelx.setIcon(icono); + } + /////////////////////////////////////////////////////////////////////////////////////////// + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel30; + private javax.swing.JLabel jLabel31; + private javax.swing.JLabel jLabel32; + private javax.swing.JLabel jLabel39; + private javax.swing.JLabel jLabel40; + private javax.swing.JLabel jLabel79; + private javax.swing.JLabel jLabel80; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel6; + private javax.swing.JScrollPane jScrollPane20; + private javax.swing.JScrollPane jScrollPane21; + private javax.swing.JScrollPane jScrollPane4; + private javax.swing.JScrollPane jScrollPane5; + private javax.swing.JScrollPane jScrollPane8; + private javax.swing.JScrollPane jScrollPane9; + private javax.swing.JSeparator jSeparator3; + private javax.swing.JSeparator jSeparator4; + private javax.swing.JSeparator jSeparator5; + private javax.swing.JLabel lbApellido; + private javax.swing.JLabel lbCantSeguidores; + private javax.swing.JLabel lbCantSeguidos; + private javax.swing.JLabel lbEmail; + private javax.swing.JLabel lbFechaN; + private javax.swing.JLabel lbImagen; + private javax.swing.JLabel lbNickName; + private javax.swing.JLabel lbNombre; + private javax.swing.JLabel lbNombreCanal; + private javax.swing.JLabel lbPrivacidad; + private javax.swing.JList<String> lstListaReproduccion; + private javax.swing.JList<String> lstSeguidores; + private javax.swing.JList<String> lstSeguidos; + private javax.swing.JList<String> lstUsuarios; + private javax.swing.JList<String> lstVideos; + private javax.swing.JTextArea txtDescripcion; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.form b/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.form new file mode 100644 index 0000000000000000000000000000000000000000..4a5df94b479f305573fc88b6f7a1b8e7e27c502f --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.form @@ -0,0 +1,435 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel6" min="-2" pref="980" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel6" alignment="0" pref="579" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel6"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel17"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seleccione un usuario:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane4"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="60" width="170" height="250"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarios"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel18"> + <Properties> + <Property name="text" type="java.lang.String" value="Usuario:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="60" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel19"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="90" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel20"> + <Properties> + <Property name="text" type="java.lang.String" value="Apellido:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="120" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel21"> + <Properties> + <Property name="text" type="java.lang.String" value="Email:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="150" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel22"> + <Properties> + <Property name="text" type="java.lang.String" value="Baja:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="210" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel23"> + <Properties> + <Property name="text" type="java.lang.String" value="Imágen:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="240" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="240" width="110" height="110"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lbImagen"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="5" width="100" height="100"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="lbFechaN"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="180" width="200" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbEmail"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="150" width="200" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbApellido"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="120" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbNombre"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="90" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="370" width="530" height="10"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel30"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Canal:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="390" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel32"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Descripción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="450" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane5"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="120" y="460" width="390" height="100"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtDescripcion"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="columns" type="int" value="20"/> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JSeparator" name="jSeparator4"> + <Properties> + <Property name="orientation" type="int" value="1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="0" width="10" height="580"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbPrivacidad"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="110" y="420" width="390" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbNombreCanal"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="110" y="390" width="390" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="480" width="410" height="70"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel79"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Videos:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="30" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel80"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Listas de Reproducción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="250" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane20"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="60" width="410" height="160"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideos"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Doble clic para ver mas informacion del video"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lstVideosMouseClicked"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane21"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="280" width="400" height="160"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListaReproduccion"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Doble clic para ver mas informacion de la lista"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lstListaReproduccionMouseClicked"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="lbNickName"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="60" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel31"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Privacidad:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="420" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel24"> + <Properties> + <Property name="text" type="java.lang.String" value="Nacimiento: "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="220" y="180" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbFechaElim"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="300" y="210" width="200" height="20"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.java b/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.java new file mode 100644 index 0000000000000000000000000000000000000000..bfb489830e76fb20f4a35db4843c21063152e006 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmConsultaUsuarioEliminado.java @@ -0,0 +1,372 @@ +package Presentacion.Usuario; + +import Logica.DataType.DtCanal; +import Logica.DataType.DtListaDeReproduccion; +import Logica.DataType.DtUsuario; +import Logica.DataType.DtVideo; +import Logica.Enumerados.Privacidad; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import Presentacion.ListaDeReproduccion.frmConsultaListaDeReproduccion; +import Presentacion.ListaDeReproduccion.frmConsultaListaDeReproduccionEliminada; +import Presentacion.Video.frmConsultaVideo; +import Presentacion.Video.frmConsultaVideoEliminado; +import java.awt.Image; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JOptionPane; + +public class frmConsultaUsuarioEliminado extends javax.swing.JDialog { + + IAdmin sys; + ArrayList<DtVideo> listaDeVideos; + ArrayList<DtListaDeReproduccion> listaDeListasRep; + + public frmConsultaUsuarioEliminado(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + + try { + cargarImagenEnJlabel(lbImagen, ""); + lbImagen.setEnabled(false); + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // lista usuarios en el JList + listarUsuarios(sys.listarUsuariosEliminados()); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel6 = new javax.swing.JPanel(); + jLabel17 = new javax.swing.JLabel(); + jScrollPane4 = new javax.swing.JScrollPane(); + lstUsuarios = new javax.swing.JList<>(); + jLabel18 = new javax.swing.JLabel(); + jLabel19 = new javax.swing.JLabel(); + jLabel20 = new javax.swing.JLabel(); + jLabel21 = new javax.swing.JLabel(); + jLabel22 = new javax.swing.JLabel(); + jLabel23 = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + lbImagen = new javax.swing.JLabel(); + lbFechaN = new javax.swing.JLabel(); + lbEmail = new javax.swing.JLabel(); + lbApellido = new javax.swing.JLabel(); + lbNombre = new javax.swing.JLabel(); + jSeparator3 = new javax.swing.JSeparator(); + jLabel30 = new javax.swing.JLabel(); + jLabel32 = new javax.swing.JLabel(); + jScrollPane5 = new javax.swing.JScrollPane(); + txtDescripcion = new javax.swing.JTextArea(); + jSeparator4 = new javax.swing.JSeparator(); + lbPrivacidad = new javax.swing.JLabel(); + lbNombreCanal = new javax.swing.JLabel(); + btnAceptar = new javax.swing.JButton(); + jLabel79 = new javax.swing.JLabel(); + jLabel80 = new javax.swing.JLabel(); + jScrollPane20 = new javax.swing.JScrollPane(); + lstVideos = new javax.swing.JList<>(); + jScrollPane21 = new javax.swing.JScrollPane(); + lstListaReproduccion = new javax.swing.JList<>(); + lbNickName = new javax.swing.JLabel(); + jLabel31 = new javax.swing.JLabel(); + jLabel24 = new javax.swing.JLabel(); + lbFechaElim = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel17.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel17.setText("Seleccione un usuario:"); + jPanel6.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1)); + + lstUsuarios.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosValueChanged(evt); + } + }); + jScrollPane4.setViewportView(lstUsuarios); + + jPanel6.add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 170, 250)); + + jLabel18.setText("Usuario:"); + jPanel6.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 60, -1, -1)); + + jLabel19.setText("Nombre:"); + jPanel6.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 90, -1, -1)); + + jLabel20.setText("Apellido:"); + jPanel6.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 120, -1, -1)); + + jLabel21.setText("Email:"); + jPanel6.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 150, -1, -1)); + + jLabel22.setText("Baja:"); + jPanel6.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 210, -1, -1)); + + jLabel23.setText("Imágen:"); + jPanel6.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 240, -1, -1)); + + jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + jPanel1.add(lbImagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 5, 100, 100)); + + jPanel6.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 240, 110, 110)); + jPanel6.add(lbFechaN, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 180, 200, 20)); + + lbEmail.setText(" "); + jPanel6.add(lbEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 150, 200, 20)); + + lbApellido.setText(" "); + jPanel6.add(lbApellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 120, 200, -1)); + + lbNombre.setText(" "); + jPanel6.add(lbNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 90, 200, -1)); + jPanel6.add(jSeparator3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 370, 530, 10)); + + jLabel30.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel30.setText("Canal:"); + jPanel6.add(jLabel30, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 390, -1, -1)); + + jLabel32.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel32.setText("Descripción:"); + jPanel6.add(jLabel32, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 450, -1, -1)); + + txtDescripcion.setEditable(false); + txtDescripcion.setColumns(20); + txtDescripcion.setLineWrap(true); + txtDescripcion.setRows(5); + jScrollPane5.setViewportView(txtDescripcion); + + jPanel6.add(jScrollPane5, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 460, 390, 100)); + + jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL); + jPanel6.add(jSeparator4, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 0, 10, 580)); + + lbPrivacidad.setText(" "); + jPanel6.add(lbPrivacidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 420, 390, -1)); + + lbNombreCanal.setText(" "); + jPanel6.add(lbNombreCanal, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 390, 390, -1)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel6.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 480, 410, 70)); + + jLabel79.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel79.setText("Videos:"); + jPanel6.add(jLabel79, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 30, -1, -1)); + + jLabel80.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel80.setText("Listas de Reproducción:"); + jPanel6.add(jLabel80, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 250, -1, -1)); + + lstVideos.setToolTipText("Doble clic para ver mas informacion del video"); + lstVideos.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + lstVideosMouseClicked(evt); + } + }); + jScrollPane20.setViewportView(lstVideos); + + jPanel6.add(jScrollPane20, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 60, 410, 160)); + + lstListaReproduccion.setToolTipText("Doble clic para ver mas informacion de la lista"); + lstListaReproduccion.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + lstListaReproduccionMouseClicked(evt); + } + }); + jScrollPane21.setViewportView(lstListaReproduccion); + + jPanel6.add(jScrollPane21, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 280, 400, 160)); + + lbNickName.setText(" "); + jPanel6.add(lbNickName, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 60, 200, -1)); + + jLabel31.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel31.setText("Privacidad:"); + jPanel6.add(jLabel31, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 420, -1, -1)); + + jLabel24.setText("Nacimiento: "); + jPanel6.add(jLabel24, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 180, -1, -1)); + jPanel6.add(lbFechaElim, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 210, 200, 20)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 980, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 579, Short.MAX_VALUE) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void lstUsuariosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosValueChanged + // Al seleccionar un usuario + if (evt.getValueIsAdjusting()) return; + if (lstUsuarios.getSelectedIndex()<0) return; + + try { + String nick = lstUsuarios.getSelectedValue(); + DtUsuario dtu = sys.seleccionarUsuarioEliminado(nick); + cargarLabelsConDatosDelUsuario(dtu); + DtCanal dtc = sys.obtenerCanalDeUsuario(); + cargarLabelsConDatosDelCanal(dtc); + + listaDeVideos = sys.listarVideosDeUsuario(); + listarVideos(listaDeVideos); + listaDeListasRep = sys.listarListasDeReproduccionDeUsuario(nick); + listarListassRep(listaDeListasRep); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstUsuariosValueChanged + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + try { + sys.liberarMemoriaUsuario(); + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnAceptarActionPerformed + + private void lstVideosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstVideosMouseClicked + // Doble clic en la lista de videos + if (evt.getClickCount() != 2) return; + if (lstVideos.getSelectedIndex()<0) return; + + int indexSeleccionado = lstVideos.getSelectedIndex(); + int idVideo = listaDeVideos.get(indexSeleccionado).getId(); + new frmConsultaVideoEliminado(this, true, idVideo).setVisible(true); + }//GEN-LAST:event_lstVideosMouseClicked + + private void lstListaReproduccionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstListaReproduccionMouseClicked + // Doble clic en la lista de Listas de reproduccion + if (evt.getClickCount() != 2) return; + if (lstListaReproduccion.getSelectedIndex()<0) return; + + int indexSeleccionado = lstListaReproduccion.getSelectedIndex(); + int idLista = listaDeListasRep.get(indexSeleccionado).getId(); + new frmConsultaListaDeReproduccionEliminada(this, true, idLista).setVisible(true); + }//GEN-LAST:event_lstListaReproduccionMouseClicked + + + /////////////////////////////////////////////////////////////////////////////////////////// + private void listarUsuarios(ArrayList<DtUsuario> ListaUsuarios){ + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + } + lstUsuarios.setModel(modelo); + + } + private void listarVideos(ArrayList<DtVideo> ListaVideos){ + DefaultListModel modelo = new DefaultListModel(); + for (DtVideo it : ListaVideos) { + modelo.addElement(it.getNombre()); + } + lstVideos.setModel(modelo); + } + private void listarListassRep(ArrayList<DtListaDeReproduccion> listaListasRep){ + DefaultListModel modelo = new DefaultListModel(); + for (DtListaDeReproduccion it : listaListasRep) { + modelo.addElement(it.getNombre()); + } + lstListaReproduccion.setModel(modelo); + } + private void cargarLabelsConDatosDelUsuario(DtUsuario u){ + lbNickName.setText(u.getNickname()); + lbNombre.setText(u.getNombre()); + lbApellido.setText(u.getApellido()); + lbEmail.setText(u.getCorreo()); + lbFechaN.setText(new SimpleDateFormat("dd-MM-yyyy").format(u.getFechaNacimiento())); + lbFechaElim.setText(new SimpleDateFormat("dd-MM-yyyy").format(u.getFechaEliminado())); + cargarImagenEnJlabel(lbImagen, u.getImagen()); + lbImagen.setEnabled(true); + } + private void cargarLabelsConDatosDelCanal(DtCanal c){ + lbNombreCanal.setText(c.getNombre()); + txtDescripcion.setText(c.getDescripcion()); + if (c.getPrivacidad() == Privacidad.PUBLICO){ + lbPrivacidad.setText("Publico"); + }else{ + lbPrivacidad.setText("Privado"); + } + } + private void cargarImagenEnJlabel(javax.swing.JLabel jLabelx, String Ruta){ + jLabelx.setText(null); + if (Ruta == null || Ruta.isEmpty()){ + Ruta = "Imagenes\\ukp.png"; + } + // Carga la imagen a la variable de tipo Image + Image img = new ImageIcon(Ruta).getImage(); + // Crea un ImageIcon a partir de la imagen (obtiene las dimenciones del jLbel y escala la imagen para que entre en el mismo) + ImageIcon icono = new ImageIcon( + img.getScaledInstance(jLabelx.getWidth(), jLabelx.getHeight(), Image.SCALE_SMOOTH) + ); + // establece la imagen en el label + jLabelx.setIcon(icono); + } + /////////////////////////////////////////////////////////////////////////////////////////// + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel24; + private javax.swing.JLabel jLabel30; + private javax.swing.JLabel jLabel31; + private javax.swing.JLabel jLabel32; + private javax.swing.JLabel jLabel79; + private javax.swing.JLabel jLabel80; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel6; + private javax.swing.JScrollPane jScrollPane20; + private javax.swing.JScrollPane jScrollPane21; + private javax.swing.JScrollPane jScrollPane4; + private javax.swing.JScrollPane jScrollPane5; + private javax.swing.JSeparator jSeparator3; + private javax.swing.JSeparator jSeparator4; + private javax.swing.JLabel lbApellido; + private javax.swing.JLabel lbEmail; + private javax.swing.JLabel lbFechaElim; + private javax.swing.JLabel lbFechaN; + private javax.swing.JLabel lbImagen; + private javax.swing.JLabel lbNickName; + private javax.swing.JLabel lbNombre; + private javax.swing.JLabel lbNombreCanal; + private javax.swing.JLabel lbPrivacidad; + private javax.swing.JList<String> lstListaReproduccion; + private javax.swing.JList<String> lstUsuarios; + private javax.swing.JList<String> lstVideos; + private javax.swing.JTextArea txtDescripcion; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.form b/UyTube_logica/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.form new file mode 100644 index 0000000000000000000000000000000000000000..513b2d16f4401845b536e8db6697ae284fc7f93f --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.form @@ -0,0 +1,173 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Dejar de seguir usuario"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="770" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel12" min="-2" pref="770" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="430" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel12" min="-2" pref="430" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel12"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane11"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="40" y="50" width="330" height="290"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstSeguidor"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstSeguidorValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane12"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="410" y="50" width="320" height="290"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstSeguido"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstSeguidoValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel61"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="40" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel62"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seguidos:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="410" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnSalir"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="salir"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSalirActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="40" y="370" width="120" height="40"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnDejarDeSeguir"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Dejar de Seguir"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDejarDeSeguirActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="370" width="200" height="40"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.java b/UyTube_logica/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..f2a77255b5b39732b9bcb25d7cd8fe297c46f99d --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmDejarDeSeguirUsuario.java @@ -0,0 +1,227 @@ +package Presentacion.Usuario; + +import Logica.DataType.DtUsuario; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmDejarDeSeguirUsuario extends javax.swing.JDialog { + + private IAdmin Sys; + + public frmDejarDeSeguirUsuario(java.awt.Frame parent, boolean modal) { + super(parent, modal); + try { + initComponents(); + this.setLocationRelativeTo(null); + + Fabrica f = Fabrica.getInstancia(); + Sys = f.getIAdmin(); + + Sys.liberarMemoriaUsuarioActual(); + Sys.liberarMemoriaUsuario(); + + ArrayList<DtUsuario> ListaUsuarios = Sys.listarUsuarios(); + + DefaultListModel modelo = new DefaultListModel(); + + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + + } + lstSeguidor.setModel(modelo); + + btnDejarDeSeguir.setEnabled(false); + lstSeguido.setEnabled(false); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel12 = new javax.swing.JPanel(); + jScrollPane11 = new javax.swing.JScrollPane(); + lstSeguidor = new javax.swing.JList<>(); + jScrollPane12 = new javax.swing.JScrollPane(); + lstSeguido = new javax.swing.JList<>(); + jLabel61 = new javax.swing.JLabel(); + jLabel62 = new javax.swing.JLabel(); + btnSalir = new javax.swing.JButton(); + btnDejarDeSeguir = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Dejar de seguir usuario"); + setResizable(false); + + jPanel12.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + lstSeguidor.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstSeguidorValueChanged(evt); + } + }); + jScrollPane11.setViewportView(lstSeguidor); + + jPanel12.add(jScrollPane11, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 50, 330, 290)); + + lstSeguido.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstSeguidoValueChanged(evt); + } + }); + jScrollPane12.setViewportView(lstSeguido); + + jPanel12.add(jScrollPane12, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 50, 320, 290)); + + jLabel61.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel61.setText("Usuarios:"); + jPanel12.add(jLabel61, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, -1, -1)); + + jLabel62.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel62.setText("Seguidos:"); + jPanel12.add(jLabel62, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 20, -1, -1)); + + btnSalir.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnSalir.setText("salir"); + btnSalir.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSalirActionPerformed(evt); + } + }); + jPanel12.add(btnSalir, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 370, 120, 40)); + + btnDejarDeSeguir.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnDejarDeSeguir.setText("Dejar de Seguir"); + btnDejarDeSeguir.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnDejarDeSeguirActionPerformed(evt); + } + }); + jPanel12.add(btnDejarDeSeguir, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 370, 200, 40)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 770, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, 770, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 430, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, 430, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed + //salir + try { + Sys.liberarMemoriaUsuarioActual(); + Sys.liberarMemoriaUsuario(); + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnSalirActionPerformed + + private void btnDejarDeSeguirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDejarDeSeguirActionPerformed + + try { + Sys.seguirUsuario();//DEJA de SEGUIR + Sys.seleccionarUsuario(lstSeguidor.getSelectedValue()); + mostrarSeguidos(Sys.listarUsuarioSeguidos()); + Sys.seleccionarUsuarioActual(lstSeguidor.getSelectedValue()); + Sys.liberarMemoriaUsuario(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnDejarDeSeguirActionPerformed + private void mostrarSeguidos(ArrayList<DtUsuario> Seguidos) { + try { + Seguidos = Sys.listarUsuarioSeguidos(); + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : Seguidos) { + modelo.addElement(it.getNickname()); + } + lstSeguido.setModel(modelo); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + private void lstSeguidorValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstSeguidorValueChanged + // SegidoRRR + if (evt.getValueIsAdjusting()) { + return; + } + if (lstSeguidor.getSelectedIndex() < 0) { + return; + } + btnDejarDeSeguir.setEnabled(false); + + String Nickname = lstSeguidor.getSelectedValue(); + + try { + DtUsuario user = Sys.seleccionarUsuario(Nickname); + lstSeguido.setEnabled(true); + lstSeguido.clearSelection(); + + mostrarSeguidos(Sys.listarUsuarioSeguidos()); + + Sys.liberarMemoriaUsuario(); + + Sys.seleccionarUsuarioActual(Nickname); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstSeguidorValueChanged + + private void lstSeguidoValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstSeguidoValueChanged + // Segidoooo + if (evt.getValueIsAdjusting()) { + return; + } + if (lstSeguido.getSelectedIndex() < 0) { + return; + } + + String SegidOOO = lstSeguido.getSelectedValue(); + //lstVideos.setEnabled(true); + + try { + DtUsuario user = Sys.seleccionarUsuario(SegidOOO); + btnDejarDeSeguir.setEnabled(true); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstSeguidoValueChanged + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnDejarDeSeguir; + private javax.swing.JButton btnSalir; + private javax.swing.JLabel jLabel61; + private javax.swing.JLabel jLabel62; + private javax.swing.JPanel jPanel12; + private javax.swing.JScrollPane jScrollPane11; + private javax.swing.JScrollPane jScrollPane12; + private javax.swing.JList<String> lstSeguido; + private javax.swing.JList<String> lstSeguidor; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Usuario/frmListarUsuarios.form b/UyTube_logica/src/Presentacion/Usuario/frmListarUsuarios.form new file mode 100644 index 0000000000000000000000000000000000000000..5077b3d21340abf7fbad277cacb42fb354757bee --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmListarUsuarios.form @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Listar usuarios"/> + <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="default"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="lbListarUasario" min="-2" pref="300" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="lbListarUasario" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="lbListarUasario"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane10"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="30" width="300" height="250"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstListaDeUsuario"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel60"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnAceptarMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="280" width="300" height="80"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Usuario/frmListarUsuarios.java b/UyTube_logica/src/Presentacion/Usuario/frmListarUsuarios.java new file mode 100644 index 0000000000000000000000000000000000000000..32aea7db0612cd547ba16328d2ee8dc3ca6c3747 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmListarUsuarios.java @@ -0,0 +1,105 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Presentacion.Usuario; +import java.util.ArrayList; +import Logica.DataType.DtUsuario; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmListarUsuarios extends javax.swing.JDialog { + public frmListarUsuarios(java.awt.Frame parent, boolean modal) { + super(parent, modal); + + try { + initComponents(); + this.setLocationRelativeTo(null); + + Fabrica f = Fabrica.getInstancia(); + IAdmin Sys = f.getIAdmin(); + + ArrayList<DtUsuario> ListaUsuarios = Sys.listarUsuarios(); + + DefaultListModel modelo = new DefaultListModel(); + + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + } + lstListaDeUsuario.setModel(modelo); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + + + + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + lbListarUasario = new javax.swing.JPanel(); + jScrollPane10 = new javax.swing.JScrollPane(); + lstListaDeUsuario = new javax.swing.JList<>(); + jLabel60 = new javax.swing.JLabel(); + btnAceptar = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Listar usuarios"); + setResizable(false); + + lbListarUasario.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jScrollPane10.setViewportView(lstListaDeUsuario); + + lbListarUasario.add(jScrollPane10, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 30, 300, 250)); + + jLabel60.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel60.setText("Usuarios:"); + lbListarUasario.add(jLabel60, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, -1, -1)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + btnAceptarMouseClicked(evt); + } + }); + lbListarUasario.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 280, 300, 80)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(lbListarUasario, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(lbListarUasario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAceptarMouseClicked + dispose(); + }//GEN-LAST:event_btnAceptarMouseClicked + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JLabel jLabel60; + private javax.swing.JScrollPane jScrollPane10; + private javax.swing.JPanel lbListarUasario; + private javax.swing.JList<String> lstListaDeUsuario; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Usuario/frmModificarUsuario.form b/UyTube_logica/src/Presentacion/Usuario/frmModificarUsuario.form new file mode 100644 index 0000000000000000000000000000000000000000..95cd5537cd2fca1ded442afe7370a6cb21bee116 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmModificarUsuario.form @@ -0,0 +1,496 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="grpPrivacidad"> + </Component> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Modificar usuario"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="960" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="lbMes" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="560" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="lbMes" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="lbMes"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lbNombre"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="60" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCorreo"> + <Properties> + <Property name="text" type="java.lang.String" value="Correo"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="140" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel128"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuario"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="320" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtNombre"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="390" y="60" width="230" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtCorreo"> + <Properties> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="390" y="140" width="230" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator9"> + <Properties> + <Property name="orientation" type="int" value="1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="310" y="0" width="10" height="560"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel131"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seleccionar usuario"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane50"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="50" width="260" height="420"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarios"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuariosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnModificar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Modificar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnModificarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="670" y="490" width="270" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnSeleccionar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Seleccionar imágen"/> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Cursor Por defecto"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSeleccionarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="370" width="170" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator10"> + <Properties> + <Property name="orientation" type="int" value="1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="640" y="0" width="10" height="560"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel132"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Canal"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="650" y="10" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbNombreC"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="650" y="60" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtNombreCanal"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="740" y="60" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbDescripcion"> + <Properties> + <Property name="text" type="java.lang.String" value="Descripción"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="650" y="100" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane51"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="740" y="100" width="200" height="160"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtDescrpcion"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnListaReprodiccion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Modificar lista de reproducción"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnListaReprodiccionActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="670" y="340" width="270" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnVideo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Modificar video"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnVideoActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="670" y="400" width="270" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="490" width="260" height="50"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jpImagen"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.BevelBorderInfo"> + <BevelBorder/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="370" width="110" height="110"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lbImg"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="5" width="100" height="100"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JSeparator" name="jSeparator6"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="310" y="40" width="650" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtApellido"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="390" y="100" width="230" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbApellido"> + <Properties> + <Property name="text" type="java.lang.String" value="Apellido"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="100" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbRCN"> + <Properties> + <Property name="text" type="java.lang.String" value="Repita contraseña"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="300" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCN"> + <Properties> + <Property name="text" type="java.lang.String" value="Contraseña nueva"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="270" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbFecha"> + <Properties> + <Property name="text" type="java.lang.String" value="Fecha de Nac."/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="180" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JCheckBox" name="chkCambiarContra"> + <Properties> + <Property name="text" type="java.lang.String" value="Cambiar contraseña"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkCambiarContraActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="230" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbPublico"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="grpPrivacidad"/> + </Property> + <Property name="text" type="java.lang.String" value="Público"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="740" y="270" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbPrivado"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="grpPrivacidad"/> + </Property> + <Property name="text" type="java.lang.String" value="Privado"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="840" y="270" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbImagen1"> + <Properties> + <Property name="text" type="java.lang.String" value="Imágen (opcional)"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="330" y="340" width="-1" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="com.toedter.calendar.JDateChooser" name="dcFecha"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="180" width="170" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnQuitarImagen"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Quitar imágen"/> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Cursor Por defecto"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuitarImagenActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="430" width="170" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JPasswordField" name="txtContraNueva2"> + <Properties> + <Property name="text" type="java.lang.String" value="jPasswordField1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="470" y="300" width="150" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JPasswordField" name="txtContraNueva1"> + <Properties> + <Property name="text" type="java.lang.String" value="jPasswordField1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="470" y="270" width="150" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Usuario/frmModificarUsuario.java b/UyTube_logica/src/Presentacion/Usuario/frmModificarUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..59482c5f1d27ad44b4336f2b1ece309956384986 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmModificarUsuario.java @@ -0,0 +1,640 @@ +package Presentacion.Usuario; + +import Logica.DataType.DtCanal; +import Logica.DataType.DtUsuario; +import Logica.Enumerados.Privacidad; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import Presentacion.ListaDeReproduccion.frmModificarListaDeReproduccion; +import Presentacion.Video.frmModificarVideo; +import java.awt.Image; +import java.io.File; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileNameExtensionFilter; + +public class frmModificarUsuario extends javax.swing.JDialog { + + IAdmin sys; + DtUsuario user; + String ruta; + + public frmModificarUsuario(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + txtContraNueva1.setEnabled(false); // TODO add your handling code here: + txtContraNueva2.setEnabled(false); // TODO add your handling code here: + lbCN.setEnabled(false); + lbRCN.setEnabled(false); + btnVideo.setEnabled(false); + btnListaReprodiccion.setEnabled(false); + desactivarCampos(); + try { + cargarImagenEnJlabel(lbImg, ""); + + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // lista usuarios en el JList + listarUsuarios(sys.listarUsuarios()); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + grpPrivacidad = new javax.swing.ButtonGroup(); + lbMes = new javax.swing.JPanel(); + lbNombre = new javax.swing.JLabel(); + lbCorreo = new javax.swing.JLabel(); + jLabel128 = new javax.swing.JLabel(); + txtNombre = new javax.swing.JTextField(); + txtCorreo = new javax.swing.JTextField(); + jSeparator9 = new javax.swing.JSeparator(); + jLabel131 = new javax.swing.JLabel(); + jScrollPane50 = new javax.swing.JScrollPane(); + lstUsuarios = new javax.swing.JList<>(); + btnModificar = new javax.swing.JButton(); + btnSeleccionar = new javax.swing.JButton(); + jSeparator10 = new javax.swing.JSeparator(); + jLabel132 = new javax.swing.JLabel(); + lbNombreC = new javax.swing.JLabel(); + txtNombreCanal = new javax.swing.JTextField(); + lbDescripcion = new javax.swing.JLabel(); + jScrollPane51 = new javax.swing.JScrollPane(); + txtDescrpcion = new javax.swing.JTextArea(); + btnListaReprodiccion = new javax.swing.JButton(); + btnVideo = new javax.swing.JButton(); + btnCancelar = new javax.swing.JButton(); + jpImagen = new javax.swing.JPanel(); + lbImg = new javax.swing.JLabel(); + jSeparator6 = new javax.swing.JSeparator(); + txtApellido = new javax.swing.JTextField(); + lbApellido = new javax.swing.JLabel(); + lbRCN = new javax.swing.JLabel(); + lbCN = new javax.swing.JLabel(); + lbFecha = new javax.swing.JLabel(); + chkCambiarContra = new javax.swing.JCheckBox(); + rbPublico = new javax.swing.JRadioButton(); + rbPrivado = new javax.swing.JRadioButton(); + lbImagen1 = new javax.swing.JLabel(); + dcFecha = new com.toedter.calendar.JDateChooser(); + btnQuitarImagen = new javax.swing.JButton(); + txtContraNueva2 = new javax.swing.JPasswordField(); + txtContraNueva1 = new javax.swing.JPasswordField(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Modificar usuario"); + setResizable(false); + + lbMes.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + lbNombre.setText("Nombre"); + lbMes.add(lbNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 60, -1, -1)); + + lbCorreo.setText("Correo"); + lbMes.add(lbCorreo, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 140, -1, -1)); + + jLabel128.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel128.setText("Usuario"); + lbMes.add(jLabel128, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 10, -1, -1)); + lbMes.add(txtNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 60, 230, -1)); + + txtCorreo.setEnabled(false); + lbMes.add(txtCorreo, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 140, 230, -1)); + + jSeparator9.setOrientation(javax.swing.SwingConstants.VERTICAL); + lbMes.add(jSeparator9, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 0, 10, 560)); + + jLabel131.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel131.setText("Seleccionar usuario"); + lbMes.add(jLabel131, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1)); + + lstUsuarios.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuariosValueChanged(evt); + } + }); + jScrollPane50.setViewportView(lstUsuarios); + + lbMes.add(jScrollPane50, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 50, 260, 420)); + + btnModificar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnModificar.setText("Modificar"); + btnModificar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnModificarActionPerformed(evt); + } + }); + lbMes.add(btnModificar, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 490, 270, 50)); + + btnSeleccionar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnSeleccionar.setText("Seleccionar imágen"); + btnSeleccionar.setToolTipText(""); + btnSeleccionar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + btnSeleccionar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSeleccionarActionPerformed(evt); + } + }); + lbMes.add(btnSeleccionar, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 370, 170, 50)); + + jSeparator10.setOrientation(javax.swing.SwingConstants.VERTICAL); + lbMes.add(jSeparator10, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 0, 10, 560)); + + jLabel132.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel132.setText("Canal"); + lbMes.add(jLabel132, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 10, -1, -1)); + + lbNombreC.setText("Nombre"); + lbMes.add(lbNombreC, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 60, -1, -1)); + lbMes.add(txtNombreCanal, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 60, 200, -1)); + + lbDescripcion.setText("Descripción"); + lbMes.add(lbDescripcion, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 100, -1, -1)); + + txtDescrpcion.setColumns(20); + txtDescrpcion.setRows(5); + jScrollPane51.setViewportView(txtDescrpcion); + + lbMes.add(jScrollPane51, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 100, 200, 160)); + + btnListaReprodiccion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + btnListaReprodiccion.setText("Modificar lista de reproducción"); + btnListaReprodiccion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnListaReprodiccionActionPerformed(evt); + } + }); + lbMes.add(btnListaReprodiccion, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 340, 270, 50)); + + btnVideo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + btnVideo.setText("Modificar video"); + btnVideo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnVideoActionPerformed(evt); + } + }); + lbMes.add(btnVideo, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 400, 270, 50)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + lbMes.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 490, 260, 50)); + + jpImagen.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); + jpImagen.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + jpImagen.add(lbImg, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 5, 100, 100)); + + lbMes.add(jpImagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 370, 110, 110)); + lbMes.add(jSeparator6, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 40, 650, 20)); + lbMes.add(txtApellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 100, 230, -1)); + + lbApellido.setText("Apellido"); + lbMes.add(lbApellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 100, -1, -1)); + + lbRCN.setText("Repita contraseña"); + lbMes.add(lbRCN, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 300, -1, -1)); + + lbCN.setText("Contraseña nueva"); + lbMes.add(lbCN, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 270, -1, -1)); + + lbFecha.setText("Fecha de Nac."); + lbMes.add(lbFecha, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 180, -1, -1)); + + chkCambiarContra.setText("Cambiar contraseña"); + chkCambiarContra.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + chkCambiarContraActionPerformed(evt); + } + }); + lbMes.add(chkCambiarContra, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 230, -1, -1)); + + grpPrivacidad.add(rbPublico); + rbPublico.setText("Público"); + lbMes.add(rbPublico, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 270, -1, -1)); + + grpPrivacidad.add(rbPrivado); + rbPrivado.setText("Privado"); + lbMes.add(rbPrivado, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 270, -1, -1)); + + lbImagen1.setText("Imágen (opcional)"); + lbMes.add(lbImagen1, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 340, -1, 20)); + lbMes.add(dcFecha, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 180, 170, -1)); + + btnQuitarImagen.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnQuitarImagen.setText("Quitar imágen"); + btnQuitarImagen.setToolTipText(""); + btnQuitarImagen.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + btnQuitarImagen.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnQuitarImagenActionPerformed(evt); + } + }); + lbMes.add(btnQuitarImagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 430, 170, 50)); + + txtContraNueva2.setText("jPasswordField1"); + lbMes.add(txtContraNueva2, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 300, 150, -1)); + + txtContraNueva1.setText("jPasswordField1"); + lbMes.add(txtContraNueva1, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 270, 150, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 960, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(lbMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 560, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(lbMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + private void listarUsuarios(ArrayList<DtUsuario> ListaUsuarios) { + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + } + lstUsuarios.setModel(modelo); + + } + + private void desactivarCampos() { + txtNombre.setEnabled(false); + txtContraNueva1.setEnabled(false); + txtContraNueva2.setEnabled(false); + txtDescrpcion.setEnabled(false); + txtNombreCanal.setEnabled(false); + txtApellido.setEnabled(false); + dcFecha.setEnabled(false); + lbImg.setEnabled(false); + lbMes.setEnabled(false); + lbNombre.setEnabled(false); + lbApellido.setEnabled(false); + lbNombreC.setEnabled(false); + lbCorreo.setEnabled(false); + lbDescripcion.setEnabled(false); + lbFecha.setEnabled(false); + chkCambiarContra.setEnabled(false); + rbPublico.setEnabled(false); + rbPrivado.setEnabled(false); + btnModificar.setEnabled(false); + btnSeleccionar.setEnabled(false); + btnQuitarImagen.setEnabled(false); + txtDescrpcion.setEnabled(false); + + } + + private void activarCampos() { + + txtNombre.setEnabled(true); + txtDescrpcion.setEnabled(true); + txtNombreCanal.setEnabled(true); + txtApellido.setEnabled(true); + dcFecha.setEnabled(true); + lbImg.setEnabled(true); + lbMes.setEnabled(true); + lbNombre.setEnabled(true); + lbApellido.setEnabled(true); + lbNombreC.setEnabled(true); + lbCorreo.setEnabled(true); + lbDescripcion.setEnabled(true); + lbFecha.setEnabled(true); + chkCambiarContra.setEnabled(true); + rbPublico.setEnabled(true); + rbPrivado.setEnabled(true); + btnModificar.setEnabled(true); + btnSeleccionar.setEnabled(true); + btnQuitarImagen.setEnabled(true); + txtDescrpcion.setEnabled(true); + } + + private String seleccionarImagen() { + // Crea un JFileChooser + JFileChooser JFC = new JFileChooser(); + // crea un filtro para aceptar solo algunas extensiones + FileNameExtensionFilter filtroImagen = new FileNameExtensionFilter("JPG", "JPEG", "PNG", "jpg", "jpeg", "png"); + // Agrega el filtro al JFileChooser + JFC.setFileFilter(filtroImagen); + + // archivo seleccionado + File archivo; + // para saber si se selecciono algo o se cancelo + int resultado; + + while (true) { + // muestra el JFileChooser + resultado = JFC.showOpenDialog(this); + + // Si pasa algo que no sea el aceptar + if (resultado != JFileChooser.APPROVE_OPTION) { + return ""; + } + + // obtiene el archivo seleccionado + archivo = JFC.getSelectedFile(); + + // Si se selecciono algun archivo + if (archivo != null) { + // obtiene la ruta del archivo + String rutaArchivo = archivo.getAbsolutePath(); + // obtiene el archivo como imagen a partir de la ruta + Image img = new ImageIcon(rutaArchivo).getImage(); + + // verifica que tanto se deformará la imagen al mostrarla en un cuadrado + float deformacion; + if (img.getHeight(null) > img.getWidth(null)) { + deformacion = img.getHeight(null) / img.getWidth(null); + } else { + deformacion = img.getWidth(null) / img.getHeight(null); + } + + if (deformacion < 1.3 && deformacion >= 1) { + // si no se deforma demasiado + // devuelve la ruta absoluta + return rutaArchivo; + } else { + // si se deforma demasiado, lo avisa al usuario para que escoja otra + JOptionPane.showMessageDialog(null, + "La imagen es demasiado alta o demasiado ancha.\n" + img.getWidth(null) + "x" + img.getHeight(null), + "Problemas con la imagen", + JOptionPane.WARNING_MESSAGE + ); + } + } else { + // sino devuelve un string vacio + return ""; + } + } + } + + private void cargarImagenEnJlabel(javax.swing.JLabel jLabelx, String Ruta) { + jLabelx.setText(null); + if (Ruta == null || Ruta.isEmpty()){ + Ruta = "Imagenes\\ukp.png"; + } + // Carga la imagen a la variable de tipo Image + Image img = new ImageIcon(Ruta).getImage(); + // Crea un ImageIcon a partir de la imagen (obtiene las dimenciones del jLbel y escala la imagen para que entre en el mismo) + ImageIcon icono = new ImageIcon( + img.getScaledInstance(jLabelx.getWidth(), jLabelx.getHeight(), Image.SCALE_SMOOTH) + ); + // establece la imagen en el label + jLabelx.setIcon(icono); + } + + private boolean validarNombres(String _nombre) { + Pattern patronNombres = Pattern.compile("^([A-Za-zÑñÃáÉéÃÃÓóÚú]+)\\s*([A-Za-zÑñÃáÉéÃÃÓóÚú]+)\\s*([A-Za-zÑñÃáÉéÃÃÓóÚú]+)$"); + Matcher mather = patronNombres.matcher(_nombre); + if (mather.find() == true) { + return true; + } + return false; + } + + private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed + txtNombre.setText(convertirPrimeraEnMayusculas(txtNombre.getText())); + txtApellido.setText(convertirPrimeraEnMayusculas(txtApellido.getText())); + try { + + if (lstUsuarios.isSelectionEmpty()) { + JOptionPane.showMessageDialog(null, "Seleccione un usuario para modificar", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (txtNombre.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "El campo nombre no puede quedar vacÃo", "Error", JOptionPane.WARNING_MESSAGE); + } else { + txtNombre.setText(txtNombre.getText().trim()); + if (!validarNombres(txtNombre.getText())) { + JOptionPane.showMessageDialog(null, "El nombre tiene caracteres no válidos", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (txtApellido.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "El campo apellido no puede quedar vacÃo", "Error", JOptionPane.WARNING_MESSAGE); + } else { + txtApellido.setText(txtApellido.getText().trim()); + if (!validarNombres(txtApellido.getText())) { + JOptionPane.showMessageDialog(null, "El apellido tiene caracteres no válidos", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (txtNombreCanal.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "El campo nombre de canal no puede quedar vacÃo", "Error", JOptionPane.WARNING_MESSAGE); + } else { + txtNombreCanal.setText(txtNombreCanal.getText().trim()); + String pass = user.getContrasenia(); + if (chkCambiarContra.isSelected()) { + + if (!(txtContraNueva1.getText().equals("") && txtContraNueva2.getText().equals(""))) { + + if (txtContraNueva1.getText().equals(txtContraNueva2.getText())) { + pass = txtContraNueva1.getText(); + } else { + JOptionPane.showMessageDialog(null, "Las contraseñas no coinciden, no se pudo efectuar el cambio de contraseña. Inténtelo de nuevo", "Error", JOptionPane.WARNING_MESSAGE); + txtContraNueva1.setText(""); + txtContraNueva2.setText(""); + return; + } + + } else { + JOptionPane.showMessageDialog(null, "Ingrese la contraseña nueva", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + } + java.sql.Date fecha = null; //casteo fecha + if (dcFecha.getDate() != null) { + java.util.Date utilDate = dcFecha.getDate(); + fecha = new java.sql.Date(utilDate.getTime()); + }else{ + JOptionPane.showMessageDialog(null, "Debe seleccionar la fecha de nacimiento", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + DtUsuario u = new DtUsuario(user.getNickname(), pass, txtNombre.getText(), txtApellido.getText(), user.getCorreo(), fecha, ruta, PROPERTIES); + Privacidad priv; + if (rbPrivado.isSelected()) { + priv = Privacidad.PRIVADO; + } else { + priv = Privacidad.PUBLICO; + } + DtCanal c = new DtCanal(0, txtNombreCanal.getText(), txtDescrpcion.getText(), priv); + sys.modificarUsuarioYCanal(u, c); + + JOptionPane.showMessageDialog(null, "Datos modificados correctamente", "OK", JOptionPane.INFORMATION_MESSAGE); + dispose(); + + } + } + } + } + } + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnModificarActionPerformed + + private void btnSeleccionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSeleccionarActionPerformed + //cargarImagen(lbImagen); + String rutaAnterior = ruta; + ruta = seleccionarImagen(); + if (ruta.isEmpty()) { + ruta = rutaAnterior; + } + cargarImagenEnJlabel(lbImg, ruta); + }//GEN-LAST:event_btnSeleccionarActionPerformed + + private void btnListaReprodiccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnListaReprodiccionActionPerformed + new frmModificarListaDeReproduccion(this, true, lstUsuarios.getSelectedValue()).setVisible(true); + }//GEN-LAST:event_btnListaReprodiccionActionPerformed + + private void btnVideoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVideoActionPerformed + new frmModificarVideo(this, true, lstUsuarios.getSelectedValue()).setVisible(true); + }//GEN-LAST:event_btnVideoActionPerformed + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + sys.liberarMemoriaUsuario(); + dispose(); + }//GEN-LAST:event_btnCancelarActionPerformed + private void cargarDatosDelUsuario(DtUsuario u) { + txtNombre.setText(u.getNombre()); + txtApellido.setText(u.getApellido()); + txtCorreo.setText(u.getCorreo()); + dcFecha.setDate(u.getFechaNacimiento()); + cargarImagenEnJlabel(lbImg, u.getImagen()); + + } + + private void cargarDatosDelCanal(DtCanal c) { + txtNombreCanal.setText(c.getNombre()); + txtDescrpcion.setText(c.getDescripcion()); + if (c.getPrivacidad() == Privacidad.PUBLICO) { + rbPublico.setSelected(true); + } else { + rbPrivado.setSelected(true); + } + } + + + private void lstUsuariosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuariosValueChanged + try { + if (!lstUsuarios.isSelectionEmpty()) { + activarCampos(); + } + btnVideo.setEnabled(true); + btnListaReprodiccion.setEnabled(true); + String nick = lstUsuarios.getSelectedValue(); + user = sys.seleccionarUsuario(nick); + cargarDatosDelUsuario(user); + DtCanal dtc = sys.obtenerCanalDeUsuario(); + cargarDatosDelCanal(dtc); + ruta = user.getImagen(); + txtContraNueva1.setText(""); + txtContraNueva2.setText(""); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + + } // TODO add your handling code here: + }//GEN-LAST:event_lstUsuariosValueChanged + + private void chkCambiarContraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkCambiarContraActionPerformed + if (chkCambiarContra.isSelected()) { + txtContraNueva1.setEnabled(true); + txtContraNueva2.setEnabled(true); + lbCN.setEnabled(true); + lbRCN.setEnabled(true); + + } else { + txtContraNueva1.setEnabled(false); + txtContraNueva2.setEnabled(false); + lbCN.setEnabled(false); + lbRCN.setEnabled(false); + } // TODO add your handling code here: + }//GEN-LAST:event_chkCambiarContraActionPerformed + + private void btnQuitarImagenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarImagenActionPerformed + // Quitar imagen + ruta = ""; + cargarImagenEnJlabel(lbImg, ruta); + }//GEN-LAST:event_btnQuitarImagenActionPerformed + + + private String convertirPrimeraEnMayusculas(String cadena){ + if (cadena.isEmpty()) { + return ""; + } + char[] caracteres = cadena.toCharArray(); + caracteres[0] = Character.toUpperCase(caracteres[0]);//Convierte el primer caracter de la primer palabra + // el -2 es para evitar una excepción al caernos del arreglo + for (int i = 0; i < cadena.length() - 2; i++) { // Es 'palabra' + if (caracteres[i] == ' ' || caracteres[i] == '.' || caracteres[i] == ',') { // Reemplazamos + caracteres[i + 1] = Character.toUpperCase(caracteres[i + 1]); + } + } + return new String(caracteres); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancelar; + private javax.swing.JButton btnListaReprodiccion; + private javax.swing.JButton btnModificar; + private javax.swing.JButton btnQuitarImagen; + private javax.swing.JButton btnSeleccionar; + private javax.swing.JButton btnVideo; + private javax.swing.JCheckBox chkCambiarContra; + private com.toedter.calendar.JDateChooser dcFecha; + private javax.swing.ButtonGroup grpPrivacidad; + private javax.swing.JLabel jLabel128; + private javax.swing.JLabel jLabel131; + private javax.swing.JLabel jLabel132; + private javax.swing.JScrollPane jScrollPane50; + private javax.swing.JScrollPane jScrollPane51; + private javax.swing.JSeparator jSeparator10; + private javax.swing.JSeparator jSeparator6; + private javax.swing.JSeparator jSeparator9; + private javax.swing.JPanel jpImagen; + private javax.swing.JLabel lbApellido; + private javax.swing.JLabel lbCN; + private javax.swing.JLabel lbCorreo; + private javax.swing.JLabel lbDescripcion; + private javax.swing.JLabel lbFecha; + private javax.swing.JLabel lbImagen1; + private javax.swing.JLabel lbImg; + private javax.swing.JPanel lbMes; + private javax.swing.JLabel lbNombre; + private javax.swing.JLabel lbNombreC; + private javax.swing.JLabel lbRCN; + private javax.swing.JList<String> lstUsuarios; + private javax.swing.JRadioButton rbPrivado; + private javax.swing.JRadioButton rbPublico; + private javax.swing.JTextField txtApellido; + private javax.swing.JPasswordField txtContraNueva1; + private javax.swing.JPasswordField txtContraNueva2; + private javax.swing.JTextField txtCorreo; + private javax.swing.JTextArea txtDescrpcion; + private javax.swing.JTextField txtNombre; + private javax.swing.JTextField txtNombreCanal; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Usuario/frmSeguirUsuario.form b/UyTube_logica/src/Presentacion/Usuario/frmSeguirUsuario.form new file mode 100644 index 0000000000000000000000000000000000000000..8b096f0aea6c6ce528f0bbb03a8458a7f1222d1b --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmSeguirUsuario.form @@ -0,0 +1,173 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Seguir usuario"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="770" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel12" min="-2" pref="770" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="430" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel12" min="-2" pref="430" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel12"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane11"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="40" y="50" width="330" height="290"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstSeguidor"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstSeguidorValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane12"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="410" y="50" width="320" height="290"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstNoSeguido"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstNoSeguidoValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel61"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="40" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel62"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="No Seguidos:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="410" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnSeguir"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Seguir"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSeguirActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="540" y="370" width="190" height="40"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnSalir"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="salir"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSalirActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="50" y="370" width="120" height="40"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Usuario/frmSeguirUsuario.java b/UyTube_logica/src/Presentacion/Usuario/frmSeguirUsuario.java new file mode 100644 index 0000000000000000000000000000000000000000..da1a7184d2901a95853566f97b90fc3c70ea06de --- /dev/null +++ b/UyTube_logica/src/Presentacion/Usuario/frmSeguirUsuario.java @@ -0,0 +1,231 @@ +package Presentacion.Usuario; + +import Logica.DataType.DtUsuario; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmSeguirUsuario extends javax.swing.JDialog { + + private IAdmin Sys; + public ArrayList<DtUsuario> ListaTodosUsuarios; + + public frmSeguirUsuario(java.awt.Frame parent, boolean modal) { + super(parent, modal); + try { + initComponents(); + this.setLocationRelativeTo(null); + + Fabrica f = Fabrica.getInstancia(); + Sys = f.getIAdmin(); + + Sys.liberarMemoriaUsuarioActual(); + Sys.liberarMemoriaUsuario(); + + ListaTodosUsuarios = Sys.listarUsuarios(); + + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : ListaTodosUsuarios) { + modelo.addElement(it.getNickname()); + } + lstSeguidor.setModel(modelo); + + btnSeguir.setEnabled(false); + lstNoSeguido.setEnabled(false); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel12 = new javax.swing.JPanel(); + jScrollPane11 = new javax.swing.JScrollPane(); + lstSeguidor = new javax.swing.JList<>(); + jScrollPane12 = new javax.swing.JScrollPane(); + lstNoSeguido = new javax.swing.JList<>(); + jLabel61 = new javax.swing.JLabel(); + jLabel62 = new javax.swing.JLabel(); + btnSeguir = new javax.swing.JButton(); + btnSalir = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Seguir usuario"); + setResizable(false); + + jPanel12.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + lstSeguidor.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstSeguidorValueChanged(evt); + } + }); + jScrollPane11.setViewportView(lstSeguidor); + + jPanel12.add(jScrollPane11, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 50, 330, 290)); + + lstNoSeguido.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstNoSeguidoValueChanged(evt); + } + }); + jScrollPane12.setViewportView(lstNoSeguido); + + jPanel12.add(jScrollPane12, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 50, 320, 290)); + + jLabel61.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel61.setText("Usuarios:"); + jPanel12.add(jLabel61, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, -1, -1)); + + jLabel62.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel62.setText("No Seguidos:"); + jPanel12.add(jLabel62, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 20, -1, -1)); + + btnSeguir.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnSeguir.setText("Seguir"); + btnSeguir.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSeguirActionPerformed(evt); + } + }); + jPanel12.add(btnSeguir, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 370, 190, 40)); + + btnSalir.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnSalir.setText("salir"); + btnSalir.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSalirActionPerformed(evt); + } + }); + jPanel12.add(btnSalir, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 370, 120, 40)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 770, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, 770, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 430, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, 430, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed + //salir + try { + Sys.liberarMemoriaUsuarioActual(); + Sys.liberarMemoriaUsuario(); + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnSalirActionPerformed + + private void btnSeguirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSeguirActionPerformed + // TODO add your handling code here: + try { + Sys.seguirUsuario();// SEGUIR + String NickName = lstSeguidor.getSelectedValue(); + + DtUsuario user = Sys.seleccionarUsuario(NickName); + lstNoSeguido.setEnabled(true); + lstNoSeguido.clearSelection(); + + ArrayList<DtUsuario> NoSeguidos = Sys.listarUsuarioNoSeguidos(); + + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : NoSeguidos) { + modelo.addElement(it.getNickname()); + } + lstNoSeguido.setModel(modelo); + Sys.seleccionarUsuarioActual(NickName); + Sys.liberarMemoriaUsuario(); + //Sys.seguirUsuario(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnSeguirActionPerformed + + private void lstSeguidorValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstSeguidorValueChanged + // SegidoRRR + if (evt.getValueIsAdjusting()) { + return; + } + if (lstSeguidor.getSelectedIndex() < 0) { + return; + } + btnSeguir.setEnabled(false); + + String NickName = lstSeguidor.getSelectedValue(); + + try { + DtUsuario user = Sys.seleccionarUsuario(NickName); + lstNoSeguido.setEnabled(true); + lstNoSeguido.clearSelection(); + + ArrayList<DtUsuario> NoSeguidos = Sys.listarUsuarioNoSeguidos(); + + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : NoSeguidos) { + modelo.addElement(it.getNickname()); + } + lstNoSeguido.setModel(modelo); + Sys.seleccionarUsuarioActual(NickName); + Sys.liberarMemoriaUsuario(); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstSeguidorValueChanged + + private void lstNoSeguidoValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstNoSeguidoValueChanged + // Segidoooo + if (evt.getValueIsAdjusting()) { + return; + } + if (lstNoSeguido.getSelectedIndex() < 0) { + return; + } + + String Nickname = lstNoSeguido.getSelectedValue(); + //lstVideos.setEnabled(true); + + try { + DtUsuario user = Sys.seleccionarUsuario(Nickname); + btnSeguir.setEnabled(true); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstNoSeguidoValueChanged + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnSalir; + private javax.swing.JButton btnSeguir; + private javax.swing.JLabel jLabel61; + private javax.swing.JLabel jLabel62; + private javax.swing.JPanel jPanel12; + private javax.swing.JScrollPane jScrollPane11; + private javax.swing.JScrollPane jScrollPane12; + private javax.swing.JList<String> lstNoSeguido; + private javax.swing.JList<String> lstSeguidor; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Video/frmAltaVideo.form b/UyTube_logica/src/Presentacion/Video/frmAltaVideo.form new file mode 100644 index 0000000000000000000000000000000000000000..e7177c98fd5208bf2258856be8050f8701aff61f --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmAltaVideo.form @@ -0,0 +1,389 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Alta video"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/> + <EventHandler event="windowActivated" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowActivated"/> + </Events> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel14" min="-2" pref="980" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel14" alignment="0" pref="535" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel14"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel71"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Dueño del video:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane16"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="50" width="290" height="360"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstDuenioVideo"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstDuenioVideoValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel72"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="30" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel73"> + <Properties> + <Property name="text" type="java.lang.String" value="Segundos"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="560" y="100" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel74"> + <Properties> + <Property name="text" type="java.lang.String" value="URL:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="160" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel75"> + <Properties> + <Property name="text" type="java.lang.String" value="Descripción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="220" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel76"> + <Properties> + <Property name="text" type="java.lang.String" value="Fecha publicación:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="380" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel77"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Asignar categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="690" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane17"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="690" y="50" width="260" height="360"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstAsignarCategoria"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstAsignarCategoriaValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JTextField" name="txtNombre"> + <Events> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtNombreFocusGained"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="50" width="330" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtUrl"> + <Events> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtUrlFocusGained"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="180" width="330" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane18"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="240" width="330" height="120"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtDescripcion"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="690" y="440" width="260" height="70"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="440" width="290" height="70"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSpinner" name="spSegundos"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" maximum="59" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/> + </Property> + </Properties> + <Events> + <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spSegundosStateChanged"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="560" y="120" width="60" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSpinner" name="spHoras"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" maximum="15" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/> + </Property> + </Properties> + <Events> + <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spHorasStateChanged"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="420" y="120" width="60" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSpinner" name="spMinutos"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" maximum="59" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/> + </Property> + </Properties> + <Events> + <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spMinutosStateChanged"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="490" y="120" width="60" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel135"> + <Properties> + <Property name="text" type="java.lang.String" value="Duración:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="100" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel136"> + <Properties> + <Property name="text" type="java.lang.String" value="Horas"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="420" y="100" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel137"> + <Properties> + <Property name="text" type="java.lang.String" value="Minutos"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="490" y="100" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="com.toedter.calendar.JDateChooser" name="jDateChooser1"> + <Properties> + <Property name="maxSelectableDate" type="java.util.Date" editor="org.netbeans.beaninfo.editors.DateEditor"> + <SerializedValue value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,117,116,105,108,46,68,97,116,101,104,106,-127,1,75,89,116,25,3,0,0,120,112,119,8,0,0,2,75,-49,58,60,88,120"/> + </Property> + <Property name="minSelectableDate" type="java.util.Date" editor="org.netbeans.beaninfo.editors.DateEditor"> + <SerializedValue value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,117,116,105,108,46,68,97,116,101,104,106,-127,1,75,89,116,25,3,0,0,120,112,119,8,-1,-1,-3,-3,-81,8,28,-72,120"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="480" y="380" width="190" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjNombre"> + <Properties> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 15]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="70" width="330" height="15"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjUrl"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="200" width="330" height="15"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjFecha"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="430" width="250" height="15"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjDescripcion"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="370" width="330" height="15"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbMsjDuracion"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="340" y="140" width="330" height="15"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Video/frmAltaVideo.java b/UyTube_logica/src/Presentacion/Video/frmAltaVideo.java new file mode 100644 index 0000000000000000000000000000000000000000..728f0472d1a88756fff64b89d122fd9849b3171c --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmAltaVideo.java @@ -0,0 +1,547 @@ + +package Presentacion.Video; + +import Logica.Fabrica; +import Logica.Clases.Video; +import Logica.DataType.DtVideo; +import Logica.Enumerados.Privacidad; +import Logica.Interfaces.IAdmin; +import java.awt.Color; +import java.sql.Time; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import javax.swing.border.Border; +import javax.swing.plaf.ColorUIResource; + +public class frmAltaVideo extends javax.swing.JDialog { + + private ArrayList<String> indexDuenioVideo = new ArrayList(); + private ArrayList<String> indexCategorias = new ArrayList(); + private IAdmin sys; + private String categoria = ""; + private String usrSeleccionado = ""; + private Border bordeDefault; + private Color colorOK = new ColorUIResource(40,167,69); + private Color colorError = new ColorUIResource(220,53,69); + private String nombre = new String(); + private String url = new String(); + private String descripcion = new String(); + int anioActual,diaActual,mesActual; + + // Patrón para validar el email + Pattern patronURL = Pattern.compile("^((((https?|ftps?|gopher|telnet|nntp)://)|(mailto:|news:))(%[0-9A-Fa-f]{2}|[-()_.!~*’;/?:@&=+$, A-Za-z0-9])+)([).!’;/?:, ][[:blank:]])?$"); + + Pattern patronNombre= Pattern.compile("^([A-Za-zÑñÃáÉéÃÃÓóÚú0-9]+)\\s*([A-Za-zÑñÃáÉéÃÃÓóÚú0-9]+)\\s*" + + "([A-Za-zÑñÃáÉéÃÃÓóÚú0-9]+)$"); + public frmAltaVideo(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + sys = Fabrica.getInstancia().getIAdmin(); + bordeDefault = txtNombre.getBorder(); + nombre = ""; + url = ""; + descripcion = ""; + } + + private boolean validarDuracion(int s, int m, int h){ + if ( s > 0 || m > 0 || h > 0) { + return true; + } + lbMsjDuracion.setOpaque(true); + lbMsjDuracion.setForeground(Color.WHITE); + lbMsjDuracion.setBackground(colorError); + lbMsjDuracion.setText(" El campo duración es obligatorio"); + return false; + } + + private void limpiarCampos(){ + txtNombre.setText(""); + txtDescripcion.setText(""); + txtUrl.setText(""); + spHoras.setValue(0); + spMinutos.setValue(0); + spSegundos.setValue(0); + usrSeleccionado=""; + categoria = ""; + jDateChooser1.setDate(null); + } + + private void limpiarLstDuenios(){ + DefaultListModel modelo = new DefaultListModel(); + lstDuenioVideo.setModel(modelo); + indexDuenioVideo.clear(); + } + + private void limpiarLstCategorias(){ + DefaultListModel modelo = new DefaultListModel(); + lstAsignarCategoria.setModel(modelo); + indexCategorias.clear(); + } + + private boolean validarFormatoURL(String _url){ + Matcher mather = patronURL.matcher(_url); + if (mather.find() == true) { + return true; + } + return false; + } + + private boolean validarNombres(String _nombre){ + Matcher mather = patronNombre.matcher(_nombre); + if (mather.find() == true) { + return true; + } + return false; + } + + private boolean validarTxt(JTextField txt, int max,JLabel lb,String nombreCampo){ + try{ + if(txt.getText().length() > max ){ + lb.setText(" El campo supera los "+max+" caracteres"); + cambiarColoresError(txt, lb); + return false; + } + else if(txt.getText().equals("")){ + lb.setText(" El campo "+nombreCampo+" es obligatorio"); + cambiarColoresError(txt, lb); + return false; + } + else if(nombreCampo.equals("Nombre") ){ + for (DtVideo video : sys.listarVideosDeUsuario()) { + if(video.getNombre().equals(nombre)){ + lb.setText(" El nombre del video ya existe"); + cambiarColoresError(txt, lb); + return false; + } + } + } + else if(nombreCampo.equals("URL")){ + if(!validarFormatoURL(url)){ + lb.setText(" El formato de la URI no es válido"); + cambiarColoresError(txt, lb); + return false; + } + } + else{ + txt.setBorder(bordeDefault); + lb.setText(""); + lb.setOpaque(false); + } + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + return true; + } + + private void cambiarColoresError(JTextField txt, JLabel lb){ + lb.setOpaque(true); + lb.setForeground(Color.WHITE); + lb.setBackground(colorError); + txt.setBorder(BorderFactory.createLineBorder(colorError, 1)); + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel14 = new javax.swing.JPanel(); + jLabel71 = new javax.swing.JLabel(); + jScrollPane16 = new javax.swing.JScrollPane(); + lstDuenioVideo = new javax.swing.JList<>(); + jLabel72 = new javax.swing.JLabel(); + jLabel73 = new javax.swing.JLabel(); + jLabel74 = new javax.swing.JLabel(); + jLabel75 = new javax.swing.JLabel(); + jLabel76 = new javax.swing.JLabel(); + jLabel77 = new javax.swing.JLabel(); + jScrollPane17 = new javax.swing.JScrollPane(); + lstAsignarCategoria = new javax.swing.JList<>(); + txtNombre = new javax.swing.JTextField(); + txtUrl = new javax.swing.JTextField(); + jScrollPane18 = new javax.swing.JScrollPane(); + txtDescripcion = new javax.swing.JTextArea(); + btnAceptar = new javax.swing.JButton(); + btnCancelar = new javax.swing.JButton(); + spSegundos = new javax.swing.JSpinner(); + spHoras = new javax.swing.JSpinner(); + spMinutos = new javax.swing.JSpinner(); + jLabel135 = new javax.swing.JLabel(); + jLabel136 = new javax.swing.JLabel(); + jLabel137 = new javax.swing.JLabel(); + jDateChooser1 = new com.toedter.calendar.JDateChooser(); + lbMsjNombre = new javax.swing.JLabel(); + lbMsjUrl = new javax.swing.JLabel(); + lbMsjFecha = new javax.swing.JLabel(); + lbMsjDescripcion = new javax.swing.JLabel(); + lbMsjDuracion = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Alta video"); + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + public void windowActivated(java.awt.event.WindowEvent evt) { + formWindowActivated(evt); + } + }); + + jPanel14.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel71.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + jLabel71.setText("Dueño del video:"); + jPanel14.add(jLabel71, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1)); + + lstDuenioVideo.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstDuenioVideoValueChanged(evt); + } + }); + jScrollPane16.setViewportView(lstDuenioVideo); + + jPanel14.add(jScrollPane16, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 50, 290, 360)); + + jLabel72.setText("Nombre:"); + jPanel14.add(jLabel72, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 30, -1, -1)); + + jLabel73.setText("Segundos"); + jPanel14.add(jLabel73, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 100, -1, -1)); + + jLabel74.setText("URL:"); + jPanel14.add(jLabel74, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 160, -1, -1)); + + jLabel75.setText("Descripción:"); + jPanel14.add(jLabel75, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 220, -1, -1)); + + jLabel76.setText("Fecha publicación:"); + jPanel14.add(jLabel76, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 380, -1, -1)); + + jLabel77.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + jLabel77.setText("Asignar categorÃa:"); + jPanel14.add(jLabel77, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 20, -1, -1)); + + lstAsignarCategoria.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstAsignarCategoriaValueChanged(evt); + } + }); + jScrollPane17.setViewportView(lstAsignarCategoria); + + jPanel14.add(jScrollPane17, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 50, 260, 360)); + + txtNombre.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + txtNombreFocusGained(evt); + } + }); + jPanel14.add(txtNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 50, 330, -1)); + + txtUrl.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + txtUrlFocusGained(evt); + } + }); + jPanel14.add(txtUrl, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 180, 330, -1)); + + txtDescripcion.setColumns(20); + txtDescripcion.setRows(5); + jScrollPane18.setViewportView(txtDescripcion); + + jPanel14.add(jScrollPane18, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 240, 330, 120)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel14.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 440, 260, 70)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + jPanel14.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 440, 290, 70)); + + spSegundos.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1)); + spSegundos.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spSegundosStateChanged(evt); + } + }); + jPanel14.add(spSegundos, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 120, 60, -1)); + + spHoras.setModel(new javax.swing.SpinnerNumberModel(0, 0, 15, 1)); + spHoras.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spHorasStateChanged(evt); + } + }); + jPanel14.add(spHoras, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 120, 60, -1)); + + spMinutos.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1)); + spMinutos.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spMinutosStateChanged(evt); + } + }); + jPanel14.add(spMinutos, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 120, 60, -1)); + + jLabel135.setText("Duración:"); + jPanel14.add(jLabel135, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 100, -1, -1)); + + jLabel136.setText("Horas"); + jPanel14.add(jLabel136, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 100, -1, -1)); + + jLabel137.setText("Minutos"); + jPanel14.add(jLabel137, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 100, -1, -1)); + + jDateChooser1.setMaxSelectableDate(new java.util.Date(2524622503000L)); + jDateChooser1.setMinSelectableDate(new java.util.Date(-2208971613000L)); + jPanel14.add(jDateChooser1, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 380, 190, -1)); + + lbMsjNombre.setMaximumSize(new java.awt.Dimension(0, 15)); + lbMsjNombre.setMinimumSize(new java.awt.Dimension(0, 15)); + jPanel14.add(lbMsjNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 70, 330, 15)); + jPanel14.add(lbMsjUrl, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 200, 330, 15)); + jPanel14.add(lbMsjFecha, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 430, 250, 15)); + jPanel14.add(lbMsjDescripcion, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 370, 330, 15)); + jPanel14.add(lbMsjDuracion, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 140, 330, 15)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, 980, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + jDateChooser1.setBorder(bordeDefault); + lbMsjFecha.setText(""); + lbMsjFecha.setOpaque(false); + nombre = txtNombre.getText().trim();//Obtiene el nombre y quita los espacios de los extremos + descripcion = txtDescripcion.getText().trim();//Obtiene la descripcion y quita los espacios de los extremos + url = txtUrl.getText().trim();//Obtiene la url y quita los espacios de los extremos + int horas = (Integer)spHoras.getValue(); + int minutos = (Integer)spMinutos.getValue(); + int segundos = (Integer)spSegundos.getValue(); + Time duracion = new Time(horas, minutos, segundos); + java.sql.Date fecha = null; + //Verifica que la fecha no sea nula y la guarda en el formato correcto + if( jDateChooser1.getDate() != null){ + java.util.Date utilDate = jDateChooser1.getDate();//Obtiene la fecha del JDateChooser en formato Date + fecha = new java.sql.Date(utilDate.getTime());//Lo combierte al tipo Date sql + } + //Arrays para validaciones campos de texto + JTextField v1[] = {txtNombre,txtUrl}; //campos a validar + int[] v2= {100,2083}; //Largos maximos de los campos Nombre y URL + JLabel[] v3= { lbMsjNombre, lbMsjUrl}; //labels para mostrar mensajes + String[] v4 ={"Nombre","URL","Descricion"};//Nombre del campo + boolean[] v5 ={false,false,false};//Estado inicial de las validaciones, cada elemento es una validacion de un campo especifico + for (int i = 0; i < v5.length-1; i++) { + if (validarTxt(v1[i], v2[i], v3[i], v4[i])) { + v5[i] = true; + } + } + if(validarDuracion(segundos, minutos, horas)){ + v5[2] = true; + } + if (fecha == null) { + jDateChooser1.setBorder(BorderFactory.createLineBorder(colorError, 1)); + lbMsjFecha.setText(" La fecha es obligatoria"); + lbMsjFecha.setOpaque(true); + lbMsjFecha.setForeground(Color.WHITE); + lbMsjFecha.setBackground(colorError); + } + if(v5[0]==false|| v5[1]==false || v5[2]==false){ + return; + } + try { + DtVideo dtVideo = new DtVideo(0, nombre, descripcion, duracion, fecha, url, Privacidad.PRIVADO, categoria, 0, 0); + int opcion=JOptionPane.showConfirmDialog(null, + "¿Desea guardar el video \""+nombre+"\"?" + , "Confirmar alta de Video", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if(opcion==0){ + sys.altaVideo(dtVideo); + limpiarCampos(); + } + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnAceptarActionPerformed + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + limpiarLstDuenios(); + limpiarLstCategorias(); + limpiarCampos(); + this.setVisible(false);//Oculta el formulario AltaVideo + }//GEN-LAST:event_btnCancelarActionPerformed + + private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated + DefaultListModel modeloDuenio = new DefaultListModel(); + DefaultListModel modeloCategoria = new DefaultListModel(); + Calendar c = new GregorianCalendar();//Objeto de tipo calendario con la fecha actual + java.util.Date fechaActual = new Date(c.get(Calendar.YEAR)-1900,c.get(Calendar.MONTH),c.get(Calendar.DATE));//Obtiene la fecha actual del calendario + jDateChooser1.setDate(fechaActual);//Setea el JDateChooser con la fecha actual + try { + // Obtengo todos los nickname y los cargo en el listDuenioVideo(Lista de dueños de videos) + limpiarLstCategorias(); + limpiarLstDuenios(); + if (!sys.listarUsuarios().isEmpty()) { + for (int i = 0; i < sys.listarUsuarios().size(); i++) { + modeloDuenio.add(i, sys.listarUsuarios().get(i).getNickname()); + } + lstDuenioVideo.setModel(modeloDuenio); + lstDuenioVideo.setSelectedIndex(0);//Setea la lista en el primer usuario + usrSeleccionado = lstDuenioVideo.getSelectedValue(); + sys.seleccionarUsuario(usrSeleccionado); + } + // Obtengo todas las categorias de video y las muestro en la lista + if (!sys.listarCategorias().isEmpty()) { + for (int i = 0; i < sys.listarCategorias().size(); i++) { + modeloCategoria.add(i, sys.listarCategorias().get(i)); + indexCategorias.add(i, sys.listarCategorias().get(i));//Alamacena cada categoria obtenida en el mismo orde + } + lstAsignarCategoria.setModel(modeloCategoria); + //Setea la lista Categoria en el elemento UNDEFINE + for (int i = 0; i < indexCategorias.size(); i++) { + if( indexCategorias.get(i).equals("UNDEFINED") ){ + lstAsignarCategoria.setSelectedIndex(i); + categoria = lstAsignarCategoria.getSelectedValue(); + break; + } + } + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_formWindowActivated + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + // Al cerrar el formulario se borran todos los datos + limpiarCampos(); + limpiarLstCategorias(); + limpiarLstDuenios(); + }//GEN-LAST:event_formWindowClosing + + private void lstDuenioVideoValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstDuenioVideoValueChanged + if (evt.getValueIsAdjusting()) return; + if (lstDuenioVideo.getSelectedIndex()<0) return; + try { + // El sistema selecciona al usuario actual con el nickname seleccionado de la lista + usrSeleccionado = lstDuenioVideo.getSelectedValue(); + sys.seleccionarUsuario(usrSeleccionado); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstDuenioVideoValueChanged + + private void lstAsignarCategoriaValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstAsignarCategoriaValueChanged + if (evt.getValueIsAdjusting()) return; + if (lstAsignarCategoria.getSelectedIndex()<0) return; + try { + // Selecciona una categoria de la lista de categorias + categoria = lstAsignarCategoria.getSelectedValue(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstAsignarCategoriaValueChanged + + private void txtNombreFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNombreFocusGained + //Al recibir el foco restaura los valores + txtNombre.setBorder(bordeDefault); + lbMsjNombre.setText(""); + lbMsjNombre.setOpaque(false); + }//GEN-LAST:event_txtNombreFocusGained + + private void txtUrlFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtUrlFocusGained + //Al recibir el foco restaura los valores + txtUrl.setBorder(bordeDefault); + lbMsjUrl.setText(""); + lbMsjUrl.setOpaque(false); + }//GEN-LAST:event_txtUrlFocusGained + + private void spSegundosStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spSegundosStateChanged + // Al cambiar el valor verifica y restaura los valores + if(validarDuracion((Integer)spSegundos.getValue(),(Integer)spMinutos.getValue(),(Integer)spHoras.getValue())){ + lbMsjDuracion.setText(""); + lbMsjDuracion.setOpaque(false); + } + }//GEN-LAST:event_spSegundosStateChanged + + private void spMinutosStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spMinutosStateChanged + // Al cambiar el valor verifica y restaura los valores + if(validarDuracion((Integer)spSegundos.getValue(),(Integer)spMinutos.getValue(),(Integer)spHoras.getValue())){ + lbMsjDuracion.setText(""); + lbMsjDuracion.setOpaque(false); + } + }//GEN-LAST:event_spMinutosStateChanged + + private void spHorasStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spHorasStateChanged + // Al cambiar el valor verifica y restaura los valores + if(validarDuracion((Integer)spSegundos.getValue(),(Integer)spMinutos.getValue(),(Integer)spHoras.getValue())){ + lbMsjDuracion.setText(""); + lbMsjDuracion.setOpaque(false); + } + }//GEN-LAST:event_spHorasStateChanged + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JButton btnCancelar; + private com.toedter.calendar.JDateChooser jDateChooser1; + private javax.swing.JLabel jLabel135; + private javax.swing.JLabel jLabel136; + private javax.swing.JLabel jLabel137; + private javax.swing.JLabel jLabel71; + private javax.swing.JLabel jLabel72; + private javax.swing.JLabel jLabel73; + private javax.swing.JLabel jLabel74; + private javax.swing.JLabel jLabel75; + private javax.swing.JLabel jLabel76; + private javax.swing.JLabel jLabel77; + private javax.swing.JPanel jPanel14; + private javax.swing.JScrollPane jScrollPane16; + private javax.swing.JScrollPane jScrollPane17; + private javax.swing.JScrollPane jScrollPane18; + private javax.swing.JLabel lbMsjDescripcion; + private javax.swing.JLabel lbMsjDuracion; + private javax.swing.JLabel lbMsjFecha; + private javax.swing.JLabel lbMsjNombre; + private javax.swing.JLabel lbMsjUrl; + private javax.swing.JList<String> lstAsignarCategoria; + private javax.swing.JList<String> lstDuenioVideo; + private javax.swing.JSpinner spHoras; + private javax.swing.JSpinner spMinutos; + private javax.swing.JSpinner spSegundos; + private javax.swing.JTextArea txtDescripcion; + private javax.swing.JTextField txtNombre; + private javax.swing.JTextField txtUrl; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Video/frmComentarVideo.form b/UyTube_logica/src/Presentacion/Video/frmComentarVideo.form new file mode 100644 index 0000000000000000000000000000000000000000..2f8df03cddcbc6ebc655be32c99ffcdbcca42790 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmComentarVideo.form @@ -0,0 +1,314 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.7" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Comentar video"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="980" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel6" min="-2" pref="980" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="550" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel6" min="-2" pref="550" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel6"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane3"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="210" y="280" width="310" height="90"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="AreaComentario"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="rows" type="int" value="5"/> + <Property name="toolTipText" type="java.lang.String" value="Ingrese aqui nuevo comentario"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnComentar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Comentar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnComentarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="310" y="460" width="210" height="60"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane4"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="50" width="400" height="380"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTree" name="ArbolComentarios"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.tree.TreeModel" editor="org.netbeans.modules.form.editors2.TreeModelEditor"> + <TreeModel code=""/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Cursor de Mano"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="740" y="460" width="210" height="60"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel15"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Comentarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="550" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel35"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Texto del comentario:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="210" y="250" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane6"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="50" width="150" height="150"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuario"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuarioValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel45"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuario que comenta:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="250" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane52"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="210" y="50" width="310" height="150"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideos"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstVideosValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel150"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Videos:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="210" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="280" width="150" height="150"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarioComentador"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Seleccione usuario que realizara el nuevo comentario"/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuarioComentadorValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel50"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Propietario del video:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="com.toedter.calendar.JDateChooser" name="DateCh"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="370" y="390" width="150" height="30"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Fecha del comentario:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="210" y="390" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Video/frmComentarVideo.java b/UyTube_logica/src/Presentacion/Video/frmComentarVideo.java new file mode 100644 index 0000000000000000000000000000000000000000..0f7c37ddd51b722abe8f3780f77d8dd68df02660 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmComentarVideo.java @@ -0,0 +1,450 @@ +package Presentacion.Video; + +import Logica.DataType.DtComentario; +import Logica.DataType.DtUsuario; +import Logica.DataType.DtVideo; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.sql.Date; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + +public class frmComentarVideo extends javax.swing.JDialog { + + private IAdmin Sys; + private ArrayList<DtVideo> VideosDelUser; + private ArrayList<DtComentario> ComentariosDelVideo; + + public frmComentarVideo(java.awt.Frame parent, boolean modal) { + super(parent, modal); + try { + initComponents(); + this.setLocationRelativeTo(null); + Fabrica f = Fabrica.getInstancia(); + Sys = f.getIAdmin(); + + Sys.liberarMemoriaVideo(); + Sys.liberarMemoriaUsuarioActual(); + Sys.liberarMemoriaUsuario(); + + // quita el icono de carpetas en el JTree de comentarios + javax.swing.tree.DefaultTreeCellRenderer render = (javax.swing.tree.DefaultTreeCellRenderer) ArbolComentarios.getCellRenderer(); + render.setLeafIcon(null); + render.setOpenIcon(null); + render.setClosedIcon(null); + + ArrayList<DtUsuario> ListaUsuarios = Sys.listarUsuarios(); + + DefaultListModel modelo = new DefaultListModel(); + DefaultListModel modelo2 = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + modelo2.addElement(it.getNickname()); + } + lstUsuario.setModel(modelo); + lstUsuarioComentador.setModel(modelo2); + + limpiarComponentesComentario(false); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel6 = new javax.swing.JPanel(); + jScrollPane3 = new javax.swing.JScrollPane(); + AreaComentario = new javax.swing.JTextArea(); + btnComentar = new javax.swing.JButton(); + jScrollPane4 = new javax.swing.JScrollPane(); + ArbolComentarios = new javax.swing.JTree(); + btnAceptar = new javax.swing.JButton(); + jLabel15 = new javax.swing.JLabel(); + jLabel35 = new javax.swing.JLabel(); + jScrollPane6 = new javax.swing.JScrollPane(); + lstUsuario = new javax.swing.JList<>(); + jLabel45 = new javax.swing.JLabel(); + jScrollPane52 = new javax.swing.JScrollPane(); + lstVideos = new javax.swing.JList<>(); + jLabel150 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + lstUsuarioComentador = new javax.swing.JList<>(); + jLabel50 = new javax.swing.JLabel(); + DateCh = new com.toedter.calendar.JDateChooser(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Comentar video"); + setResizable(false); + + jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + AreaComentario.setColumns(20); + AreaComentario.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + AreaComentario.setRows(5); + AreaComentario.setToolTipText("Ingrese aqui nuevo comentario"); + jScrollPane3.setViewportView(AreaComentario); + + jPanel6.add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 280, 310, 90)); + + btnComentar.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N + btnComentar.setText("Comentar"); + btnComentar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnComentarActionPerformed(evt); + } + }); + jPanel6.add(btnComentar, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 460, 210, 60)); + + ArbolComentarios.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N + javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root"); + ArbolComentarios.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); + ArbolComentarios.setToolTipText(""); + ArbolComentarios.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); + jScrollPane4.setViewportView(ArbolComentarios); + + jPanel6.add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 50, 400, 380)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel6.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 460, 210, 60)); + + jLabel15.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel15.setText("Comentarios:"); + jPanel6.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 20, -1, -1)); + + jLabel35.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel35.setText("Texto del comentario:"); + jPanel6.add(jLabel35, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 250, -1, -1)); + + lstUsuario.setToolTipText(""); + lstUsuario.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuarioValueChanged(evt); + } + }); + jScrollPane6.setViewportView(lstUsuario); + + jPanel6.add(jScrollPane6, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 50, 150, 150)); + + jLabel45.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel45.setText("Usuario que comenta:"); + jPanel6.add(jLabel45, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 250, -1, -1)); + + lstVideos.setToolTipText(""); + lstVideos.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstVideosValueChanged(evt); + } + }); + jScrollPane52.setViewportView(lstVideos); + + jPanel6.add(jScrollPane52, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 50, 310, 150)); + + jLabel150.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel150.setText("Videos:"); + jPanel6.add(jLabel150, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 20, -1, -1)); + + lstUsuarioComentador.setToolTipText("Seleccione usuario que realizara el nuevo comentario"); + lstUsuarioComentador.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuarioComentadorValueChanged(evt); + } + }); + jScrollPane1.setViewportView(lstUsuarioComentador); + + jPanel6.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 280, 150, 150)); + + jLabel50.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel50.setText("Propietario del video:"); + jPanel6.add(jLabel50, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1)); + jPanel6.add(DateCh, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 390, 150, 30)); + + jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel1.setText("Fecha del comentario:"); + jPanel6.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 390, -1, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 980, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 980, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 550, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 550, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + + private boolean isSelected(TreePath d) { + boolean b; + try { + DefaultMutableTreeNode l = (DefaultMutableTreeNode) d.getLastPathComponent(); + b = true; + } catch (Exception e) { + b = false; + } + return b; + } + + private void agregarNodoATree(ArrayList<DtComentario> l, int e, DefaultMutableTreeNode nodoPadre) { + // si el array vacio, no hay nada que hacer + if (e == l.size()) { + return; + } + // guardo el nivel del prmer comentario con el que se trabajara (no siempre sera el primer elemento del array) + int nivelActual = l.get(e).getNivelSubComentario(); + // Variable para el nuevo comentario a procesar + DefaultMutableTreeNode nodoComentario = null; + // sera true si se ebe llamar a la recursividad + boolean llamarRecursividad = false; + + // recorre los elementos desde el indice pasado como parametro hasta el final del array + for (; e < l.size(); e++) { + // variable del comentario para trabajar en esta iteracion del for + DtComentario coment = l.get(e); + + if (coment.getNivelSubComentario() == nivelActual) { + // Si el coment esta al nivel a partir del cual se procesara + // extrae los datos en un string + String textoAMostrar = coment.getNickname() + ": " + coment.getTexto(); + //String textoAMostrar = coment.getNickname() + ": " + coment.getTexto() +coment.getFecha().toString(); + // instancia el nodo con los datos + nodoComentario = new DefaultMutableTreeNode(textoAMostrar); + // lo agrega como hijo del nodo padre recibido como parametro + nodoPadre.add(nodoComentario); + // activa la recursividad en caso de que se encuentren hijos del comentario + llamarRecursividad = true; + } else if (coment.getNivelSubComentario() > nivelActual) { + // Si el comentario de esta iteracion es menor que el nivel a procesar + + // si hay que llamar recursividd + if (llamarRecursividad) { + // llama a recursividad pero pasando como nodo padre al comentario recien creado + agregarNodoATree(l, e, nodoComentario); + // en este punto ya se han agregado todos los hijos y nietos del comentario recien creado + // asi que ya no hay que llamar recursividad hasta agregar otro nodo en el primer if + llamarRecursividad = false; + } + } else { + // si se encuentra un comentario de menor nivel al que se esta procesando + // debe salir, esa es otra familia de comentarios + return; + } + } + } + + private int obtenerIndexComentarioSeleccionadoEnJTree(javax.swing.JTree arbol) { + // Jtree auxiliar + javax.swing.JTree aux = new javax.swing.JTree(arbol.getModel()); + // expande los nodos del JTree auxiliar + for (int i = 0; i < aux.getRowCount(); i++) { + aux.expandRow(i); + } + // Obtiene el numero de fila del elemento seleccionado + // basandose en la ruta hasta el elemento + return aux.getRowForPath(arbol.getSelectionPath()) - 1; + } + private void btnComentarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnComentarActionPerformed + //Video->comentar video->comentar + try { + if (lstUsuarioComentador.getSelectedIndex() < 0){ + JOptionPane.showMessageDialog(null, "No ha seleccionado el usuario que realizará el comentario!", "¡Atención!", JOptionPane.WARNING_MESSAGE); + return; + } + if (AreaComentario.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "No ha escrito el comentario!", "¡Atención!", JOptionPane.WARNING_MESSAGE); + return; + } + if (DateCh.getDate() == null) { + JOptionPane.showMessageDialog(null, "No ha seleccionado el usuario que realizará el comentario!", "¡Atención!", JOptionPane.WARNING_MESSAGE); + return; + } + + java.sql.Date fecha = null; + java.util.Date utilDate = DateCh.getDate();//Obtiene la fecha del JDateChooser en formato Date + fecha = new java.sql.Date(utilDate.getTime());//Lo combierte al tipo Date sql + + DtComentario dtc = new DtComentario(WIDTH, "", fecha, AreaComentario.getText(), 0); + + int index = obtenerIndexComentarioSeleccionadoEnJTree(ArbolComentarios); + if (index < 0) { + Sys.altaComentario(dtc); + } else { + ComentariosDelVideo = Sys.listarComentariosDeVideo(); + int comPad = ComentariosDelVideo.get(index).getId(); + Sys.altaComentario(dtc, comPad); + } + mostrarComentarios(Sys.listarComentariosDeVideo()); + AreaComentario.setText(""); //hacer esto en una funcion no seas desprolijo! + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnComentarActionPerformed + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + try { + if (!AreaComentario.getText().isEmpty()) { + int resp = JOptionPane.showConfirmDialog(null, "No se ha realizado el comentario\n¿Seguro que desea salir?", "¿Seguro que desea salir?", JOptionPane.YES_NO_OPTION);//yes 0, no 1. + if (resp == 0) { + Sys.liberarMemoriaVideo(); + Sys.liberarMemoriaUsuarioActual(); + Sys.liberarMemoriaUsuario(); + dispose(); + } + } else { + Sys.liberarMemoriaVideo(); + Sys.liberarMemoriaUsuarioActual(); + Sys.liberarMemoriaUsuario(); + dispose(); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnAceptarActionPerformed + + private void mostrarComentarios(ArrayList<DtComentario> ComentariosDelVideo) { + + DefaultMutableTreeNode raiz = new DefaultMutableTreeNode("Comentarios:"); + agregarNodoATree(ComentariosDelVideo, 0, raiz); + TreeModel datos = new DefaultTreeModel(raiz); + ArbolComentarios.setModel(datos); + for (int i = 0; i < ArbolComentarios.getRowCount(); i++) {//expande los nodos + ArbolComentarios.expandRow(i); + } + } + + private void limpiarComponentesComentario(boolean habilitado){ + + lstUsuarioComentador.clearSelection(); + lstUsuarioComentador.setEnabled(habilitado); + + AreaComentario.setText(""); + AreaComentario.setEnabled(habilitado); + + DateCh.setEnabled(habilitado); + btnComentar.setEnabled(habilitado); + + java.util.Date hoyAhora = new java.util.Date(); + DateCh.setDate(hoyAhora); + + mostrarComentarios(new ArrayList<>()); + ArbolComentarios.setEnabled(habilitado); + } + + private void lstUsuarioValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuarioValueChanged + // Usuario seleccionado + if (evt.getValueIsAdjusting()) { + return; + } + if (lstUsuario.getSelectedIndex() < 0) { + return; + } + + lstVideos.clearSelection(); + String Nickname = lstUsuario.getSelectedValue(); + //lstVideos.setEnabled(true); + + try { + DtUsuario user = Sys.seleccionarUsuario(Nickname); + VideosDelUser = Sys.listarVideosDeUsuario(); + + DefaultListModel modelo = new DefaultListModel(); + for (DtVideo it : VideosDelUser) { + modelo.addElement(it.getNombre()); + } + lstVideos.setModel(modelo); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstUsuarioValueChanged + + private void lstVideosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstVideosValueChanged + if (evt.getValueIsAdjusting()) { + return; + } + if (lstVideos.getSelectedIndex() < 0) { + limpiarComponentesComentario(false); + return; + } + limpiarComponentesComentario(true); + try { + //lstUsuarioValoradoR.clearSelection(); + int VideoIndex = lstVideos.getSelectedIndex(); + int IDvideo = VideosDelUser.get(VideoIndex).getId(); + Sys.seleccionarVideo(IDvideo); + + mostrarComentarios(Sys.listarComentariosDeVideo()); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstVideosValueChanged + + private void lstUsuarioComentadorValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuarioComentadorValueChanged + // Usuario seleccionado + if (evt.getValueIsAdjusting()) { + return; + } + if (lstUsuarioComentador.getSelectedIndex() < 0) { + return; + } + + String Nickname = lstUsuarioComentador.getSelectedValue(); + + try { + DtUsuario user = Sys.seleccionarUsuarioActual(Nickname); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstUsuarioComentadorValueChanged + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTree ArbolComentarios; + private javax.swing.JTextArea AreaComentario; + private com.toedter.calendar.JDateChooser DateCh; + private javax.swing.JButton btnAceptar; + private javax.swing.JButton btnComentar; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel150; + private javax.swing.JLabel jLabel35; + private javax.swing.JLabel jLabel45; + private javax.swing.JLabel jLabel50; + private javax.swing.JPanel jPanel6; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JScrollPane jScrollPane4; + private javax.swing.JScrollPane jScrollPane52; + private javax.swing.JScrollPane jScrollPane6; + private javax.swing.JList<String> lstUsuario; + private javax.swing.JList<String> lstUsuarioComentador; + private javax.swing.JList<String> lstVideos; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Video/frmConsultaVideo.form b/UyTube_logica/src/Presentacion/Video/frmConsultaVideo.form new file mode 100644 index 0000000000000000000000000000000000000000..14b7196b9ca79a046b48a60ef986a01aef629025 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmConsultaVideo.form @@ -0,0 +1,432 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.7" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Consultar video"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="1069" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Component id="jPanel15" alignment="0" pref="1069" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="592" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Component id="jPanel15" alignment="0" pref="592" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel15"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel81"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Dueño del video:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane22"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="50" width="140" height="300"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstDuenioVideo"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstDuenioVideoValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel82"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Comentarios:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="670" y="220" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane23"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="190" y="50" width="160" height="300"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideoUsuario"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstVideoUsuarioValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel83"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel84"> + <Properties> + <Property name="text" type="java.lang.String" value="Duración:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="80" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel85"> + <Properties> + <Property name="text" type="java.lang.String" value="URL:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="110" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel86"> + <Properties> + <Property name="text" type="java.lang.String" value="Descripción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="230" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane24"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="250" width="270" height="130"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtDescripcion"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="columns" type="int" value="20"/> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel87"> + <Properties> + <Property name="text" type="java.lang.String" value="Privacidad:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="170" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel88"> + <Properties> + <Property name="text" type="java.lang.String" value="Categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="200" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbNombre"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="460" y="50" width="580" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbDuracion"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="460" y="80" width="580" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbUrl"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lbUrlMousePressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="460" y="110" width="580" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbPrivacidad"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="460" y="170" width="580" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCategoria"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="460" y="200" width="580" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="670" y="510" width="380" height="60"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel94"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Les gustó:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="400" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel95"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="No les gustó:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="350" y="400" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane25"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="430" width="290" height="140"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstLike"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane26"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="350" y="430" width="300" height="140"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstDislike"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane27"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="670" y="250" width="380" height="230"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTree" name="treeComentarios"> + <Properties> + <Property name="model" type="javax.swing.tree.TreeModel" editor="org.netbeans.modules.form.editors2.TreeModelEditor"> + <TreeModel code=""/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel99"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Video del Usuario:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="190" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCantDisLikes"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="400" width="200" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCantLikes"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="110" y="400" width="200" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel89"> + <Properties> + <Property name="text" type="java.lang.String" value="Publicación:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="140" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbFechaPublicacion"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="460" y="140" width="580" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Video/frmConsultaVideo.java b/UyTube_logica/src/Presentacion/Video/frmConsultaVideo.java new file mode 100644 index 0000000000000000000000000000000000000000..5b03509211fa2cbffee8da977c81a32d42445fa2 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmConsultaVideo.java @@ -0,0 +1,507 @@ + +package Presentacion.Video; + +import Logica.DataType.DtComentario; +import Logica.DataType.DtUsuario; +import Logica.DataType.DtValoracion; +import Logica.DataType.DtVideo; +import Logica.Enumerados.TipoValoracion; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.util.ArrayList; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeModel; + +public class frmConsultaVideo extends javax.swing.JDialog { + + private IAdmin sys; + private ArrayList<DtVideo> listaDeVideos; + private String enlace = ""; + private boolean liberarMemoria; + + public frmConsultaVideo(java.awt.Frame parent, boolean modal) { + // Constructor para abrir ventana desde la ventana principal + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + limpiarElementosDeVentana(); + liberarMemoria = true; + + // quita el icono de carpetas en el JTree de comentarios + javax.swing.tree.DefaultTreeCellRenderer render = (javax.swing.tree.DefaultTreeCellRenderer) treeComentarios.getCellRenderer(); + render.setLeafIcon(null); + render.setOpenIcon(null); + render.setClosedIcon(null); + + try { + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // lista usuarios en el JList + mostrarListaDeUsuarios(sys.listarUsuarios()); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + + } + + public frmConsultaVideo(javax.swing.JDialog parent, boolean modal, String nickname, int idVideo) { + // Constructor para abrir ventana desde otro caso de uso + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + limpiarElementosDeVentana(); + liberarMemoria = false; + + // quita el icono de carpetas en el JTree de comentarios + javax.swing.tree.DefaultTreeCellRenderer render = (javax.swing.tree.DefaultTreeCellRenderer) treeComentarios.getCellRenderer(); + render.setLeafIcon(null); + render.setOpenIcon(null); + render.setClosedIcon(null); + + try { + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // El sistema ya tiene un usuario seleccionado + // El sistema ya tiene un video seleccionado + + // lista usuarios en el JList + mostrarListaDeUsuarios(sys.listarUsuarios()); + lstDuenioVideo.setSelectedValue(nickname, true); + lstVideoUsuario.setSelectedValue(sys.seleccionarVideo(idVideo).getNombre(), true); + //mostrarListaDeVideos(sys.listarVideosDeUsuario()); + + lstDuenioVideo.setEnabled(false); + lstVideoUsuario.setEnabled(false); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel15 = new javax.swing.JPanel(); + jLabel81 = new javax.swing.JLabel(); + jScrollPane22 = new javax.swing.JScrollPane(); + lstDuenioVideo = new javax.swing.JList<>(); + jLabel82 = new javax.swing.JLabel(); + jScrollPane23 = new javax.swing.JScrollPane(); + lstVideoUsuario = new javax.swing.JList<>(); + jLabel83 = new javax.swing.JLabel(); + jLabel84 = new javax.swing.JLabel(); + jLabel85 = new javax.swing.JLabel(); + jLabel86 = new javax.swing.JLabel(); + jScrollPane24 = new javax.swing.JScrollPane(); + txtDescripcion = new javax.swing.JTextArea(); + jLabel87 = new javax.swing.JLabel(); + jLabel88 = new javax.swing.JLabel(); + lbNombre = new javax.swing.JLabel(); + lbDuracion = new javax.swing.JLabel(); + lbUrl = new javax.swing.JLabel(); + lbPrivacidad = new javax.swing.JLabel(); + lbCategoria = new javax.swing.JLabel(); + btnAceptar = new javax.swing.JButton(); + jLabel94 = new javax.swing.JLabel(); + jLabel95 = new javax.swing.JLabel(); + jScrollPane25 = new javax.swing.JScrollPane(); + lstLike = new javax.swing.JList<>(); + jScrollPane26 = new javax.swing.JScrollPane(); + lstDislike = new javax.swing.JList<>(); + jScrollPane27 = new javax.swing.JScrollPane(); + treeComentarios = new javax.swing.JTree(); + jLabel99 = new javax.swing.JLabel(); + lbCantDisLikes = new javax.swing.JLabel(); + lbCantLikes = new javax.swing.JLabel(); + jLabel89 = new javax.swing.JLabel(); + lbFechaPublicacion = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Consultar video"); + setResizable(false); + + jPanel15.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel81.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel81.setText("Dueño del video:"); + jPanel15.add(jLabel81, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1)); + + lstDuenioVideo.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstDuenioVideoValueChanged(evt); + } + }); + jScrollPane22.setViewportView(lstDuenioVideo); + + jPanel15.add(jScrollPane22, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 50, 140, 300)); + + jLabel82.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel82.setText("Comentarios:"); + jPanel15.add(jLabel82, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 220, -1, -1)); + + lstVideoUsuario.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstVideoUsuarioValueChanged(evt); + } + }); + jScrollPane23.setViewportView(lstVideoUsuario); + + jPanel15.add(jScrollPane23, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 50, 160, 300)); + + jLabel83.setText("Nombre:"); + jPanel15.add(jLabel83, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 50, -1, -1)); + + jLabel84.setText("Duración:"); + jPanel15.add(jLabel84, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 80, -1, -1)); + + jLabel85.setText("URL:"); + jPanel15.add(jLabel85, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 110, -1, -1)); + + jLabel86.setText("Descripción:"); + jPanel15.add(jLabel86, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 230, -1, -1)); + + txtDescripcion.setEditable(false); + txtDescripcion.setColumns(20); + txtDescripcion.setLineWrap(true); + txtDescripcion.setRows(5); + jScrollPane24.setViewportView(txtDescripcion); + + jPanel15.add(jScrollPane24, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 250, 270, 130)); + + jLabel87.setText("Privacidad:"); + jPanel15.add(jLabel87, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 170, -1, -1)); + + jLabel88.setText("CategorÃa:"); + jPanel15.add(jLabel88, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 200, -1, -1)); + + lbNombre.setText(" "); + jPanel15.add(lbNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 50, 580, -1)); + + lbDuracion.setText(" "); + jPanel15.add(lbDuracion, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 80, 580, -1)); + + lbUrl.setText(" "); + lbUrl.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + lbUrlMousePressed(evt); + } + }); + jPanel15.add(lbUrl, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 110, 580, -1)); + + lbPrivacidad.setText(" "); + jPanel15.add(lbPrivacidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 170, 580, -1)); + + lbCategoria.setText(" "); + jPanel15.add(lbCategoria, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 200, 580, -1)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel15.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 510, 380, 60)); + + jLabel94.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel94.setText("Les gustó:"); + jPanel15.add(jLabel94, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 400, -1, -1)); + + jLabel95.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel95.setText("No les gustó:"); + jPanel15.add(jLabel95, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 400, -1, -1)); + + jScrollPane25.setViewportView(lstLike); + + jPanel15.add(jScrollPane25, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 430, 290, 140)); + + jScrollPane26.setViewportView(lstDislike); + + jPanel15.add(jScrollPane26, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 430, 300, 140)); + + javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root"); + treeComentarios.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); + jScrollPane27.setViewportView(treeComentarios); + + jPanel15.add(jScrollPane27, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 250, 380, 230)); + + jLabel99.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel99.setText("Video del Usuario:"); + jPanel15.add(jLabel99, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 20, -1, -1)); + + lbCantDisLikes.setText(" "); + jPanel15.add(lbCantDisLikes, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 400, 200, 20)); + + lbCantLikes.setText(" "); + jPanel15.add(lbCantLikes, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 400, 200, 20)); + + jLabel89.setText("Publicación:"); + jPanel15.add(jLabel89, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 140, -1, -1)); + + lbFechaPublicacion.setText(" "); + jPanel15.add(lbFechaPublicacion, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 140, 580, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 1069, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, 1069, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 592, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + // boton aceptar + try { + if (liberarMemoria){ + sys.liberarMemoriaUsuario(); + } + sys.liberarMemoriaVideo(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + }finally{ + dispose(); + } + }//GEN-LAST:event_btnAceptarActionPerformed + + private void lstDuenioVideoValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstDuenioVideoValueChanged + // seleccionar usuario + if (evt.getValueIsAdjusting()) return; + if (lstDuenioVideo.getSelectedIndex()<0) return; + try { + String nick = lstDuenioVideo.getSelectedValue(); + sys.seleccionarUsuario(nick); + listaDeVideos = sys.listarVideosDeUsuario(); + mostrarListaDeVideos(listaDeVideos); + limpiarElementosDeVentana(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstDuenioVideoValueChanged + + private void lstVideoUsuarioValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstVideoUsuarioValueChanged + // seleccionar video + if (evt.getValueIsAdjusting()) return; + if (lstVideoUsuario.getSelectedIndex()<0) return; + try { + int indexSeleccionado = lstVideoUsuario.getSelectedIndex(); + int idVideo = listaDeVideos.get(indexSeleccionado).getId(); + DtVideo dtv = sys.seleccionarVideo(idVideo); + mostrarDatosDeVideo(dtv); + mostrarListasDrValoraciones(sys.obtenerValoracionesDeVideo()); + mostrarListaDeComentarios(sys.listarComentariosDeVideo()); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstVideoUsuarioValueChanged + + private void lbUrlMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbUrlMousePressed + // al cloquear sobre la URL del video + if (lbUrl.getText().isEmpty() || enlace.isEmpty()) return; + + // Fuente: + // http://www.forosdelweb.com/f45/jlabel-como-hipervinculo-netbeans-948388/ + try { + if (java.awt.Desktop.isDesktopSupported()) { + java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); + if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { + desktop.browse(new java.net.URI(enlace)); + } + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lbUrlMousePressed + + /////////////////////////////////////////////////////////////////////////////////////////// + private void mostrarListaDeUsuarios(ArrayList<DtUsuario> ListaUsuarios){ + DefaultListModel modelo = new DefaultListModel(); + ListaUsuarios.forEach((it) -> { + modelo.addElement(it.getNickname()); + // a que te dejo re loco este for + }); + lstDuenioVideo.setModel(modelo); + + } + private void mostrarListaDeVideos(ArrayList<DtVideo> listaVideos){ + DefaultListModel modelo = new DefaultListModel(); + for (DtVideo it : listaVideos) { + modelo.addElement(it.getNombre()); + } + lstVideoUsuario.setModel(modelo); + } + private void mostrarDatosDeVideo(DtVideo v){ + lbNombre.setText(v.getNombre()); + lbDuracion.setText(v.getDuracion().toString()); + lbUrl.setText(obtenerTextoComoEnlace(v.getUrlVideoOriginal(), v.getUrlVideoOriginal())); + enlace = v.getUrlVideoOriginal(); + lbPrivacidad.setText(v.getPrivacidad().toString()); + lbCategoria.setText(v.getCategoria()); + txtDescripcion.setText(v.getDescripcion()); + lbCantLikes.setText(String.valueOf(v.getCantLikes())); + lbCantDisLikes.setText(String.valueOf(v.getCantDisLikes())); + lbFechaPublicacion.setText(v.getFechaPublicacion().toString()); + } + private void mostrarListasDrValoraciones(ArrayList<DtValoracion> lVal){ + DefaultListModel modeloLikes = new DefaultListModel(); + DefaultListModel modeloDisLikes = new DefaultListModel(); + for (DtValoracion it : lVal){ + if (it.getVal() == TipoValoracion.LIKE){ + modeloLikes.addElement(it.getNickname()); + }else{ + modeloDisLikes.addElement(it.getNickname()); + } + } + lstLike.setModel(modeloLikes); + lstDislike.setModel(modeloDisLikes); + } + private void mostrarListaDeComentarios(ArrayList<DtComentario> lCom){ + // crea el nodo raiz + DefaultMutableTreeNode raiz = new DefaultMutableTreeNode("Comentarios:"); + // agrega al nodo raiz toodos los comentarios + agregarNodoATree(lCom, 0, raiz); + + // Carga el arbol en el TreeModel + TreeModel datos = new DefaultTreeModel(raiz); + // Carga el TreeModel en el JTree + treeComentarios.setModel(datos); + // la siguiente funcion la saque de stackoverflow + expandAllNodes(treeComentarios, 0, treeComentarios.getRowCount()); + } + private void expandAllNodes(javax.swing.JTree tree, int startingIndex, int rowCount) { + // Extraido de: + // https://stackoverflow.com/questions/15210979/how-do-i-auto-expand-a-jtree-when-setting-a-new-treemodel + for (int i = startingIndex; i < rowCount; ++i) { + tree.expandRow(i); + } + + if (tree.getRowCount() != rowCount) { + expandAllNodes(tree, rowCount, tree.getRowCount()); + } + } + private void agregarNodoATree(ArrayList<DtComentario> l, int e, DefaultMutableTreeNode nodoPadre){ + // si el array vacio, no hay nada que hacer + if (e == l.size()){ + return; + } + + // guardo el nivel del prmer comentario con el que se trabajara (no siempre sera el primer elemento del array) + int nivelActual = l.get(e).getNivelSubComentario(); + // Variable para el nuevo comentario a procesar + DefaultMutableTreeNode nodoComentario = null; + // sera true si se ebe llamar a la recursividad + boolean llamarRecursividad = false; + + // recorre los elementos desde el indice pasado como parametro hasta el final del array + for (; e < l.size(); e++){ + // variable del comentario para trabajar en esta iteracion del for + DtComentario coment = l.get(e); + + if (coment.getNivelSubComentario() == nivelActual) { + // Si el coment esta al nivel a partir del cual se procesara + // extrae los datos en un string + String textoAMostrar = coment.getNickname() + ": " + coment.getTexto(); + // instancia el nodo con los datos + nodoComentario = new DefaultMutableTreeNode(textoAMostrar); + // lo agrega como hijo del nodo padre recibido como parametro + nodoPadre.add(nodoComentario); + // activa la recursividad en caso de que se encuentren hijos del comentario + llamarRecursividad = true; + }else if (coment.getNivelSubComentario() > nivelActual){ + // Si el comentario de esta iteracion es menor que el nivel a procesar + + // si hay que llamar recursividd + if (llamarRecursividad){ + // llama a recursividad pero pasando como nodo padre al comentario recien creado + agregarNodoATree(l, e, nodoComentario); + // en este punto ya se han agregado todos los hijos y nietos del comentario recien creado + // asi que ya no hay que llamar recursividad hasta agregar otro nodo en el primer if + llamarRecursividad = false; + } + }else{ + // si se encuentra un comentario de menor nivel al que se esta procesando + // debe salir, esa es otra familia de comentarios + return; + } + } + } + private void limpiarElementosDeVentana(){ + enlace = ""; + // limpieza de labels + lbNombre.setText(""); + lbDuracion.setText(""); + lbUrl.setText(""); + lbPrivacidad.setText(""); + lbCategoria.setText(""); + txtDescripcion.setText(""); + lbCantLikes.setText(""); + lbCantDisLikes.setText(""); + lbFechaPublicacion.setText(""); + // limpieza de listas + lstLike.setModel(new DefaultListModel()); + lstDislike.setModel(new DefaultListModel()); + // limpieza de Arbol + treeComentarios.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Comentarios:"))); + } + public String obtenerTextoComoEnlace(String enlace, String texto) { + // Extraido de + // http://www.forosdelweb.com/f45/jlabel-como-hipervinculo-netbeans-948388/ + return"<html><a href=" + '"' + enlace + '"'+ ">" + texto + "</a></html>"; + } + /////////////////////////////////////////////////////////////////////////////////////////// + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JLabel jLabel81; + private javax.swing.JLabel jLabel82; + private javax.swing.JLabel jLabel83; + private javax.swing.JLabel jLabel84; + private javax.swing.JLabel jLabel85; + private javax.swing.JLabel jLabel86; + private javax.swing.JLabel jLabel87; + private javax.swing.JLabel jLabel88; + private javax.swing.JLabel jLabel89; + private javax.swing.JLabel jLabel94; + private javax.swing.JLabel jLabel95; + private javax.swing.JLabel jLabel99; + private javax.swing.JPanel jPanel15; + private javax.swing.JScrollPane jScrollPane22; + private javax.swing.JScrollPane jScrollPane23; + private javax.swing.JScrollPane jScrollPane24; + private javax.swing.JScrollPane jScrollPane25; + private javax.swing.JScrollPane jScrollPane26; + private javax.swing.JScrollPane jScrollPane27; + private javax.swing.JLabel lbCantDisLikes; + private javax.swing.JLabel lbCantLikes; + private javax.swing.JLabel lbCategoria; + private javax.swing.JLabel lbDuracion; + private javax.swing.JLabel lbFechaPublicacion; + private javax.swing.JLabel lbNombre; + private javax.swing.JLabel lbPrivacidad; + private javax.swing.JLabel lbUrl; + private javax.swing.JList<String> lstDislike; + private javax.swing.JList<String> lstDuenioVideo; + private javax.swing.JList<String> lstLike; + private javax.swing.JList<String> lstVideoUsuario; + private javax.swing.JTree treeComentarios; + private javax.swing.JTextArea txtDescripcion; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Video/frmConsultaVideoEliminado.form b/UyTube_logica/src/Presentacion/Video/frmConsultaVideoEliminado.form new file mode 100644 index 0000000000000000000000000000000000000000..9044c307f0778cd294a2d537ec003d60d7efdd4d --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmConsultaVideoEliminado.form @@ -0,0 +1,270 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.7" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Consultar video"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="505" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Component id="jPanel15" alignment="0" pref="505" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="489" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Component id="jPanel15" alignment="0" pref="489" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel15"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel83"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel84"> + <Properties> + <Property name="text" type="java.lang.String" value="Duración:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel85"> + <Properties> + <Property name="text" type="java.lang.String" value="URL:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="80" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel86"> + <Properties> + <Property name="text" type="java.lang.String" value="Descripción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="200" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane24"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="200" width="380" height="130"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtDescripcion"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="columns" type="int" value="20"/> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel87"> + <Properties> + <Property name="text" type="java.lang.String" value="Privacidad:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="140" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel88"> + <Properties> + <Property name="text" type="java.lang.String" value="Categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="170" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbNombre"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="20" width="390" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbDuracion"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="50" width="390" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbUrl"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lbUrlMousePressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="80" width="390" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbPrivacidad"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="140" width="390" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCategoria"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="170" width="380" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="410" width="460" height="60"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel94"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Les gustó:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="340" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel95"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="No les gustó:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="370" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCantDisLikes"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="110" y="370" width="370" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbCantLikes"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="110" y="340" width="370" height="20"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel89"> + <Properties> + <Property name="text" type="java.lang.String" value="Publicación:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="110" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbFechaPublicacion"> + <Properties> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="110" width="390" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Video/frmConsultaVideoEliminado.java b/UyTube_logica/src/Presentacion/Video/frmConsultaVideoEliminado.java new file mode 100644 index 0000000000000000000000000000000000000000..da427c6b8e09b289e5c9079c478f9acbd32c6bef --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmConsultaVideoEliminado.java @@ -0,0 +1,238 @@ + +package Presentacion.Video; + +import Logica.DataType.DtVideo; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import javax.swing.JOptionPane; + +public class frmConsultaVideoEliminado extends javax.swing.JDialog { + + private IAdmin sys; + private String enlace = ""; + + public frmConsultaVideoEliminado(javax.swing.JDialog parent, boolean modal, int idVideo) { + // Constructor para abrir ventana desde otro caso de uso + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + limpiarElementosDeVentana(); + + try { + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // El sistema ya tiene un usuario seleccionado + mostrarDatosDeVideo(sys.seleccionarVideo(idVideo)); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel15 = new javax.swing.JPanel(); + jLabel83 = new javax.swing.JLabel(); + jLabel84 = new javax.swing.JLabel(); + jLabel85 = new javax.swing.JLabel(); + jLabel86 = new javax.swing.JLabel(); + jScrollPane24 = new javax.swing.JScrollPane(); + txtDescripcion = new javax.swing.JTextArea(); + jLabel87 = new javax.swing.JLabel(); + jLabel88 = new javax.swing.JLabel(); + lbNombre = new javax.swing.JLabel(); + lbDuracion = new javax.swing.JLabel(); + lbUrl = new javax.swing.JLabel(); + lbPrivacidad = new javax.swing.JLabel(); + lbCategoria = new javax.swing.JLabel(); + btnAceptar = new javax.swing.JButton(); + jLabel94 = new javax.swing.JLabel(); + jLabel95 = new javax.swing.JLabel(); + lbCantDisLikes = new javax.swing.JLabel(); + lbCantLikes = new javax.swing.JLabel(); + jLabel89 = new javax.swing.JLabel(); + lbFechaPublicacion = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Consultar video"); + setResizable(false); + + jPanel15.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel83.setText("Nombre:"); + jPanel15.add(jLabel83, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1)); + + jLabel84.setText("Duración:"); + jPanel15.add(jLabel84, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 50, -1, -1)); + + jLabel85.setText("URL:"); + jPanel15.add(jLabel85, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 80, -1, -1)); + + jLabel86.setText("Descripción:"); + jPanel15.add(jLabel86, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 200, -1, -1)); + + txtDescripcion.setEditable(false); + txtDescripcion.setColumns(20); + txtDescripcion.setLineWrap(true); + txtDescripcion.setRows(5); + jScrollPane24.setViewportView(txtDescripcion); + + jPanel15.add(jScrollPane24, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 200, 380, 130)); + + jLabel87.setText("Privacidad:"); + jPanel15.add(jLabel87, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 140, -1, -1)); + + jLabel88.setText("CategorÃa:"); + jPanel15.add(jLabel88, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 170, -1, -1)); + + lbNombre.setText(" "); + jPanel15.add(lbNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 20, 390, -1)); + + lbDuracion.setText(" "); + jPanel15.add(lbDuracion, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 50, 390, -1)); + + lbUrl.setText(" "); + lbUrl.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + lbUrlMousePressed(evt); + } + }); + jPanel15.add(lbUrl, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 80, 390, -1)); + + lbPrivacidad.setText(" "); + jPanel15.add(lbPrivacidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 140, 390, -1)); + + lbCategoria.setText(" "); + jPanel15.add(lbCategoria, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 170, 380, -1)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel15.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 410, 460, 60)); + + jLabel94.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel94.setText("Les gustó:"); + jPanel15.add(jLabel94, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 340, -1, -1)); + + jLabel95.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel95.setText("No les gustó:"); + jPanel15.add(jLabel95, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 370, -1, -1)); + + lbCantDisLikes.setText(" "); + jPanel15.add(lbCantDisLikes, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 370, 370, 20)); + + lbCantLikes.setText(" "); + jPanel15.add(lbCantLikes, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 340, 370, 20)); + + jLabel89.setText("Publicación:"); + jPanel15.add(jLabel89, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 110, -1, -1)); + + lbFechaPublicacion.setText(" "); + jPanel15.add(lbFechaPublicacion, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 110, 390, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 505, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, 505, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 489, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE)) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + // boton aceptar + dispose(); + }//GEN-LAST:event_btnAceptarActionPerformed + + private void lbUrlMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbUrlMousePressed + // al cloquear sobre la URL del video + if (lbUrl.getText().isEmpty() || enlace.isEmpty()) return; + + // Fuente: + // http://www.forosdelweb.com/f45/jlabel-como-hipervinculo-netbeans-948388/ + try { + if (java.awt.Desktop.isDesktopSupported()) { + java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); + if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { + desktop.browse(new java.net.URI(enlace)); + } + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lbUrlMousePressed + + /////////////////////////////////////////////////////////////////////////////////////////// + private void mostrarDatosDeVideo(DtVideo v){ + lbNombre.setText(v.getNombre()); + lbDuracion.setText(v.getDuracion().toString()); + lbUrl.setText(obtenerTextoComoEnlace(v.getUrlVideoOriginal(), v.getUrlVideoOriginal())); + enlace = v.getUrlVideoOriginal(); + lbPrivacidad.setText(v.getPrivacidad().toString()); + lbCategoria.setText(v.getCategoria()); + txtDescripcion.setText(v.getDescripcion()); + lbCantLikes.setText(String.valueOf(v.getCantLikes())); + lbCantDisLikes.setText(String.valueOf(v.getCantDisLikes())); + lbFechaPublicacion.setText(v.getFechaPublicacion().toString()); + } + private void limpiarElementosDeVentana(){ + enlace = ""; + // limpieza de labels + lbNombre.setText(""); + lbDuracion.setText(""); + lbUrl.setText(""); + lbPrivacidad.setText(""); + lbCategoria.setText(""); + txtDescripcion.setText(""); + lbCantLikes.setText(""); + lbCantDisLikes.setText(""); + lbFechaPublicacion.setText(""); + } + public String obtenerTextoComoEnlace(String enlace, String texto) { + // Extraido de + // http://www.forosdelweb.com/f45/jlabel-como-hipervinculo-netbeans-948388/ + return"<html><a href=" + '"' + enlace + '"'+ ">" + texto + "</a></html>"; + } + /////////////////////////////////////////////////////////////////////////////////////////// + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JLabel jLabel83; + private javax.swing.JLabel jLabel84; + private javax.swing.JLabel jLabel85; + private javax.swing.JLabel jLabel86; + private javax.swing.JLabel jLabel87; + private javax.swing.JLabel jLabel88; + private javax.swing.JLabel jLabel89; + private javax.swing.JLabel jLabel94; + private javax.swing.JLabel jLabel95; + private javax.swing.JPanel jPanel15; + private javax.swing.JScrollPane jScrollPane24; + private javax.swing.JLabel lbCantDisLikes; + private javax.swing.JLabel lbCantLikes; + private javax.swing.JLabel lbCategoria; + private javax.swing.JLabel lbDuracion; + private javax.swing.JLabel lbFechaPublicacion; + private javax.swing.JLabel lbNombre; + private javax.swing.JLabel lbPrivacidad; + private javax.swing.JLabel lbUrl; + private javax.swing.JTextArea txtDescripcion; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Video/frmModificarVideo.form b/UyTube_logica/src/Presentacion/Video/frmModificarVideo.form new file mode 100644 index 0000000000000000000000000000000000000000..1f67137188657262ce34212484f16d979e94d72b --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmModificarVideo.form @@ -0,0 +1,402 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="buttonGroup1"> + </Component> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Modificar video"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel14" min="-2" pref="980" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jPanel14" min="-2" pref="550" max="-2" attributes="0"/> + <EmptySpace min="0" pref="12" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel14"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="btnModificar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Modificar"/> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnModificarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="560" y="470" width="390" height="70"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="473" width="390" height="70"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane16"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="50" width="180" height="400"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstDuenioVideo"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstDuenioVideoValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel71"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Dueño del video:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane17"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="240" y="50" width="180" height="400"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideoUsuario"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstVideoUsuarioValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel72"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Video del Usuario:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="240" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtNombre"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="50" width="210" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel73"> + <Properties> + <Property name="text" type="java.lang.String" value="Nombre:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel74"> + <Properties> + <Property name="text" type="java.lang.String" value="Duración:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="100" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel75"> + <Properties> + <Property name="text" type="java.lang.String" value="URL:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="140" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtURL"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="140" width="210" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel76"> + <Properties> + <Property name="text" type="java.lang.String" value="Descripción:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="180" width="80" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane18"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="180" width="210" height="120"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtDescripcion"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel77"> + <Properties> + <Property name="text" type="java.lang.String" value="Fecha publicación:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="450" y="340" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel78"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Asignar categoría:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="770" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbPublico"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="buttonGroup1"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Público"/> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="460" y="390" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbPrivado"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="buttonGroup1"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Privado"/> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="640" y="390" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSpinner" name="spHora"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" maximum="15" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="100" width="60" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel144"> + <Properties> + <Property name="text" type="java.lang.String" value="Horas"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="530" y="80" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSpinner" name="spMinuto"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" maximum="59" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="600" y="100" width="50" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel145"> + <Properties> + <Property name="text" type="java.lang.String" value="Minutos"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="600" y="80" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSpinner" name="spSegundos"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" maximum="59" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="660" y="100" width="50" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel146"> + <Properties> + <Property name="text" type="java.lang.String" value="Segundos"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="660" y="80" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane19"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="770" y="50" width="180" height="400"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstCategorias"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="com.toedter.calendar.JDateChooser" name="dcFechaPublicacion"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="600" y="340" width="140" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Video/frmModificarVideo.java b/UyTube_logica/src/Presentacion/Video/frmModificarVideo.java new file mode 100644 index 0000000000000000000000000000000000000000..b4c3f3bedb751d9a0b29b347db69d1d5d09fb5ef --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmModificarVideo.java @@ -0,0 +1,472 @@ +package Presentacion.Video; + +import Logica.DataType.DtUsuario; +import Logica.DataType.DtVideo; +import Logica.Enumerados.Privacidad; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.sql.Time; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; +import javax.swing.ListModel; + +public class frmModificarVideo extends javax.swing.JDialog { + + IAdmin sys; + DefaultListModel s = new DefaultListModel(); + boolean liberarMemoria; + String validarNombre; + + public frmModificarVideo(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + liberarMemoria = true; + + try { + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // lista usuarios en el JList + listarUsuarios(sys.listarUsuarios()); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + jPanel14 = new javax.swing.JPanel(); + btnModificar = new javax.swing.JButton(); + btnCancelar = new javax.swing.JButton(); + jScrollPane16 = new javax.swing.JScrollPane(); + lstDuenioVideo = new javax.swing.JList<>(); + jLabel71 = new javax.swing.JLabel(); + jScrollPane17 = new javax.swing.JScrollPane(); + lstVideoUsuario = new javax.swing.JList<>(); + jLabel72 = new javax.swing.JLabel(); + txtNombre = new javax.swing.JTextField(); + jLabel73 = new javax.swing.JLabel(); + jLabel74 = new javax.swing.JLabel(); + jLabel75 = new javax.swing.JLabel(); + txtURL = new javax.swing.JTextField(); + jLabel76 = new javax.swing.JLabel(); + jScrollPane18 = new javax.swing.JScrollPane(); + txtDescripcion = new javax.swing.JTextArea(); + jLabel77 = new javax.swing.JLabel(); + jLabel78 = new javax.swing.JLabel(); + rbPublico = new javax.swing.JRadioButton(); + rbPrivado = new javax.swing.JRadioButton(); + spHora = new javax.swing.JSpinner(); + jLabel144 = new javax.swing.JLabel(); + spMinuto = new javax.swing.JSpinner(); + jLabel145 = new javax.swing.JLabel(); + spSegundos = new javax.swing.JSpinner(); + jLabel146 = new javax.swing.JLabel(); + jScrollPane19 = new javax.swing.JScrollPane(); + lstCategorias = new javax.swing.JList<>(); + dcFechaPublicacion = new com.toedter.calendar.JDateChooser(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Modificar video"); + setResizable(false); + + jPanel14.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + btnModificar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnModificar.setText("Modificar"); + btnModificar.setEnabled(false); + btnModificar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnModificarActionPerformed(evt); + } + }); + jPanel14.add(btnModificar, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 470, 390, 70)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + jPanel14.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 473, 390, 70)); + + lstDuenioVideo.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstDuenioVideoValueChanged(evt); + } + }); + jScrollPane16.setViewportView(lstDuenioVideo); + + jPanel14.add(jScrollPane16, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 50, 180, 400)); + + jLabel71.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel71.setText("Dueño del video:"); + jPanel14.add(jLabel71, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1)); + + lstVideoUsuario.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstVideoUsuarioValueChanged(evt); + } + }); + jScrollPane17.setViewportView(lstVideoUsuario); + + jPanel14.add(jScrollPane17, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 50, 180, 400)); + + jLabel72.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel72.setText("Video del Usuario:"); + jPanel14.add(jLabel72, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 20, -1, -1)); + jPanel14.add(txtNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 50, 210, -1)); + + jLabel73.setText("Nombre:"); + jPanel14.add(jLabel73, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 50, -1, -1)); + + jLabel74.setText("Duración:"); + jPanel14.add(jLabel74, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 100, -1, -1)); + + jLabel75.setText("URL:"); + jPanel14.add(jLabel75, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 140, -1, -1)); + jPanel14.add(txtURL, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 140, 210, -1)); + + jLabel76.setText("Descripción:"); + jPanel14.add(jLabel76, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 180, 80, -1)); + + txtDescripcion.setColumns(20); + txtDescripcion.setRows(5); + jScrollPane18.setViewportView(txtDescripcion); + + jPanel14.add(jScrollPane18, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 180, 210, 120)); + + jLabel77.setText("Fecha publicación:"); + jPanel14.add(jLabel77, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 340, -1, -1)); + + jLabel78.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel78.setText("Asignar categorÃa:"); + jPanel14.add(jLabel78, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 20, -1, -1)); + + buttonGroup1.add(rbPublico); + rbPublico.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + rbPublico.setText("Público"); + jPanel14.add(rbPublico, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 390, -1, -1)); + + buttonGroup1.add(rbPrivado); + rbPrivado.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + rbPrivado.setText("Privado"); + jPanel14.add(rbPrivado, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 390, -1, -1)); + + spHora.setModel(new javax.swing.SpinnerNumberModel(0, 0, 15, 1)); + jPanel14.add(spHora, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 100, 60, -1)); + + jLabel144.setText("Horas"); + jPanel14.add(jLabel144, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 80, -1, -1)); + + spMinuto.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1)); + jPanel14.add(spMinuto, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 100, 50, -1)); + + jLabel145.setText("Minutos"); + jPanel14.add(jLabel145, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 80, -1, -1)); + + spSegundos.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1)); + jPanel14.add(spSegundos, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 100, 50, -1)); + + jLabel146.setText("Segundos"); + jPanel14.add(jLabel146, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 80, -1, -1)); + + jScrollPane19.setViewportView(lstCategorias); + + jPanel14.add(jScrollPane19, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 50, 180, 400)); + jPanel14.add(dcFechaPublicacion, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 340, 140, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, 980, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, 550, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 12, Short.MAX_VALUE)) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + public frmModificarVideo(javax.swing.JDialog parent, boolean modal, String nickname) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + liberarMemoria = false; + try { + // obtiene la instancia de sistema + sys = Fabrica.getInstancia().getIAdmin(); + + // Limpio la ventana + // limpiarElementosDeVentana(); + // lista usuarios y categorias en JList + listarUsuarios(sys.listarUsuarios()); + lstDuenioVideo.setSelectedValue(nickname, true); + lstDuenioVideo.setEnabled(false); + + // Selecciono el usuario en la lista de usuarios + // deshabilito la lista de usuarios para que no lo cambien + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + dispose(); + } + } + + private void habilitarModificar() { + if (!lstVideoUsuario.isSelectionEmpty()) { + btnModificar.setEnabled(true); + } else { + btnModificar.setEnabled(false); + } + } + + private boolean existeVideo(String nombre) { + ListModel<String> lst = lstVideoUsuario.getModel(); + for (int i = 0; i < lst.getSize(); i++) { + if (lst.getElementAt(i).equals(nombre)) { + return true; + } + + } + return false; + + } + + private void listarUsuarios(ArrayList<DtUsuario> ListaUsuarios) { + DefaultListModel modelo = new DefaultListModel(); + for (DtUsuario it : ListaUsuarios) { + modelo.addElement(it.getNickname()); + } + lstDuenioVideo.setModel(modelo); + + } + + private void listarCategorias(ArrayList<String> ListaCategorias) { + DefaultListModel modelo2 = new DefaultListModel(); + for (int i = 0; i < sys.listarCategorias().size(); i++) { + modelo2.add(i, sys.listarCategorias().get(i)); + } + lstCategorias.setModel(modelo2); + } + + private void listarVideos(ArrayList<DtVideo> ListaVideos) { + DefaultListModel modelo1 = new DefaultListModel(); + for (DtVideo it : ListaVideos) { + modelo1.addElement(it.getNombre()); + } + lstVideoUsuario.setModel(modelo1); + + } + + private void cargarDatosDeVideo(DtVideo v) { + int hora, minuto, segundo; + txtNombre.setText(v.getNombre()); + txtDescripcion.setText(v.getDescripcion()); + txtURL.setText(v.getUrlVideoOriginal()); + dcFechaPublicacion.setDate(v.getFechaPublicacion()); + + spHora.setValue(v.getDuracion().getHours()); + spMinuto.setValue(v.getDuracion().getMinutes()); + spSegundos.setValue(v.getDuracion().getSeconds()); + + if (v.getPrivacidad() == Privacidad.PUBLICO) { + rbPublico.setSelected(true); + } else { + rbPrivado.setSelected(true); + } + + lstCategorias.setSelectedValue(v.getCategoria(), true); + + } + + + private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed + try { + if (lstVideoUsuario.isSelectionEmpty()) { + JOptionPane.showMessageDialog(null, "Seleccione un video para modificar", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (txtNombre.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "El nombre del video no puede ser vacÃo", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (txtNombre.getText().length() > 100) { + JOptionPane.showMessageDialog(null, "El nombre del video no puede tener mas de 100 caracteres", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (lstCategorias.isSelectionEmpty()) { + JOptionPane.showMessageDialog(null, "Seleccione una categorÃa", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (txtURL.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "La URL del video no puede ser vacÃa", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (!validarFormatoURL(txtURL.getText())) { + JOptionPane.showMessageDialog(null, "La URL del video no es válida", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (dcFechaPublicacion.getDate() == null) { + JOptionPane.showMessageDialog(null, "Seleccione una fecha de publicacion", "Error", JOptionPane.WARNING_MESSAGE); + } else { + if (!txtNombre.getText().equals(validarNombre)) { + if (existeVideo(txtNombre.getText())) { + JOptionPane.showMessageDialog(null, "Ya existe este video en la lista seleccionada", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + } + + int hora = (Integer) spHora.getValue(); + int minuto = (Integer) spMinuto.getValue(); + int segundo = (Integer) spSegundos.getValue(); + Privacidad priv = Privacidad.PRIVADO; + if (rbPrivado.isSelected() && !(rbPublico.isSelected())) { + priv = Privacidad.PRIVADO; + } else if (rbPublico.isSelected() && !(rbPrivado.isSelected())) { + priv = Privacidad.PUBLICO; + } else { + JOptionPane.showMessageDialog(null, "Seleccione privacidad del video", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + java.sql.Date fecha = null; + if (dcFechaPublicacion.getDate() != null) { + java.util.Date utilDate = dcFechaPublicacion.getDate(); + fecha = new java.sql.Date(utilDate.getTime()); + } + DtVideo video = new DtVideo(WIDTH, txtNombre.getText(), txtDescripcion.getText(), new Time(hora, minuto, segundo), fecha, txtURL.getText(), priv, lstCategorias.getSelectedValue(), ALLBITS, PROPERTIES); + if (sys.obtenerCanalDeUsuario().getPrivacidad() == Privacidad.PRIVADO && rbPublico.isSelected()) { + JOptionPane.showMessageDialog(null, "No es posible hacer público un video si su canal es privado", "Error", JOptionPane.WARNING_MESSAGE); + return; + } + sys.modificarVideo(video); + + if (liberarMemoria) { + sys.liberarMemoriaUsuario(); + } + sys.liberarMemoriaVideo(); + + JOptionPane.showMessageDialog(null, "Se han efectuado los cambios", "OK", JOptionPane.INFORMATION_MESSAGE); + dispose(); + } + } + } + } + } + } + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + + } + }//GEN-LAST:event_btnModificarActionPerformed + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + try { + if (liberarMemoria) { + sys.liberarMemoriaUsuario(); + } + sys.liberarMemoriaVideo(); + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + + } + }//GEN-LAST:event_btnCancelarActionPerformed + + private void lstDuenioVideoValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstDuenioVideoValueChanged + if (evt.getValueIsAdjusting()) { + return; + } + if (lstDuenioVideo.getSelectedIndex() < 0) { + return; + } + txtDescripcion.setText(""); + txtNombre.setText(""); + txtURL.setText(""); + spHora.setValue(0); + spMinuto.setValue(0); + spSegundos.setValue(0); + lstCategorias.clearSelection(); + String nick = lstDuenioVideo.getSelectedValue(); + sys.seleccionarUsuario(nick); + listarVideos(sys.listarVideosDeUsuario()); + habilitarModificar(); + buttonGroup1.clearSelection(); + dcFechaPublicacion.setDate(null); + }//GEN-LAST:event_lstDuenioVideoValueChanged + + private void lstVideoUsuarioValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstVideoUsuarioValueChanged + if (evt.getValueIsAdjusting()) { + return; + } + if (lstVideoUsuario.getSelectedIndex() < 0) { + return; + } + + try { + habilitarModificar(); + String nombre = lstVideoUsuario.getSelectedValue(); + ArrayList<DtVideo> arr = sys.listarVideosDeUsuario(); + int idVideo = arr.get(lstVideoUsuario.getSelectedIndex()).getId(); + DtVideo dtv = sys.seleccionarVideo(idVideo); + validarNombre = dtv.getNombre(); + + listarCategorias(sys.listarCategorias()); + cargarDatosDeVideo(dtv); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + + } + }//GEN-LAST:event_lstVideoUsuarioValueChanged + + private boolean validarFormatoURL(String _url) { + Pattern patronURL = Pattern.compile("^((((https?|ftps?|gopher|telnet|nntp)://)|(mailto:|news:))(%[0-9A-Fa-f]{2}|[-()_.!~*’;/?:@&=+$, A-Za-z0-9])+)([).!’;/?:, ][[:blank:]])?$"); + Matcher mather = patronURL.matcher(_url); + if (mather.find() == true) { + return true; + } + return false; + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancelar; + private javax.swing.JButton btnModificar; + private javax.swing.ButtonGroup buttonGroup1; + private com.toedter.calendar.JDateChooser dcFechaPublicacion; + private javax.swing.JLabel jLabel144; + private javax.swing.JLabel jLabel145; + private javax.swing.JLabel jLabel146; + private javax.swing.JLabel jLabel71; + private javax.swing.JLabel jLabel72; + private javax.swing.JLabel jLabel73; + private javax.swing.JLabel jLabel74; + private javax.swing.JLabel jLabel75; + private javax.swing.JLabel jLabel76; + private javax.swing.JLabel jLabel77; + private javax.swing.JLabel jLabel78; + private javax.swing.JPanel jPanel14; + private javax.swing.JScrollPane jScrollPane16; + private javax.swing.JScrollPane jScrollPane17; + private javax.swing.JScrollPane jScrollPane18; + private javax.swing.JScrollPane jScrollPane19; + private javax.swing.JList<String> lstCategorias; + private javax.swing.JList<String> lstDuenioVideo; + private javax.swing.JList<String> lstVideoUsuario; + public static javax.swing.JRadioButton rbPrivado; + public static javax.swing.JRadioButton rbPublico; + private javax.swing.JSpinner spHora; + private javax.swing.JSpinner spMinuto; + private javax.swing.JSpinner spSegundos; + private javax.swing.JTextArea txtDescripcion; + private javax.swing.JTextField txtNombre; + private javax.swing.JTextField txtURL; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/Video/frmValorarVideo.form b/UyTube_logica/src/Presentacion/Video/frmValorarVideo.form new file mode 100644 index 0000000000000000000000000000000000000000..b5a28f34e83473ad7f66174e2614c57967a1a418 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmValorarVideo.form @@ -0,0 +1,282 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="buttonGroup1"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + </Component> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Valorar video"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="850" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel16" min="-2" pref="850" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="450" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel16" min="-2" pref="450" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel16"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane28"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="620" y="50" width="200" height="310"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarioValoradoR"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Seleccione usuario que realizara la valoracion"/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuarioValoradoRValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane29"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="260" y="50" width="330" height="310"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstVideoAValorar"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Seleccione el video a valorar"/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstVideoAValorarValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel96"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuario valorador:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="620" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel97"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Video a valorar:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="260" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane30"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="50" width="200" height="310"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstUsuarioValorado"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Seleccione el uruaio que realizara la valoracion "/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstUsuarioValoradoValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel98"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Usuario valorado:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbMeGusta"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="buttonGroup1"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Me gusta"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rbMeGustaActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="260" y="390" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbNoMeGusta"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="buttonGroup1"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="No me gusta"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rbNoMeGustaActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="380" y="390" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnValorar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Valorar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnValorarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="620" y="380" width="200" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + <Property name="toolTipText" type="java.lang.String" value="Se perderan todos los Items seleccionados"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="380" width="200" height="50"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="rbQuitar"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="buttonGroup1"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Quitar"/> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rbQuitarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="520" y="390" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/Video/frmValorarVideo.java b/UyTube_logica/src/Presentacion/Video/frmValorarVideo.java new file mode 100644 index 0000000000000000000000000000000000000000..58ec5ff925f5dd648ca09da0ed120da147344362 --- /dev/null +++ b/UyTube_logica/src/Presentacion/Video/frmValorarVideo.java @@ -0,0 +1,409 @@ +package Presentacion.Video; + +import java.util.ArrayList; +import Logica.DataType.DtUsuario; +import Logica.DataType.DtValoracion; +import Logica.DataType.DtVideo; +import Logica.Enumerados.TipoValoracion; +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +public class frmValorarVideo extends javax.swing.JDialog { + + private IAdmin sys; + ArrayList<DtUsuario> ListaUsuarios; + private ArrayList<DtVideo> VideosDelUser; + + public frmValorarVideo(java.awt.Frame parent, boolean modal) { + super(parent, modal); + try { + initComponents(); + this.setLocationRelativeTo(null); + + Fabrica f = Fabrica.getInstancia(); + sys = f.getIAdmin(); + + ListaUsuarios = sys.listarUsuarios(); + mostrarListadoDeUsuarios(ListaUsuarios); + + mostrarValoracionEnRadioButtons(); + + lstUsuarioValoradoR.setEnabled(false); + lstVideoAValorar.setEnabled(false); + btnValorar.setEnabled(false); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + jPanel16 = new javax.swing.JPanel(); + jScrollPane28 = new javax.swing.JScrollPane(); + lstUsuarioValoradoR = new javax.swing.JList<>(); + jScrollPane29 = new javax.swing.JScrollPane(); + lstVideoAValorar = new javax.swing.JList<>(); + jLabel96 = new javax.swing.JLabel(); + jLabel97 = new javax.swing.JLabel(); + jScrollPane30 = new javax.swing.JScrollPane(); + lstUsuarioValorado = new javax.swing.JList<>(); + jLabel98 = new javax.swing.JLabel(); + rbMeGusta = new javax.swing.JRadioButton(); + rbNoMeGusta = new javax.swing.JRadioButton(); + btnValorar = new javax.swing.JButton(); + btnCancelar = new javax.swing.JButton(); + rbQuitar = new javax.swing.JRadioButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Valorar video"); + setResizable(false); + + jPanel16.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + lstUsuarioValoradoR.setToolTipText("Seleccione usuario que realizara la valoracion"); + lstUsuarioValoradoR.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuarioValoradoRValueChanged(evt); + } + }); + jScrollPane28.setViewportView(lstUsuarioValoradoR); + + jPanel16.add(jScrollPane28, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 50, 200, 310)); + + lstVideoAValorar.setToolTipText("Seleccione el video a valorar"); + lstVideoAValorar.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstVideoAValorarValueChanged(evt); + } + }); + jScrollPane29.setViewportView(lstVideoAValorar); + + jPanel16.add(jScrollPane29, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 50, 330, 310)); + + jLabel96.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel96.setText("Usuario valorador:"); + jPanel16.add(jLabel96, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 20, -1, -1)); + + jLabel97.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel97.setText("Video a valorar:"); + jPanel16.add(jLabel97, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 20, -1, -1)); + + lstUsuarioValorado.setToolTipText("Seleccione el uruaio que realizara la valoracion "); + lstUsuarioValorado.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstUsuarioValoradoValueChanged(evt); + } + }); + jScrollPane30.setViewportView(lstUsuarioValorado); + + jPanel16.add(jScrollPane30, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 50, 200, 310)); + + jLabel98.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel98.setText("Usuario valorado:"); + jPanel16.add(jLabel98, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1)); + + buttonGroup1.add(rbMeGusta); + rbMeGusta.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + rbMeGusta.setText("Me gusta"); + rbMeGusta.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rbMeGustaActionPerformed(evt); + } + }); + jPanel16.add(rbMeGusta, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 390, -1, -1)); + + buttonGroup1.add(rbNoMeGusta); + rbNoMeGusta.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + rbNoMeGusta.setText("No me gusta"); + rbNoMeGusta.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rbNoMeGustaActionPerformed(evt); + } + }); + jPanel16.add(rbNoMeGusta, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 390, -1, -1)); + + btnValorar.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + btnValorar.setText("Valorar"); + btnValorar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnValorarActionPerformed(evt); + } + }); + jPanel16.add(btnValorar, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 380, 200, 50)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.setToolTipText("Se perderan todos los Items seleccionados"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + jPanel16.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 380, 200, 50)); + + buttonGroup1.add(rbQuitar); + rbQuitar.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + rbQuitar.setText("Quitar"); + rbQuitar.setEnabled(false); + rbQuitar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rbQuitarActionPerformed(evt); + } + }); + jPanel16.add(rbQuitar, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 390, -1, -1)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 850, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, 850, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 450, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + //CANCELAR + try { + sys.liberarMemoriaVideo(); + sys.liberarMemoriaUsuarioActual(); + sys.liberarMemoriaUsuario(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } finally { + dispose(); + } + }//GEN-LAST:event_btnCancelarActionPerformed + + private void lstUsuarioValoradoValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuarioValoradoValueChanged + // Seleccionar usuario duenio de video + if (evt.getValueIsAdjusting()) { + return; + } + if (lstUsuarioValorado.getSelectedIndex() < 0) { + return; + } + + try { + int indiceSeleccionado = lstUsuarioValorado.getSelectedIndex(); + String nick = ListaUsuarios.get(indiceSeleccionado).getNickname(); + sys.seleccionarUsuario(nick); + VideosDelUser = sys.listarVideosDeUsuario(); + mostrarListadoDeVideos(VideosDelUser); + mostrarValoracionEnRadioButtons(); + + lstVideoAValorar.setEnabled(true); + + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + + }//GEN-LAST:event_lstUsuarioValoradoValueChanged + + private void lstVideoAValorarValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstVideoAValorarValueChanged + // Al seleccionar un video + if (evt.getValueIsAdjusting()) { + return; + } + if (lstVideoAValorar.getSelectedIndex() < 0) { + mostrarValoracionEnRadioButtons(); + return; + } + + try { + int indiceSeleccionado = lstVideoAValorar.getSelectedIndex(); + int idVideo = VideosDelUser.get(indiceSeleccionado).getId(); + sys.seleccionarVideo(idVideo); + mostrarValoracionEnRadioButtons(); + + lstUsuarioValoradoR.setEnabled(true); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstVideoAValorarValueChanged + + private void lstUsuarioValoradoRValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstUsuarioValoradoRValueChanged + // al seleccionar usuario que va a valorar + if (evt.getValueIsAdjusting()) { + return; + } + if (lstUsuarioValoradoR.getSelectedIndex() < 0) { + return; + } + + try { + int indiceSeleccionado = lstUsuarioValoradoR.getSelectedIndex(); + String nick = ListaUsuarios.get(indiceSeleccionado).getNickname(); + sys.seleccionarUsuarioActual(nick); + mostrarValoracionEnRadioButtons(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_lstUsuarioValoradoRValueChanged + + private void btnValorarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnValorarActionPerformed + // Clic en boton Valorar + + // validaciones + if (lstUsuarioValorado.getSelectedIndex() < 0) { + JOptionPane.showMessageDialog(null, "Debe seleccionar un usuario propietario del video", "¡Atención!", JOptionPane.WARNING_MESSAGE); + return; + } + if (lstVideoAValorar.getSelectedIndex() < 0) { + JOptionPane.showMessageDialog(null, "Debe seleccionar un video", "¡Atención!", JOptionPane.WARNING_MESSAGE); + return; + } + if (lstUsuarioValoradoR.getSelectedIndex() < 0) { + JOptionPane.showMessageDialog(null, "Debe seleccionar el usuario que realizará la valoración", "¡Atención!", JOptionPane.WARNING_MESSAGE); + return; + } + if ( ! (rbMeGusta.isSelected() || rbNoMeGusta.isSelected() || rbQuitar.isSelected())) { + JOptionPane.showMessageDialog(null, "Debe seleccionar la opcion de valoración", "¡Atención!", JOptionPane.WARNING_MESSAGE); + return; + } + + try { + String nick; + int indiceSeleccionado; + + indiceSeleccionado = lstUsuarioValorado.getSelectedIndex(); + nick = ListaUsuarios.get(indiceSeleccionado).getNickname(); + sys.seleccionarUsuario(nick); + + indiceSeleccionado = lstVideoAValorar.getSelectedIndex(); + int idVideo = VideosDelUser.get(indiceSeleccionado).getId(); + sys.seleccionarVideo(idVideo); + + indiceSeleccionado = lstUsuarioValoradoR.getSelectedIndex(); + nick = ListaUsuarios.get(indiceSeleccionado).getNickname(); + sys.seleccionarUsuarioActual(nick); + + if (rbMeGusta.isSelected()) { + sys.altaValoracion(new DtValoracion(TipoValoracion.LIKE, "hola")); + } else if (rbNoMeGusta.isSelected()) { + sys.altaValoracion(new DtValoracion(TipoValoracion.DISLIKE, "hola")); + } else { + sys.altaValoracion(null); + } + + sys.liberarMemoriaVideo(); + sys.liberarMemoriaUsuarioActual(); + sys.liberarMemoriaUsuario(); + JOptionPane.showMessageDialog(null, "Video valorado exitosamente\n", "Informacion", JOptionPane.INFORMATION_MESSAGE); + dispose(); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnValorarActionPerformed + + private void rbMeGustaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbMeGustaActionPerformed + btnValorar.setEnabled(true); + }//GEN-LAST:event_rbMeGustaActionPerformed + + private void rbNoMeGustaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbNoMeGustaActionPerformed + btnValorar.setEnabled(true); + }//GEN-LAST:event_rbNoMeGustaActionPerformed + + private void rbQuitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbQuitarActionPerformed + btnValorar.setEnabled(true); + }//GEN-LAST:event_rbQuitarActionPerformed + + //////////////////////////////////////////////////////////////////////////////////////////// + private void mostrarListadoDeUsuarios(ArrayList<DtUsuario> l) { + DefaultListModel modelo1 = new DefaultListModel(); + DefaultListModel modelo2 = new DefaultListModel(); + for (DtUsuario it : l) { + modelo1.addElement(it.getNickname()); + modelo2.addElement(it.getNickname()); + } + lstUsuarioValorado.setModel(modelo1); + lstUsuarioValoradoR.setModel(modelo2); + } + + private void mostrarListadoDeVideos(ArrayList<DtVideo> l) { + DefaultListModel modelo1 = new DefaultListModel(); + for (DtVideo it : l) { + modelo1.addElement(it.getNombre()); + } + lstVideoAValorar.setModel(modelo1); + lstVideoAValorar.updateUI(); + } + + private void mostrarValoracionEnRadioButtons() { + try { + if (lstUsuarioValorado.isSelectionEmpty() + || lstVideoAValorar.isSelectionEmpty() + || lstUsuarioValoradoR.isSelectionEmpty()) { + buttonGroup1.clearSelection(); + rbMeGusta.setEnabled(false); + rbNoMeGusta.setEnabled(false); + rbQuitar.setEnabled(false); + btnValorar.setEnabled(false); + return; + } + rbMeGusta.setEnabled(true); + rbNoMeGusta.setEnabled(true); + + DtValoracion dtv = sys.obtenerValoracionDada(); + + if (dtv == null) { + buttonGroup1.clearSelection(); + btnValorar.setEnabled(false); + rbQuitar.setEnabled(false); + //rbMeGusta.setSelected(false); + //rbNoMeGusta.setSelected(false); + } else { + if (dtv.getVal() == TipoValoracion.LIKE) { + rbMeGusta.setSelected(true); + rbNoMeGusta.setSelected(false); + } else { + rbMeGusta.setSelected(false); + rbNoMeGusta.setSelected(true); + } + rbQuitar.setEnabled(true); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error \n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + //////////////////////////////////////////////////////////////////////////////////////////// + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancelar; + private javax.swing.JButton btnValorar; + public static javax.swing.ButtonGroup buttonGroup1; + private javax.swing.JLabel jLabel96; + private javax.swing.JLabel jLabel97; + private javax.swing.JLabel jLabel98; + private javax.swing.JPanel jPanel16; + private javax.swing.JScrollPane jScrollPane28; + private javax.swing.JScrollPane jScrollPane29; + private javax.swing.JScrollPane jScrollPane30; + private javax.swing.JList<String> lstUsuarioValorado; + private javax.swing.JList<String> lstUsuarioValoradoR; + private javax.swing.JList<String> lstVideoAValorar; + private javax.swing.JRadioButton rbMeGusta; + private javax.swing.JRadioButton rbNoMeGusta; + private javax.swing.JRadioButton rbQuitar; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/frmAcercaDeNos.form b/UyTube_logica/src/Presentacion/frmAcercaDeNos.form new file mode 100644 index 0000000000000000000000000000000000000000..5dc7a596f4d4c1da8b33bd6ad3bde722c959a1ab --- /dev/null +++ b/UyTube_logica/src/Presentacion/frmAcercaDeNos.form @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Acerca de nos"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="570" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel10" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="460" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jPanel10" min="-2" pref="460" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel10"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="14" green="14" red="14" type="rgb"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lbImagen"> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lbImagenMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="0" width="570" height="430"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnAceptar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Aceptar"/> + <Property name="borderPainted" type="boolean" value="false"/> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Cursor de Mano"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnAceptarMouseClicked"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAceptarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="440" y="420" width="110" height="30"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/frmAcercaDeNos.java b/UyTube_logica/src/Presentacion/frmAcercaDeNos.java new file mode 100644 index 0000000000000000000000000000000000000000..ca5dfe8a5a683733333d7d04f3edda2b97e57a17 --- /dev/null +++ b/UyTube_logica/src/Presentacion/frmAcercaDeNos.java @@ -0,0 +1,144 @@ +package Presentacion; +import java.awt.Image; +import javax.swing.ImageIcon; + +public class frmAcercaDeNos extends javax.swing.JDialog { + boolean aburrido = false; + + public frmAcercaDeNos(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + + lbImagen.setText(null); + Image img7 = new ImageIcon("Imagenes/about.png").getImage(); + ImageIcon img8 = new ImageIcon(img7.getScaledInstance(lbImagen.getWidth(), lbImagen.getHeight(), Image.SCALE_SMOOTH)); + lbImagen.setIcon(img8); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel10 = new javax.swing.JPanel(); + lbImagen = new javax.swing.JLabel(); + btnAceptar = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Acerca de nos"); + setResizable(false); + + jPanel10.setBackground(new java.awt.Color(20, 20, 20)); + jPanel10.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + lbImagen.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + lbImagenMouseClicked(evt); + } + }); + jPanel10.add(lbImagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 570, 430)); + + btnAceptar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnAceptar.setText("Aceptar"); + btnAceptar.setBorderPainted(false); + btnAceptar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); + btnAceptar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + btnAceptarMouseClicked(evt); + } + }); + btnAceptar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAceptarActionPerformed(evt); + } + }); + jPanel10.add(btnAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 420, 110, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 570, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 460, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed + // Boton Acptar + dispose(); + }//GEN-LAST:event_btnAceptarActionPerformed + + private void btnAceptarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAceptarMouseClicked + dispose(); + }//GEN-LAST:event_btnAceptarMouseClicked + + private void lbImagenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbImagenMouseClicked + if ((!aburrido) && evt.getClickCount() == 42) { + // aburrido + // muy aburrido + int rango = 300; + int xInicial = this.getX(); + int yInicial = this.getY(); + + for (int i = 0; i < 3; i++) { + for (int x = this.getX(); x < xInicial + rango; x++) { + this.setLocation(x, yInicial); + } + for (int x = this.getX(); x > xInicial - rango; x--) { + this.setLocation(x, yInicial); + } + for (int x = this.getX(); x < xInicial; x++) { + this.setLocation(x, yInicial); + } + } + aburrido = true; + }else if (aburrido && evt.getClickCount() == 42) { + int respuesta = javax.swing.JOptionPane.showConfirmDialog( + null, + "¿En serio estás tan aburrido?", + "¿Aburrido?", + javax.swing.JOptionPane.YES_OPTION, + javax.swing.JOptionPane.QUESTION_MESSAGE + ); + if (respuesta == javax.swing.JOptionPane.YES_OPTION){ + javax.swing.JOptionPane.showMessageDialog(null, + "Se nota...", + "La verdad...", + javax.swing.JOptionPane.INFORMATION_MESSAGE); + }else if (respuesta == javax.swing.JOptionPane.NO_OPTION){ + javax.swing.JOptionPane.showMessageDialog(null, + "Pues no parece...", + "¿Ah no?", + javax.swing.JOptionPane.INFORMATION_MESSAGE); + } + dispose(); + } + }//GEN-LAST:event_lbImagenMouseClicked + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAceptar; + private javax.swing.JPanel jPanel10; + private javax.swing.JLabel lbImagen; + // End of variables declaration//GEN-END:variables +} diff --git a/UyTube_logica/src/Presentacion/frmInicioSesion.form b/UyTube_logica/src/Presentacion/frmInicioSesion.form new file mode 100644 index 0000000000000000000000000000000000000000..3688d52a95ce6f68abb563f0927e4a5d644af405 --- /dev/null +++ b/UyTube_logica/src/Presentacion/frmInicioSesion.form @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" value="Iniciar sesión"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="pnlFondo" min="-2" pref="450" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="pnlFondo" min="-2" pref="190" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="pnlFondo"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Nro de Empleado"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="160" y="30" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Contraseña"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="160" y="80" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbImagen"> + <Properties> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" value="imagen"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="20" width="110" height="100"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtNroEmpleado"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtNroEmpleadoKeyReleased"/> + <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtNroEmpleadoKeyTyped"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="270" y="30" width="160" height="30"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JPasswordField" name="txtContrasenia"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtContraseniaKeyPressed"/> + <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtContraseniaKeyReleased"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="270" y="80" width="160" height="30"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnIniciar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Iniciar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnIniciarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="280" y="130" width="150" height="40"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="btnCancelar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Cancelar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelarActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="130" width="150" height="40"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/frmInicioSesion.java b/UyTube_logica/src/Presentacion/frmInicioSesion.java new file mode 100644 index 0000000000000000000000000000000000000000..859bca4c1a28427b4c6dd9675c949016a75c9dfa --- /dev/null +++ b/UyTube_logica/src/Presentacion/frmInicioSesion.java @@ -0,0 +1,213 @@ +package Presentacion; + +import Logica.Fabrica; +import Logica.Interfaces.IAdmin; +import java.awt.Image; +import java.awt.event.KeyEvent; +import javax.swing.ImageIcon; +import javax.swing.JOptionPane; + +public class frmInicioSesion extends javax.swing.JDialog { + + // almacena el resultado el inicio de sesion + boolean resultado; + IAdmin sys; + + public frmInicioSesion(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + this.setLocationRelativeTo(null); + + txtNroEmpleado.setText(""); + txtContrasenia.setText(""); + + // Coloca la imagen del login + lbImagen.setText(null); + Image img = new ImageIcon("Imagenes/ukp.png").getImage(); + ImageIcon img2 = new ImageIcon(img.getScaledInstance(lbImagen.getWidth(), lbImagen.getHeight(), Image.SCALE_SMOOTH)); + lbImagen.setIcon(img2); + + // pide la instancia de Fabrica + + Fabrica f = Fabrica.getInstancia(); + // pide la instancia del sistema + sys = f.getIAdmin(); + + // desactiva el boton de Iniciar + btnIniciar.setEnabled(false); + + // inicializa la variable en falso + resultado = false; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + pnlFondo = new javax.swing.JPanel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + lbImagen = new javax.swing.JLabel(); + txtNroEmpleado = new javax.swing.JTextField(); + txtContrasenia = new javax.swing.JPasswordField(); + btnIniciar = new javax.swing.JButton(); + btnCancelar = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Iniciar sesión"); + setResizable(false); + + pnlFondo.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel4.setText("Nro de Empleado"); + pnlFondo.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 30, -1, -1)); + + jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel5.setText("Contraseña"); + pnlFondo.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 80, -1, -1)); + + lbImagen.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + lbImagen.setText("imagen"); + pnlFondo.add(lbImagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, 110, 100)); + + txtNroEmpleado.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + txtNroEmpleado.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + txtNroEmpleadoKeyReleased(evt); + } + public void keyTyped(java.awt.event.KeyEvent evt) { + txtNroEmpleadoKeyTyped(evt); + } + }); + pnlFondo.add(txtNroEmpleado, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 30, 160, 30)); + + txtContrasenia.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + txtContrasenia.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtContraseniaKeyPressed(evt); + } + public void keyReleased(java.awt.event.KeyEvent evt) { + txtContraseniaKeyReleased(evt); + } + }); + pnlFondo.add(txtContrasenia, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 80, 160, 30)); + + btnIniciar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnIniciar.setText("Iniciar"); + btnIniciar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnIniciarActionPerformed(evt); + } + }); + pnlFondo.add(btnIniciar, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 130, 150, 40)); + + btnCancelar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N + btnCancelar.setText("Cancelar"); + btnCancelar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCancelarActionPerformed(evt); + } + }); + pnlFondo.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 130, 150, 40)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(pnlFondo, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(pnlFondo, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed + // insicar secion->cancelar + this.resultado = false; + dispose(); + + }//GEN-LAST:event_btnCancelarActionPerformed + + private void btnIniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIniciarActionPerformed + //Sesion->iniciarSecion->iniciar + btnIniciar(); + }//GEN-LAST:event_btnIniciarActionPerformed + + private void txtNroEmpleadoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNroEmpleadoKeyTyped + if (!Character.isDigit(evt.getKeyChar())) { + getToolkit().beep(); + evt.consume(); + } + }//GEN-LAST:event_txtNroEmpleadoKeyTyped + + private void txtNroEmpleadoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNroEmpleadoKeyReleased + habilitarBotonIniciar(); + }//GEN-LAST:event_txtNroEmpleadoKeyReleased + + private void txtContraseniaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtContraseniaKeyReleased + habilitarBotonIniciar(); + }//GEN-LAST:event_txtContraseniaKeyReleased + + private void txtContraseniaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtContraseniaKeyPressed + // AL pulsar un ENTER + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + btnIniciar(); + } + }//GEN-LAST:event_txtContraseniaKeyPressed + + private void habilitarBotonIniciar(){ + // Hacer OR sin short circuit + if (txtNroEmpleado.getText().isEmpty() || txtContrasenia.getText().isEmpty()) { + btnIniciar.setEnabled(false); + } else { + btnIniciar.setEnabled(true); + } + } + + private void btnIniciar(){ + + try { + int nro = Integer.parseInt(txtNroEmpleado.getText()); + String contrasenia = txtContrasenia.getText(); + this.resultado = sys.iniciarSesionAdministrador(nro, contrasenia); + + if (resultado) { + dispose(); + } else { + JOptionPane.showMessageDialog(null, "El número de empleado o la contraseña son incorrectos", "Error al iniciar sesión", JOptionPane.ERROR_MESSAGE); + txtNroEmpleado.setText(""); + txtContrasenia.setText(""); + btnIniciar.setEnabled(false); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Ha ocurrido un error", "Error", JOptionPane.ERROR_MESSAGE); + } + } + + public boolean seInicioLaSesion(){ + return resultado; + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancelar; + private javax.swing.JButton btnIniciar; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel lbImagen; + private javax.swing.JPanel pnlFondo; + private javax.swing.JPasswordField txtContrasenia; + private javax.swing.JTextField txtNroEmpleado; + // End of variables declaration//GEN-END:variables + +} diff --git a/UyTube_logica/src/Presentacion/frmPrincipal.form b/UyTube_logica/src/Presentacion/frmPrincipal.form new file mode 100644 index 0000000000000000000000000000000000000000..1b1ae668f74dd63b34d7847d1009134672d1e0a5 --- /dev/null +++ b/UyTube_logica/src/Presentacion/frmPrincipal.form @@ -0,0 +1,475 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.JMenuItem" name="jMenuItem14"> + <Properties> + <Property name="text" type="java.lang.String" value="jMenuItem14"/> + </Properties> + </Component> + <Component class="javax.swing.JMenuItem" name="jMenuItem21"> + <Properties> + <Property name="text" type="java.lang.String" value="jMenuItem21"/> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane36"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="jList27"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="5"> + <StringItem index="0" value="Item 1"/> + <StringItem index="1" value="Item 2"/> + <StringItem index="2" value="Item 3"/> + <StringItem index="3" value="Item 4"/> + <StringItem index="4" value="Item 5"/> + </StringArray> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.ButtonGroup" name="privacidad_nuevoUsuario"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + </Component> + <Component class="javax.swing.ButtonGroup" name="privacidad_modUsuario"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + </Component> + <Component class="javax.swing.ButtonGroup" name="privacidad_modVideo"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + </Component> + <Component class="javax.swing.ButtonGroup" name="valorarVideo"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + </Component> + <Component class="javax.swing.ButtonGroup" name="privacidad_NuevaLR"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + </Component> + <Component class="javax.swing.ButtonGroup" name="privacidad_modListaR"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + </Component> + <Component class="javax.swing.ButtonGroup" name="tipo_nLR"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/> + </AuxValues> + </Component> + <Menu class="javax.swing.JMenuBar" name="barraDeMenu"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="18" style="0"/> + </Property> + </Properties> + <SubComponents> + <Menu class="javax.swing.JMenu" name="menuSesion"> + <Properties> + <Property name="text" type="java.lang.String" value="Sesión"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="18" style="0"/> + </Property> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="mitIniciarSesion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Iniciar sesión"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitIniciarSesionActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitCerrarSesion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cerrar sesión"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitCerrarSesionActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + <Menu class="javax.swing.JMenu" name="menuUsuario"> + <Properties> + <Property name="text" type="java.lang.String" value="Usuario"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="18" style="0"/> + </Property> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="mitNuevoUsuario"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Nuevo Usuario"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitNuevoUsuarioActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitConsultaUsuario"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Consultar Usuario"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitConsultaUsuarioActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitModificarUsuario"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Modificar Usuario"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitModificarUsuarioActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitListarUsuarios"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Listar Usuarios"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitListarUsuariosActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitSeguirUsuario"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Seguir Usuario"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitSeguirUsuarioActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitSeguirUsuario1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Dejar de seguir usuario"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitSeguirUsuario1ActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitEliminarUsuario"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Eliminar usuario"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitEliminarUsuarioActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitConsultaUsuarioEliminado"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Consultar Usuario eliminado"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitConsultaUsuarioEliminadoActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + <Menu class="javax.swing.JMenu" name="menuVideo"> + <Properties> + <Property name="text" type="java.lang.String" value="Video"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="18" style="0"/> + </Property> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="mitNuevoVideo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Nuevo Video"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitNuevoVideoActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitModificarVideo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Modificar Video"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitModificarVideoActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitConsultarVideo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Consultar Video"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitConsultarVideoActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitComentarVideo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Comentar Video"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitComentarVideoActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitValorarVideo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Valorar Video"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitValorarVideoActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + <Menu class="javax.swing.JMenu" name="menuListaDeReproduccion"> + <Properties> + <Property name="text" type="java.lang.String" value="Lista de reproducción"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="18" style="0"/> + </Property> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="mitNuevaListaDeReproduccion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Nueva Lista"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitNuevaListaDeReproduccionActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitModificarListaDeReproduccion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Modificar Lista"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitModificarListaDeReproduccionActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitConsultarListaDeReproduccion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Consultar Lista"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitConsultarListaDeReproduccionActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitAgregarVideoAListaDeReproduccion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Agregar Video"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitAgregarVideoAListaDeReproduccionActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitQuitarVideoDeListaDeReproduccion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Quitar Video"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitQuitarVideoDeListaDeReproduccionActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + <Menu class="javax.swing.JMenu" name="menuCategoria"> + <Properties> + <Property name="text" type="java.lang.String" value="Categoría"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="18" style="0"/> + </Property> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="mitNuevaCategoria"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Nueva Categoría"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitNuevaCategoriaActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitConsultarCategoria"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Consultar Categoría"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitConsultarCategoriaActionPerformed"/> + </Events> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="mitListarCategorias"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Listar Categoría"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitListarCategoriasActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + <Menu class="javax.swing.JMenu" name="menuAbout"> + <Properties> + <Property name="text" type="java.lang.String" value="About"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="18" style="0"/> + </Property> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="mitAcercaDeNos"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Acerca de nos"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mitAcercaDeNosActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + </SubComponents> + </Menu> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="UyTube"/> + <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getTconImage()" type="code"/> + </Property> + <Property name="locationByPlatform" type="boolean" value="true"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[800, 525]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[800, 525]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="menuBar" type="java.lang.String" value="barraDeMenu"/> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/> + </Events> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-32,0,0,4,-44"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JDesktopPane" name="pnlFondo"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="1a" green="0" red="0" type="rgb"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> + <Property name="columns" type="int" value="0"/> + <Property name="rows" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lbFondo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="48" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" value="( > ) UyTube"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/UyTube_logica/src/Presentacion/frmPrincipal.java b/UyTube_logica/src/Presentacion/frmPrincipal.java new file mode 100644 index 0000000000000000000000000000000000000000..9227c567af181a7e10695e8aa67c2ef093f99a49 --- /dev/null +++ b/UyTube_logica/src/Presentacion/frmPrincipal.java @@ -0,0 +1,652 @@ +package Presentacion; + +import Presentacion.Categoria.*; +import Presentacion.ListaDeReproduccion.*; +import Presentacion.Usuario.*; +import Presentacion.Video.*; +import java.awt.Image; +import java.awt.Toolkit; +import javax.swing.ImageIcon; +import javax.swing.JOptionPane; + +public class frmPrincipal extends javax.swing.JFrame { + + private boolean sesionIniciada; + + public frmPrincipal() { + initComponents(); + // centra la ventana y se maximiza + this.setLocationRelativeTo(null); + this.setExtendedState(MAXIMIZED_BOTH); + //tienes que agregar esto nada mas + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + + // carga la imagen de fondo + this.lbFondo.setText(null); + Image img3 = new ImageIcon("Imagenes/des.jpeg").getImage(); + ImageIcon img4 = new ImageIcon(img3.getScaledInstance(lbFondo.getWidth(), lbFondo.getHeight(), Image.SCALE_SMOOTH)); + lbFondo.setIcon(img4); + + //####### Descomentar la siguiente linea ###### // + activarBarraDeMenu(false); // hecho... + sesionIniciada = false; + mitCerrarSesion.setEnabled(false); + } + + public Image getTconImage() { + Image retValue = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("Imagenes/icono.jpg")); + return retValue; + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jMenuItem14 = new javax.swing.JMenuItem(); + jMenuItem21 = new javax.swing.JMenuItem(); + jScrollPane36 = new javax.swing.JScrollPane(); + jList27 = new javax.swing.JList<>(); + privacidad_nuevoUsuario = new javax.swing.ButtonGroup(); + privacidad_modUsuario = new javax.swing.ButtonGroup(); + privacidad_modVideo = new javax.swing.ButtonGroup(); + valorarVideo = new javax.swing.ButtonGroup(); + privacidad_NuevaLR = new javax.swing.ButtonGroup(); + privacidad_modListaR = new javax.swing.ButtonGroup(); + tipo_nLR = new javax.swing.ButtonGroup(); + pnlFondo = new javax.swing.JDesktopPane(); + lbFondo = new javax.swing.JLabel(); + barraDeMenu = new javax.swing.JMenuBar(); + menuSesion = new javax.swing.JMenu(); + mitIniciarSesion = new javax.swing.JMenuItem(); + mitCerrarSesion = new javax.swing.JMenuItem(); + menuUsuario = new javax.swing.JMenu(); + mitNuevoUsuario = new javax.swing.JMenuItem(); + mitConsultaUsuario = new javax.swing.JMenuItem(); + mitModificarUsuario = new javax.swing.JMenuItem(); + mitListarUsuarios = new javax.swing.JMenuItem(); + mitSeguirUsuario = new javax.swing.JMenuItem(); + mitSeguirUsuario1 = new javax.swing.JMenuItem(); + mitEliminarUsuario = new javax.swing.JMenuItem(); + mitConsultaUsuarioEliminado = new javax.swing.JMenuItem(); + menuVideo = new javax.swing.JMenu(); + mitNuevoVideo = new javax.swing.JMenuItem(); + mitModificarVideo = new javax.swing.JMenuItem(); + mitConsultarVideo = new javax.swing.JMenuItem(); + mitComentarVideo = new javax.swing.JMenuItem(); + mitValorarVideo = new javax.swing.JMenuItem(); + menuListaDeReproduccion = new javax.swing.JMenu(); + mitNuevaListaDeReproduccion = new javax.swing.JMenuItem(); + mitModificarListaDeReproduccion = new javax.swing.JMenuItem(); + mitConsultarListaDeReproduccion = new javax.swing.JMenuItem(); + mitAgregarVideoAListaDeReproduccion = new javax.swing.JMenuItem(); + mitQuitarVideoDeListaDeReproduccion = new javax.swing.JMenuItem(); + menuCategoria = new javax.swing.JMenu(); + mitNuevaCategoria = new javax.swing.JMenuItem(); + mitConsultarCategoria = new javax.swing.JMenuItem(); + mitListarCategorias = new javax.swing.JMenuItem(); + menuAbout = new javax.swing.JMenu(); + mitAcercaDeNos = new javax.swing.JMenuItem(); + + jMenuItem14.setText("jMenuItem14"); + + jMenuItem21.setText("jMenuItem21"); + + jList27.setModel(new javax.swing.AbstractListModel<String>() { + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; + public int getSize() { return strings.length; } + public String getElementAt(int i) { return strings[i]; } + }); + jScrollPane36.setViewportView(jList27); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("UyTube"); + setIconImage(getTconImage()); + setLocationByPlatform(true); + setMinimumSize(new java.awt.Dimension(800, 525)); + setPreferredSize(new java.awt.Dimension(800, 525)); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + + pnlFondo.setBackground(new java.awt.Color(0, 0, 26)); + pnlFondo.setLayout(new java.awt.GridLayout(1, 0)); + + lbFondo.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N + lbFondo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + lbFondo.setText("( > ) UyTube"); + pnlFondo.add(lbFondo); + + getContentPane().add(pnlFondo, java.awt.BorderLayout.CENTER); + + barraDeMenu.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N + + menuSesion.setText("Sesión"); + menuSesion.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N + + mitIniciarSesion.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitIniciarSesion.setText("Iniciar sesión"); + mitIniciarSesion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitIniciarSesionActionPerformed(evt); + } + }); + menuSesion.add(mitIniciarSesion); + + mitCerrarSesion.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitCerrarSesion.setText("Cerrar sesión"); + mitCerrarSesion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitCerrarSesionActionPerformed(evt); + } + }); + menuSesion.add(mitCerrarSesion); + + barraDeMenu.add(menuSesion); + + menuUsuario.setText("Usuario"); + menuUsuario.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N + + mitNuevoUsuario.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitNuevoUsuario.setText("Nuevo Usuario"); + mitNuevoUsuario.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitNuevoUsuarioActionPerformed(evt); + } + }); + menuUsuario.add(mitNuevoUsuario); + + mitConsultaUsuario.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitConsultaUsuario.setText("Consultar Usuario"); + mitConsultaUsuario.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitConsultaUsuarioActionPerformed(evt); + } + }); + menuUsuario.add(mitConsultaUsuario); + + mitModificarUsuario.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitModificarUsuario.setText("Modificar Usuario"); + mitModificarUsuario.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitModificarUsuarioActionPerformed(evt); + } + }); + menuUsuario.add(mitModificarUsuario); + + mitListarUsuarios.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitListarUsuarios.setText("Listar Usuarios"); + mitListarUsuarios.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitListarUsuariosActionPerformed(evt); + } + }); + menuUsuario.add(mitListarUsuarios); + + mitSeguirUsuario.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitSeguirUsuario.setText("Seguir Usuario"); + mitSeguirUsuario.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitSeguirUsuarioActionPerformed(evt); + } + }); + menuUsuario.add(mitSeguirUsuario); + + mitSeguirUsuario1.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitSeguirUsuario1.setText("Dejar de seguir usuario"); + mitSeguirUsuario1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitSeguirUsuario1ActionPerformed(evt); + } + }); + menuUsuario.add(mitSeguirUsuario1); + + mitEliminarUsuario.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitEliminarUsuario.setText("Eliminar usuario"); + mitEliminarUsuario.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitEliminarUsuarioActionPerformed(evt); + } + }); + menuUsuario.add(mitEliminarUsuario); + + mitConsultaUsuarioEliminado.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitConsultaUsuarioEliminado.setText("Consultar Usuario eliminado"); + mitConsultaUsuarioEliminado.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitConsultaUsuarioEliminadoActionPerformed(evt); + } + }); + menuUsuario.add(mitConsultaUsuarioEliminado); + + barraDeMenu.add(menuUsuario); + + menuVideo.setText("Video"); + menuVideo.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N + + mitNuevoVideo.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitNuevoVideo.setText("Nuevo Video"); + mitNuevoVideo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitNuevoVideoActionPerformed(evt); + } + }); + menuVideo.add(mitNuevoVideo); + + mitModificarVideo.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitModificarVideo.setText("Modificar Video"); + mitModificarVideo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitModificarVideoActionPerformed(evt); + } + }); + menuVideo.add(mitModificarVideo); + + mitConsultarVideo.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitConsultarVideo.setText("Consultar Video"); + mitConsultarVideo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitConsultarVideoActionPerformed(evt); + } + }); + menuVideo.add(mitConsultarVideo); + + mitComentarVideo.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitComentarVideo.setText("Comentar Video"); + mitComentarVideo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitComentarVideoActionPerformed(evt); + } + }); + menuVideo.add(mitComentarVideo); + + mitValorarVideo.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitValorarVideo.setText("Valorar Video"); + mitValorarVideo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitValorarVideoActionPerformed(evt); + } + }); + menuVideo.add(mitValorarVideo); + + barraDeMenu.add(menuVideo); + + menuListaDeReproduccion.setText("Lista de reproducción"); + menuListaDeReproduccion.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N + + mitNuevaListaDeReproduccion.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitNuevaListaDeReproduccion.setText("Nueva Lista"); + mitNuevaListaDeReproduccion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitNuevaListaDeReproduccionActionPerformed(evt); + } + }); + menuListaDeReproduccion.add(mitNuevaListaDeReproduccion); + + mitModificarListaDeReproduccion.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitModificarListaDeReproduccion.setText("Modificar Lista"); + mitModificarListaDeReproduccion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitModificarListaDeReproduccionActionPerformed(evt); + } + }); + menuListaDeReproduccion.add(mitModificarListaDeReproduccion); + + mitConsultarListaDeReproduccion.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitConsultarListaDeReproduccion.setText("Consultar Lista"); + mitConsultarListaDeReproduccion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitConsultarListaDeReproduccionActionPerformed(evt); + } + }); + menuListaDeReproduccion.add(mitConsultarListaDeReproduccion); + + mitAgregarVideoAListaDeReproduccion.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitAgregarVideoAListaDeReproduccion.setText("Agregar Video"); + mitAgregarVideoAListaDeReproduccion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitAgregarVideoAListaDeReproduccionActionPerformed(evt); + } + }); + menuListaDeReproduccion.add(mitAgregarVideoAListaDeReproduccion); + + mitQuitarVideoDeListaDeReproduccion.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitQuitarVideoDeListaDeReproduccion.setText("Quitar Video"); + mitQuitarVideoDeListaDeReproduccion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitQuitarVideoDeListaDeReproduccionActionPerformed(evt); + } + }); + menuListaDeReproduccion.add(mitQuitarVideoDeListaDeReproduccion); + + barraDeMenu.add(menuListaDeReproduccion); + + menuCategoria.setText("CategorÃa"); + menuCategoria.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N + + mitNuevaCategoria.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitNuevaCategoria.setText("Nueva CategorÃa"); + mitNuevaCategoria.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitNuevaCategoriaActionPerformed(evt); + } + }); + menuCategoria.add(mitNuevaCategoria); + + mitConsultarCategoria.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitConsultarCategoria.setText("Consultar CategorÃa"); + mitConsultarCategoria.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitConsultarCategoriaActionPerformed(evt); + } + }); + menuCategoria.add(mitConsultarCategoria); + + mitListarCategorias.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitListarCategorias.setText("Listar CategorÃa"); + mitListarCategorias.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitListarCategoriasActionPerformed(evt); + } + }); + menuCategoria.add(mitListarCategorias); + + barraDeMenu.add(menuCategoria); + + menuAbout.setText("About"); + menuAbout.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N + + mitAcercaDeNos.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + mitAcercaDeNos.setText("Acerca de nos"); + mitAcercaDeNos.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mitAcercaDeNosActionPerformed(evt); + } + }); + menuAbout.add(mitAcercaDeNos); + + barraDeMenu.add(menuAbout); + + setJMenuBar(barraDeMenu); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void mitIniciarSesionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitIniciarSesionActionPerformed + //Sesion->iniciarSecion + + frmInicioSesion login = new frmInicioSesion(this, true); + login.setVisible(true); + sesionIniciada = login.seInicioLaSesion(); + + if (sesionIniciada){ + activarBarraDeMenu(true); + mitCerrarSesion.setEnabled(true); + mitIniciarSesion.setEnabled(false); + }else{ + activarBarraDeMenu(false); + } + }//GEN-LAST:event_mitIniciarSesionActionPerformed + + private void mitCerrarSesionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitCerrarSesionActionPerformed + //Sesion->cerrar secion + sesionIniciada = false; + mitCerrarSesion.setEnabled(false); + mitIniciarSesion.setEnabled(true); + activarBarraDeMenu(false); + }//GEN-LAST:event_mitCerrarSesionActionPerformed + + private void mitNuevoUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitNuevoUsuarioActionPerformed + //Usiario->nuevo Usuario + new frmAltaUsuario(this, true).setVisible(true); + }//GEN-LAST:event_mitNuevoUsuarioActionPerformed + + private void mitComentarVideoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitComentarVideoActionPerformed + //Video->comentar video + new frmComentarVideo(this, true).setVisible(true); + }//GEN-LAST:event_mitComentarVideoActionPerformed + + private void mitConsultaUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitConsultaUsuarioActionPerformed + //Usuario->consultar usuario + new frmConsultaUsuario(this, true).setVisible(true); + + /* Este codigo puede reciclarse quizas... + Consultar_Usuario.setVisible(true); + //jList1.addListSelectionListener(listener); + String[] usr = new String[3]; + usr[0] = "MCBOLSO"; + usr[1] = "Juan_96"; + usr[2] = "Pepe_85"; + + jList1.setListData(usr); + //JOptionPane.showMessageDialog(null, jList1.getSele); + menuUsuario.setEnabled(false); + menuVideo.setEnabled(false); + menuListaDeReproduccion.setEnabled(false); + menuCategoria.setEnabled(false); + menuSesion.setEnabled(false); + menuAbout.setEnabled(false); + */ + }//GEN-LAST:event_mitConsultaUsuarioActionPerformed + + private void mitModificarUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitModificarUsuarioActionPerformed + //Usuario->modificar usuario + new frmModificarUsuario(this, true).setVisible(true); + }//GEN-LAST:event_mitModificarUsuarioActionPerformed + + private void mitAcercaDeNosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitAcercaDeNosActionPerformed + //About->Acerca de nos + new frmAcercaDeNos(this, true).setVisible(true); + }//GEN-LAST:event_mitAcercaDeNosActionPerformed + + private void mitListarUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitListarUsuariosActionPerformed + //Usuario->listar usuario + new frmListarUsuarios(this, true).setVisible(true); + }//GEN-LAST:event_mitListarUsuariosActionPerformed + + private void mitSeguirUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitSeguirUsuarioActionPerformed + //usuario->seruir usuario->acptar + new frmSeguirUsuario(this, true).setVisible(true); + }//GEN-LAST:event_mitSeguirUsuarioActionPerformed + + private void mitNuevoVideoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitNuevoVideoActionPerformed + // video->nuevo video + new frmAltaVideo(this, true).setVisible(true); + }//GEN-LAST:event_mitNuevoVideoActionPerformed + + private void mitModificarVideoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitModificarVideoActionPerformed + // video->modificar video + new frmModificarVideo(this, true).setVisible(true); + }//GEN-LAST:event_mitModificarVideoActionPerformed + + private void mitConsultarVideoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitConsultarVideoActionPerformed + // video->consultar video + new frmConsultaVideo(this, true).setVisible(true); + }//GEN-LAST:event_mitConsultarVideoActionPerformed + + private void mitValorarVideoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitValorarVideoActionPerformed + //vieo->calorar video->aceptar + new frmValorarVideo(this, true).setVisible(true); + }//GEN-LAST:event_mitValorarVideoActionPerformed + + private void mitNuevaListaDeReproduccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitNuevaListaDeReproduccionActionPerformed + //lista_rep->nueva_list_rep + new frmAltaListaDeReproduccion(this, true).setVisible(true); + }//GEN-LAST:event_mitNuevaListaDeReproduccionActionPerformed + + private void mitModificarListaDeReproduccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitModificarListaDeReproduccionActionPerformed + //lista_rep->modificar + new frmModificarListaDeReproduccion(this, true).setVisible(true); + }//GEN-LAST:event_mitModificarListaDeReproduccionActionPerformed + + private void mitConsultarListaDeReproduccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitConsultarListaDeReproduccionActionPerformed + //listaRep->consultarlitRep + new frmConsultaListaDeReproduccion(this, true).setVisible(true); + }//GEN-LAST:event_mitConsultarListaDeReproduccionActionPerformed + + private void mitAgregarVideoAListaDeReproduccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitAgregarVideoAListaDeReproduccionActionPerformed + //listaRep->agregarVideo + new frmAgregarVideoAListaDeReproduccion(this, true).setVisible(true); + }//GEN-LAST:event_mitAgregarVideoAListaDeReproduccionActionPerformed + + private void mitQuitarVideoDeListaDeReproduccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitQuitarVideoDeListaDeReproduccionActionPerformed + //listaRep->quitarVideo + new frmQuitarVideoDeListaDeReproduccion(this, true).setVisible(true); + }//GEN-LAST:event_mitQuitarVideoDeListaDeReproduccionActionPerformed + + private void mitNuevaCategoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitNuevaCategoriaActionPerformed + //categoria->nuevaCat + new frmAltaCategoria(this, true).setVisible(true); + }//GEN-LAST:event_mitNuevaCategoriaActionPerformed + + private void mitListarCategoriasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitListarCategoriasActionPerformed + //categoria->lisatr categoria + new frmListarCategorias(this, true).setVisible(true); + }//GEN-LAST:event_mitListarCategoriasActionPerformed + + private void mitConsultarCategoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitConsultarCategoriaActionPerformed + //categoria->consultarCategoria + new frmConsultaCategoria(this, true).setVisible(true); + }//GEN-LAST:event_mitConsultarCategoriaActionPerformed + + private void mitSeguirUsuario1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitSeguirUsuario1ActionPerformed + // TODO add your handling code here: + new frmDejarDeSeguirUsuario(this, true).setVisible(true); + }//GEN-LAST:event_mitSeguirUsuario1ActionPerformed + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + // al cerrar la ventana + int exit = JOptionPane.showConfirmDialog( + this, /* Ventana padre*/ + "¿Seguro que quieres salir?", /* mensaje */ + "¿Seguro?", /* Titulo */ + JOptionPane.YES_NO_OPTION, /* opciones en botones */ + JOptionPane.QUESTION_MESSAGE /* tipo de icono */ + ); + if (exit == JOptionPane.YES_OPTION) { + System.exit(0); + } + }//GEN-LAST:event_formWindowClosing + + private void mitEliminarUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitEliminarUsuarioActionPerformed + // usuario -> eliminar usuario + new frmBajaUsuario(this, true).setVisible(true); + }//GEN-LAST:event_mitEliminarUsuarioActionPerformed + + private void mitConsultaUsuarioEliminadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitConsultaUsuarioEliminadoActionPerformed + // usuario -> Consultar usuario eliminado + new frmConsultaUsuarioEliminado(this, true).setVisible(true); + }//GEN-LAST:event_mitConsultaUsuarioEliminadoActionPerformed + + + private void activarBarraDeMenu(boolean b){ + menuUsuario.setEnabled(b); + menuListaDeReproduccion.setEnabled(b); + menuVideo.setEnabled(b); + menuCategoria.setEnabled(b); + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Metal".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(frmPrincipal.class + .getName()).log(java.util.logging.Level.SEVERE, null, ex); + + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(frmPrincipal.class + .getName()).log(java.util.logging.Level.SEVERE, null, ex); + + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(frmPrincipal.class + .getName()).log(java.util.logging.Level.SEVERE, null, ex); + + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(frmPrincipal.class + .getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new frmPrincipal().setVisible(true); + + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JMenuBar barraDeMenu; + private javax.swing.JList<String> jList27; + private javax.swing.JMenuItem jMenuItem14; + private javax.swing.JMenuItem jMenuItem21; + private javax.swing.JScrollPane jScrollPane36; + private javax.swing.JLabel lbFondo; + private javax.swing.JMenu menuAbout; + private javax.swing.JMenu menuCategoria; + private javax.swing.JMenu menuListaDeReproduccion; + private javax.swing.JMenu menuSesion; + private javax.swing.JMenu menuUsuario; + private javax.swing.JMenu menuVideo; + private javax.swing.JMenuItem mitAcercaDeNos; + private javax.swing.JMenuItem mitAgregarVideoAListaDeReproduccion; + private javax.swing.JMenuItem mitCerrarSesion; + private javax.swing.JMenuItem mitComentarVideo; + private javax.swing.JMenuItem mitConsultaUsuario; + private javax.swing.JMenuItem mitConsultaUsuarioEliminado; + private javax.swing.JMenuItem mitConsultarCategoria; + private javax.swing.JMenuItem mitConsultarListaDeReproduccion; + private javax.swing.JMenuItem mitConsultarVideo; + private javax.swing.JMenuItem mitEliminarUsuario; + private javax.swing.JMenuItem mitIniciarSesion; + private javax.swing.JMenuItem mitListarCategorias; + private javax.swing.JMenuItem mitListarUsuarios; + private javax.swing.JMenuItem mitModificarListaDeReproduccion; + private javax.swing.JMenuItem mitModificarUsuario; + private javax.swing.JMenuItem mitModificarVideo; + private javax.swing.JMenuItem mitNuevaCategoria; + private javax.swing.JMenuItem mitNuevaListaDeReproduccion; + private javax.swing.JMenuItem mitNuevoUsuario; + private javax.swing.JMenuItem mitNuevoVideo; + private javax.swing.JMenuItem mitQuitarVideoDeListaDeReproduccion; + private javax.swing.JMenuItem mitSeguirUsuario; + private javax.swing.JMenuItem mitSeguirUsuario1; + private javax.swing.JMenuItem mitValorarVideo; + private javax.swing.JDesktopPane pnlFondo; + public static javax.swing.ButtonGroup privacidad_NuevaLR; + public static javax.swing.ButtonGroup privacidad_modListaR; + public static javax.swing.ButtonGroup privacidad_modUsuario; + public static javax.swing.ButtonGroup privacidad_modVideo; + public static javax.swing.ButtonGroup privacidad_nuevoUsuario; + public static javax.swing.ButtonGroup tipo_nLR; + public static javax.swing.ButtonGroup valorarVideo; + // End of variables declaration//GEN-END:variables +} + + /* + public boolean isIntegerTF(javax.swing.JTextField TF) { + try { + Integer.parseInt(TF.getText()); + return true; + } catch (Exception e) { + return false; + } + } + */ \ No newline at end of file diff --git a/datos_de_prueba.sql b/datos_de_prueba.sql index 4e2069ac871dd96181fc4991e88c7a68e2b6ccba..2022e8850b6d5057203393f3a71c59478688a529 100644 --- a/datos_de_prueba.sql +++ b/datos_de_prueba.sql @@ -31,13 +31,13 @@ INSERT INTO public.canal (descripcion,eliminado,nombre,privacidad) VALUES -- Usuarios INSERT INTO public.usuario (id,apellido,contrasenia,correo,eliminado,fecha_eliminado,fecha_nacimiento,imagen,nombre,seguidores,id_canal) VALUES -('MCBolso','Castro','12345678','mcbolso96@gmail.com',false,NULL,'1999-08-04','Imagenes\perfiles\MCBolso.jpg','Mariano',0,3) -,('JotaJota96','Alvarez','12345678','jjap96@gmail.com',false,NULL,'1996-10-09','Imagenes\perfiles\JotaJota96.jpg','Juan',3,1) +('JotaJota96','Alvarez','12345678','jjap96@gmail.com',false,NULL,'1996-10-09','Imagenes\perfiles\JotaJota96.jpg','Juan',3,1) ,('LuC31G','Garrido','12345678','LuC31@gmail.com',false,NULL,'1998-12-31','Imagenes\perfiles\LuC31G.jpg','Lucas',2,2) +,('MCBolso','Castro','12345678','mcbolso96@gmail.com',false,NULL,'1999-08-04','Imagenes\perfiles\MCBolso.jpg','Mariano',0,3) +,('camilillo15','Camilo','12345678','facu_camilo2@hotmail.com',false,NULL,'1999-07-13','Imagenes\perfiles\camilillo15.jpg','Facundo',1,4) ,('jarrieta31','Arrieta','jarrieta31','julioarrieta23@gmail.com',false,NULL,'1976-03-02','Imagenes\perfiles\jarrieta31.jpg','Julio',4,5) ,('terraplanista1','Ibañez','terraplanista1','olivertierraplana@gmail.com',false,NULL,'2019-10-03','','Oliver',0,6) ,('apmi','Pastores','apmi','apmi@hotmail.com',false,NULL,'2019-10-03','','Alerta',1,7) -,('camilillo15','Camilo','12345678','facu_camilo2@hotmail.com',false,NULL,'1999-07-13','Imagenes\perfiles\camilillo15.jpg','Facundo',1,4) ; -- Usuarios seguidores @@ -72,28 +72,29 @@ INSERT INTO public.usuarios_seguidos (nick_seguidor,nick_seguido) VALUES -- Videos INSERT INTO public.video (cant_dislikes,cant_likes,categoria,descripcion,duracion,eliminado,fecha_publicacion,nombre,privacidad,url,id_canal) VALUES -(1,0,'DEPORTE','Canta el bolso en la previa vs San Lorenzo','00:00:42',false,'2019-07-21','No se como voy, no se como vengo','PUBLICO','https://www.youtube.com/watch?v=S0_FBF8XaO0',3) +(1,1,'MUSICA','Cover de La casa de al lado Christian Cary','00:05:43',false,'2019-07-21','La casa de al lado Christian Cary (Cover en guitarra)','PUBLICO','https://www.youtube.com/watch?v=An0uvGCUB9k',1) +,(0,0,'MUSICA','Cover de Verde - La Triple Nelson','00:03:32',false,'2019-09-29','Verde - La Triple Nelson (Cover en guitarra)','PUBLICO','https://www.youtube.com/watch?v=ojYnrNRXOjk',1) +,(0,1,'MUSICA','Cover de Naufrago - 4 Pesos de Propina ','00:03:36',false,'2019-02-02','Naufrago - 4 Pesos de Propina (Cover en guitarra)','PUBLICO','https://www.youtube.com/watch?v=ksuDZQuJLSY',1) +,(0,0,'MUSICA','Cover de Como pasa el tiempo - Cuarteto de nos ','00:04:32',false,'2019-05-15','Como pasa el tiempo - Cuarteto de nos (Cover en guitarra)','PUBLICO','https://www.youtube.com/watch?v=n1AR_VSHPek',1) +,(2,1,'UNDEFINED','Hola Que hace xD xD xD','00:00:47',false,'2019-02-02','HolaQueHace','PUBLICO','https://www.youtube.com/watch?v=Nl-Sq5OXIWk',2) +,(1,0,'DEPORTE','Canta el bolso en la previa vs San Lorenzo','00:00:42',false,'2019-07-21','No se como voy, no se como vengo','PUBLICO','https://www.youtube.com/watch?v=S0_FBF8XaO0',3) ,(1,0,'DEPORTE','Por la del Bolso hay que matar o morir - La Banda Del Parque','00:02:11',false,'2019-05-15','C.N. de F. Tema Nuevo 2019','PUBLICO','https://www.youtube.com/watch?v=9L5qQ9iyhJk',3) +,(1,0,'MUSICA','de La Banda del Parque (CON LETRA) | Hinchada de Nacional 2019','00:09:26',false,'2019-09-29','Las mejores canciones de La Banda','PUBLICO','https://www.youtube.com/watch?v=ob0TPs5-Y5Y',3) ,(1,0,'UNDEFINED','Camila Guiribitey','10:10:43',false,'2019-02-02','NO CREERÃS LO QUE LLEVO EN MI BOLSO','PUBLICO','https://www.youtube.com/watch?v=7wCUuplgmQM',3) -,(0,1,'UNDEFINED','Foto del apolo 15 con la bandera. -https://www.flickr.com/photos/projectapolloarchive/21489361038/in/album-72157659044904175/','00:20:47',false,'2019-10-03','Analizando la Misteriosa Bandera ´´Flameante´´ del Apolo 15','PUBLICO','https://www.youtube.com/watch?v=I8AGvzp554c',7) +,(0,1,'MUSICA','Album Favourite Worst Nightmare','00:04:09',false,'2019-02-02','505 - Arctic Monkeys','PUBLICO','https://www.youtube.com/watch?v=iV5VKdcQOJE',4) +,(0,3,'MUSICA','Ni idea como se llama el album','00:04:37',false,'2019-05-15','Wonderwall - Oasis','PUBLICO','https://www.youtube.com/watch?v=bx1Bh8ZvH84',4) +,(0,1,'UNDEFINED','Curso de android, tarea 4','00:04:02',false,'2019-10-30','Tutorial android 1','PUBLICO','https://www.youtube.com/watch?v=xCq7YXGXaLc&list=PL-6ex1wzFuEh9RUN-5nCOU13eYknEXl09',5) +,(0,0,'UNDEFINED','Curso de android, tarea 5','00:01:17',false,'2019-10-30','Tutorial android 2','PUBLICO','https://www.youtube.com/watch?v=i4W5LFeIdNU',5) ,(1,0,'UNDEFINED','CientÃficos descubren algo extraño en la cara oculta de la Luna.','00:10:02',false,'2019-10-03','Descubren algo EXTRAÑO en la cara OCULTA de la Luna','PRIVADO','https://www.youtube.com/watch?v=ObpYRHbwT9Y',6) ,(1,0,'UNDEFINED','El Segundo Libro de Enoc revela cómo fueron creados los cielos, la Tierra, el Domo, los seres visibles e invisibles y más misterios.','00:10:20',false,'2019-10-03','Los SECRETOS de la Creación revelados a Enoc','PRIVADO','https://www.youtube.com/watch?v=WuDyGe-Ir8A',6) -,(0,1,'MUSICA','Ni idea como se llama el album','00:04:37',false,'2019-05-15','Wonderwall - Oasis','PUBLICO','https://www.youtube.com/watch?v=bx1Bh8ZvH84',4) -,(0,2,'MUSICA','Album Favourite Worst Nightmare','00:04:09',false,'2019-02-02','505 - Arctic Monkeys','PUBLICO','https://www.youtube.com/watch?v=iV5VKdcQOJE',4) -,(2,2,'UNDEFINED','Curso de android, tarea 4','00:04:02',false,'2019-10-30','Tutorial android 1','PUBLICO','https://www.youtube.com/watch?v=xCq7YXGXaLc&list=PL-6ex1wzFuEh9RUN-5nCOU13eYknEXl09',5) -,(0,1,'UNDEFINED','Curso de android, tarea 5','00:01:17',false,'2019-10-30','Tutorial android 2','PUBLICO','https://www.youtube.com/watch?v=i4W5LFeIdNU',5) -,(0,0,'MUSICA','Cover de La casa de al lado Christian Cary','00:05:43',false,'2019-07-21','La casa de al lado Christian Cary (Cover en guitarra)','PUBLICO','https://www.youtube.com/watch?v=An0uvGCUB9k',1) -,(0,1,'MUSICA','Cover de Verde - La Triple Nelson','00:03:32',false,'2019-09-29','Verde - La Triple Nelson (Cover en guitarra)','PUBLICO','https://www.youtube.com/watch?v=ojYnrNRXOjk',1) -,(2,3,'MUSICA','Cover de Naufrago - 4 Pesos de Propina ','00:03:36',false,'2019-02-02','Naufrago - 4 Pesos de Propina (Cover en guitarra)','PUBLICO','https://www.youtube.com/watch?v=ksuDZQuJLSY',1) -,(0,0,'MUSICA','Cover de Como pasa el tiempo - Cuarteto de nos ','00:04:32',false,'2019-05-15','Como pasa el tiempo - Cuarteto de nos (Cover en guitarra)','PUBLICO','https://www.youtube.com/watch?v=n1AR_VSHPek',1) -,(2,1,'UNDEFINED','Hola Que hace xD xD xD','00:00:47',false,'2019-02-02','HolaQueHace','PUBLICO','https://www.youtube.com/watch?v=Nl-Sq5OXIWk',2) -,(1,0,'MUSICA','de La Banda del Parque (CON LETRA) | Hinchada de Nacional 2019','00:09:26',false,'2019-09-29','Las mejores canciones de La Banda','PUBLICO','https://www.youtube.com/watch?v=ob0TPs5-Y5Y',3) ,(1,0,'UNDEFINED','Las antiguas civilizaciones, manuscritos antiguos y varios hechos sorprendentes apuntan a la existencia de un lÃmite en el cielo y debajo de la Tierra.','00:10:00',false,'2019-10-03','Los limites del DOMO','PRIVADO','https://www.youtube.com/watch?v=a_qHPssKjCw',6) +,(0,1,'UNDEFINED','Foto del apolo 15 con la bandera. +https://www.flickr.com/photos/projectapolloarchive/21489361038/in/album-72157659044904175/','00:20:47',false,'2019-10-03','Analizando la Misteriosa Bandera ´´Flameante´´ del Apolo 15','PUBLICO','https://www.youtube.com/watch?v=I8AGvzp554c',7) ,(0,1,'UNDEFINED','Video donde respondo al video de alarma mundial sobre la cuestión de que no haya refutado sus hipótesis.','00:56:27',false,'2019-10-03','Sobre las Hipótesis Infalsables, Falsacionismo y Efecto Lupa terraplano','PUBLICO','https://www.youtube.com/watch?v=uvEyal8j0Uo',7) ,(0,1,'UNDEFINED','Comparando Saturno este año respecto del año anterior y observando el cambio de la inclinación de sus anillos a medida que el planeta se traslada alrededor del sol.','00:04:32',false,'2019-10-03','Comparación de Saturno en 2019 vs 2018','PUBLICO','https://www.youtube.com/watch?v=xta6f4CyoMk',7) ; + -- Listas de reproduccion INSERT INTO public.lista_de_reproduccion (categoria,eliminado,nombre,privacidad,tipo,id_canal) VALUES ('UNDEFINED',false,'Ver mas tarde','PRIVADO','POR_DEFECTO',1) @@ -101,11 +102,11 @@ INSERT INTO public.lista_de_reproduccion (categoria,eliminado,nombre,privacidad, ,('UNDEFINED',false,'Ver mas tarde','PRIVADO','POR_DEFECTO',3) ,('UNDEFINED',false,'Ver mas tarde','PRIVADO','POR_DEFECTO',4) ,('UNDEFINED',false,'Ver mas tarde','PRIVADO','POR_DEFECTO',5) -,('UNDEFINED',false,'Bolso siempre bolso naa','PUBLICO','PARTICULAR',3) -,('MUSICA',false,'Oasis','PUBLICO','PARTICULAR',4) ,('MUSICA',false,'Mis covers','PUBLICO','PARTICULAR',1) ,('GAMING',false,'Minecraft','PRIVADO','PARTICULAR',1) ,('UNDEFINED',false,'Pasar el rato','PRIVADO','PARTICULAR',2) +,('UNDEFINED',false,'Bolso siempre bolso naa','PUBLICO','PARTICULAR',3) +,('MUSICA',false,'Oasis','PUBLICO','PARTICULAR',4) ,('UNDEFINED',false,'Ver mas tarde','PRIVADO','POR_DEFECTO',6) ,('UNDEFINED',false,'Ver mas tarde','PRIVADO','POR_DEFECTO',7) ,('UNDEFINED',false,'videos de terraboludos','PRIVADO','PARTICULAR',7) @@ -126,66 +127,62 @@ INSERT INTO public.comentario (fecha,nivel,texto,nick_usuario,id_com_padre,id_vi ,('2019-08-01',2,'Tipico, nadie usa Linux.','MCBolso',10,NULL) ,('2019-08-01',3,'Boo, que paso con Linux? hee??','jarrieta31',11,NULL) ,('2019-08-01',2,'Yo que vos me compro una MAC...','camilillo15',10,NULL) -,('2019-10-03',0,'Me recuerda a Bulevard of broquen drims','LuC31G',NULL,9) +,('2019-10-03',0,'Me recuerda a Bulevard of broquen drims','LuC31G',NULL,11) ,('2019-10-03',1,'Si, pa mi que green day les copio...','MCBolso',14,NULL) ,('2019-10-03',2,'O ellos a green day','LuC31G',15,NULL) ,('2019-10-03',3,'nunca lo sabremos...','jarrieta31',16,NULL) ,('2019-10-03',1,'A mi me pasa al revez, esa me recuerda a esta','JotaJota96',14,NULL) -,('2019-10-03',0,'que al pedo que estas','camilillo15',NULL,12) -,('2019-10-03',0,'lo mejor que he visto!','jarrieta31',NULL,12) -,('2019-10-03',0,'¿Como se llama esa cancion?','MCBolso',NULL,12) -,('2019-10-03',0,'Cuando subis la parte 2?','JotaJota96',NULL,13) +,('2019-10-03',0,'que al pedo que estas','camilillo15',NULL,5) +,('2019-10-03',0,'lo mejor que he visto!','jarrieta31',NULL,5) +,('2019-10-03',0,'¿Como se llama esa cancion?','MCBolso',NULL,5) +,('2019-10-03',0,'Cuando subis la parte 2?','JotaJota96',NULL,12) ,('2019-10-03',1,'Ya esta subida, buscala en mis videos','jarrieta31',22,NULL) -,('2019-10-03',0,'¿Algun tutorial de MAC que me recomiendes?','camilillo15',NULL,13) +,('2019-10-03',0,'¿Algun tutorial de MAC que me recomiendes?','camilillo15',NULL,12) ,('2019-10-03',1,'Instalale windows!','MCBolso',24,NULL) ; -- Valoraciones INSERT INTO public.valoracion (val,nick_usuario,id_video) VALUES -('LIKE','LuC31G',1) -,('LIKE','MCBolso',1) -,('DISLIKE','camilillo15',1) -,('DISLIKE','jarrieta31',1) +('LIKE','JotaJota96',19) +,('LIKE','JotaJota96',18) +,('LIKE','JotaJota96',17) ,('LIKE','JotaJota96',5) -,('DISLIKE','jarrieta31',5) -,('DISLIKE','MCBolso',12) +,('LIKE','JotaJota96',12) +,('LIKE','LuC31G',1) ,('LIKE','LuC31G',3) -,('LIKE','LuC31G',11) -,('DISLIKE','camilillo15',12) -,('DISLIKE','camilillo15',7) -,('DISLIKE','camilillo15',6) -,('DISLIKE','camilillo15',5) -,('DISLIKE','camilillo15',4) -,('LIKE','JotaJota96',8) -,('LIKE','JotaJota96',9) -,('LIKE','MCBolso',13) -,('LIKE','MCBolso',10) -,('LIKE','LuC31G',13) -,('LIKE','jarrieta31',8) +,('DISLIKE','camilillo15',1) ,('DISLIKE','apmi',16) ,('DISLIKE','apmi',15) ,('DISLIKE','apmi',14) -,('LIKE','JotaJota96',19) -,('LIKE','JotaJota96',18) -,('LIKE','JotaJota96',17) +,('DISLIKE','camilillo15',8) +,('DISLIKE','camilillo15',7) +,('DISLIKE','camilillo15',9) +,('DISLIKE','camilillo15',6) +,('DISLIKE','camilillo15',5) +,('DISLIKE','MCBolso',5) +,('LIKE','JotaJota96',11) +,('LIKE','camilillo15',11) +,('LIKE','camilillo15',10) +,('LIKE','LuC31G',11) ; -- Videos en listas INSERT INTO public.videos_en_listas (id_lista,id_video) VALUES -(13,6) -,(8,11) -,(8,12) -,(8,13) -,(8,14) -,(13,17) -,(10,15) -,(7,7) -,(7,8) -,(6,2) +(13,16) +,(13,15) +,(13,14) ,(6,1) +,(8,5) ,(1,19) -,(1,17) -,(5,6) -,(2,10) -,(12,14) -; \ No newline at end of file +,(1,16) +,(9,9) +,(9,6) +,(9,7) +,(9,8) +,(6,2) +,(6,3) +,(6,4) +,(10,10) +,(4,4) +,(3,14) +;