From: Roland Haeder Date: Wed, 2 Sep 2015 12:52:22 +0000 (+0200) Subject: Initial commit X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=277ed9fe57a45c17c3f9c6d3b93d128b3e5d4ddc;p=jcore-swing.git Initial commit Signed-off-by: Roland Haeder --- 277ed9fe57a45c17c3f9c6d3b93d128b3e5d4ddc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1cd7a86 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/nbproject/private/ +/manifest.mf +/build/ +/dist/ +/*.properties diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..3502d13 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project jswingcore. + + + diff --git a/dist.sh b/dist.sh new file mode 100644 index 0000000..1626a6a --- /dev/null +++ b/dist.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +LIST=`find ../*/lib/jcore.jar` + +for entry in ${LIST}; +do + cp -v dist/jswingcore.jar ${entry} +done diff --git a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..eaf6790 Binary files /dev/null and b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/lib/jcore.jar b/lib/jcore.jar new file mode 100644 index 0000000..5ed709d Binary files /dev/null and b/lib/jcore.jar differ diff --git a/lib/log4j-api-2.3.jar b/lib/log4j-api-2.3.jar new file mode 100644 index 0000000..2a61bbe Binary files /dev/null and b/lib/log4j-api-2.3.jar differ diff --git a/lib/log4j-core-2.3.jar b/lib/log4j-core-2.3.jar new file mode 100644 index 0000000..5438b0b Binary files /dev/null and b/lib/log4j-core-2.3.jar differ diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties new file mode 100644 index 0000000..6d0afb5 --- /dev/null +++ b/lib/nblibraries.properties @@ -0,0 +1,4 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=2.0 diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..b6249fb --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1438 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..cd765b0 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=3685b2a8 +build.xml.script.CRC32=a2a4a6c0 +build.xml.stylesheet.CRC32=8064a381@1.75.2.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=3685b2a8 +nbproject/build-impl.xml.script.CRC32=2f43013b +nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..efc7157 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,97 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=jswingcore +application.vendor=Roland Haeder +auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml +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}/jswingcore.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.jcore.jar=lib\\jcore.jar +file.reference.log4j-api-2.3.jar=lib\\log4j-api-2.3.jar +file.reference.log4j-core-2.3.jar=lib\\log4j-core-2.3.jar +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=false +jar.index=${jnlp.enabled} +javac.classpath=\ + ${file.reference.jcore.jar}:\ + ${file.reference.log4j-api-2.3.jar}:\ + ${file.reference.log4j-core-2.3.jar} +# Space-separated list of extra javac options +javac.compilerargs=-Xlint:unchecked -Xlint:deprecation +javac.deprecation=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=true +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=true +javadoc.splitindex=true +javadoc.use=true +javadoc.version=true +javadoc.windowtitle=Swing Framework +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= +# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed +manifest.custom.codebase= +# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) +manifest.custom.permissions= +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=true +platform.active=default_platform +project.license=gpl30 +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 +source.reference.jcore.jar=../jcore/src +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..ef80e17 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.java.j2seproject + + + jswingcore + + + + + + + + + .\lib\nblibraries.properties + + + diff --git a/src/org/mxchange/jswingcore/client/gui/ClientFrame.java b/src/org/mxchange/jswingcore/client/gui/ClientFrame.java new file mode 100644 index 0000000..6116205 --- /dev/null +++ b/src/org/mxchange/jswingcore/client/gui/ClientFrame.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jswingcore.client.gui; + +import java.io.IOException; +import org.mxchange.jcore.FrameworkInterface; +import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.Contact; +import org.mxchange.jcore.exceptions.BadTokenException; +import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException; + +/** + * An interface for applications with a frame + * + * @author Roland Haeder + */ +public interface ClientFrame extends FrameworkInterface { + + /** + * Shows the user the "add contact" form with some special text + * + * @return Contact instance + */ + public Contact doEnterOwnData (); + + /** + * Shutdown this frame + */ + public void doShutdown (); + + /** + * Enables main window (frame) + */ + public void enableMainWindow (); + + /** + * Setups the frame (and starts it). You have to call init() before you can + * call this method. + * + * @param client Client instance + * @throws java.io.IOException If an IO error was found + * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found + */ + public void setupFrame (final Client client) throws IOException, BadTokenException; + + /** + * Initializes frame + * + * @throws org.mxchange.jcore.exceptions.FrameAlreadyInitializedException If this method has been called twice + */ + public void init () throws FrameAlreadyInitializedException; + + /** + * Returns field isInitialized. This flag indicates whether this frame has + * been initialized or not. + * + * @return Field isInitialized + */ + public boolean isInitialized (); + + /** + * Shuts down application + */ + public void shutdownApplication (); +} diff --git a/src/org/mxchange/jswingcore/model/BaseModel.java b/src/org/mxchange/jswingcore/model/BaseModel.java new file mode 100644 index 0000000..78b0e3e --- /dev/null +++ b/src/org/mxchange/jswingcore/model/BaseModel.java @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jswingcore.model; + +import java.text.MessageFormat; +import javax.swing.event.EventListenerList; +import javax.swing.event.ListDataListener; +import javax.swing.event.TableModelListener; +import org.mxchange.jcore.BaseFrameworkSystem; + +/** + * + * @author Roland Haeder + */ +public class BaseModel extends BaseFrameworkSystem { + + /** + * List of event listeners + */ + private final EventListenerList eventListenerList; + + /** + * Protected constructor + */ + protected BaseModel () { + // Trace message + this.getLogger().trace("CALLED!"); //NOI18N + + // Init listener list + this.eventListenerList = new EventListenerList(); + } + + /** + * Adds a lister of this type to the list + * + * @param listener Listener instance + */ + public void addListDataListener (final ListDataListener listener) { + // Trace message + this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N + + // Listener must not be null + if (null == listener) { + // Abort here + throw new NullPointerException("listener is null"); + } + + // Debug message + this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); + + // Remove listener + this.eventListenerList.add(ListDataListener.class, listener); + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } + + /** + * Adds a TableModel listener instance to the event list. + * + * @param listener Lister instance + */ + public void addTableModelListener (final TableModelListener listener) { + // Trace message + this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N + + // Listener must not be null + if (null == listener) { + // Abort here + throw new NullPointerException("listener is null"); + } + + // Debug message + this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); + + // Add listener + this.eventListenerList.add(TableModelListener.class, listener); + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } + + /** + * Removes given listener + * + * @param listener Listener instance + */ + public void removeListDataListener (final ListDataListener listener) { + // Trace message + this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N + + // Listener must not be null + if (null == listener) { + // Abort here + throw new NullPointerException("listener is null"); + } + + // Debug message + this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); + + // Remove listener + this.eventListenerList.remove(ListDataListener.class, listener); + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } + + /** + * Removes a TableModel listener instance from the event list. + * + * @param listener Listener instance + */ + public void removeTableModelListener (final TableModelListener listener) { + // Trace message + this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N + + // Listener must not be null + if (null == listener) { + // Abort here + throw new NullPointerException("listener is null"); + } + + // Debug message + this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); + + // Remove listener + this.eventListenerList.remove(TableModelListener.class, listener); + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } +} diff --git a/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java b/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java new file mode 100644 index 0000000..5248234 --- /dev/null +++ b/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jswingcore.model.swing.contact; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.text.MessageFormat; +import javax.swing.table.TableModel; +import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.manager.database.ManageableDatabase; +import org.mxchange.jswingcore.model.BaseModel; + +/** + * A table model for contacts + * + * @author Roland Haeder + */ +public class ContactTableModel extends BaseModel implements TableModel { + + /** + * Constructor with Client instance which holds the contact manager + * + * @param client Client instance + */ + public ContactTableModel (final Client client) { + // Trace message + this.getLogger().trace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N + + // Client must not be null + if (null == client) { + // Abort here + throw new NullPointerException("client is null"); //NOI18N + } + + // Set client + this.setClient(client); + } + + @Override + public Class getColumnClass (final int columnIndex) { + // All is the same + return Object.class; + } + + @Override + public int getColumnCount () { + // Get manager + ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); + + // Deligate this call to contact manager + return manager.getColumnCount(); + } + + @Override + public String getColumnName (final int columnIndex) { + // Get manager + ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); + + // Deligate this call to contact manager + return manager.getTranslatedColumnName(columnIndex); + } + + @Override + public int getRowCount () { + // Get manager + ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); + + try { + // Deligate this call to contact manager + return manager.size(); + } catch (final IOException ex) { + // Log warning + this.logException(ex); + + // Return zero + return 0; + } + } + + @Override + public Object getValueAt (final int rowIndex, final int columnIndex) { + // Get manager + ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); + + // Init value + Object value = null; + + try { + // Deligate this call to contact manager + value = manager.getValueFromRowColumn(rowIndex, columnIndex); + } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { + // Abort here + this.abortProgramWithException(ex); + } + + // Return it + return value; + } + + @Override + public boolean isCellEditable (final int rowIndex, final int columnIndex) { + throw new UnsupportedOperationException("Not supported yet. rowIndex=" + rowIndex + ",columnIndex=" + columnIndex); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setValueAt (final Object value, final int rowIndex, final int columnIndex) { + throw new UnsupportedOperationException("Not supported yet. value=" + value + ",rowIndex=" + rowIndex + ",columnIndex=" + columnIndex); //To change body of generated methods, choose Tools | Templates. + } +}