Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: MrHant/Zanti
base: 7178a899c2
...
head fork: MrHant/Zanti
compare: ad0388fe35
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
8 src/ru/icerow/zanti/Document.java
@@ -10,18 +10,10 @@
private String author;
private String description;
- public Document(String name, String author) {
- this(-1, name, author, "");
- }
-
public Document(String name, String author, String description) {
this(-1, name, author, description);
}
- public Document(int id, String name, String author) {
- this(id, name, author, "");
- }
-
public Document(int id, String name, String author, String description) {
this.id = id;
this.name = name;
View
131 src/ru/icerow/zanti/DocumentsListUI.form
@@ -3,6 +3,7 @@
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
+ <Property name="title" type="java.lang.String" value="&#x421;&#x438;&#x441;&#x442;&#x435;&#x43c;&#x430; &#x43e;&#x440;&#x433;&#x430;&#x43d;&#x438;&#x437;&#x430;&#x446;&#x438;&#x438; &#x438; &#x43f;&#x43e;&#x440;&#x44f;&#x434;&#x43a;&#x430; &#x432;&#x44b;&#x43f;&#x43e;&#x43b;&#x43d;&#x435;&#x43d;&#x438;&#x44f; &#x43d;&#x430;&#x443;&#x447;&#x43d;&#x43e;-&#x438;&#x441;&#x441;&#x43b;&#x435;&#x434;&#x43e;&#x432;&#x430;&#x442;&#x435;&#x43b;&#x44c;&#x441;&#x43a;&#x438;&#x445; &#x440;&#x430;&#x431;&#x43e;&#x442;"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
@@ -22,18 +23,47 @@
<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="jScrollPane1" pref="380" max="32767" attributes="0"/>
+ <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jScrollPane3" max="32767" attributes="0"/>
+ <Component id="jScrollPane1" alignment="1" max="32767" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
+ <Component id="jButtonExit" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" attributes="0">
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
</Group>
+ <Component id="jToolBar2" alignment="0" pref="510" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
+ <Component id="jToolBar2" min="-2" pref="25" max="-2" attributes="0"/>
+ <EmptySpace pref="24" max="32767" attributes="0"/>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jScrollPane1" min="-2" pref="223" max="-2" attributes="0"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jScrollPane3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
- <Component id="jScrollPane1" pref="278" max="32767" attributes="0"/>
+ <Component id="jButtonExit" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@@ -53,6 +83,99 @@
<StringArray count="0"/>
</Property>
</Properties>
+ <Events>
+ <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="jListDocumentsValueChanged"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="jButtonExit">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="&#x412;&#x44b;&#x445;&#x43e;&#x434;"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonExitActionPerformed"/>
+ </Events>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane3">
+ <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.JTextArea" name="jTextAreaDescription">
+ <Properties>
+ <Property name="columns" type="int" value="20"/>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="rows" type="int" value="5"/>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder/>
+ </Border>
+ </Property>
+ <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
+ <Color id="Default Cursor"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="&#x421;&#x43f;&#x438;&#x441;&#x43e;&#x43a; &#x43d;&#x430;&#x443;&#x447;&#x43d;&#x43e;-&#x438;&#x441;&#x441;&#x43b;&#x435;&#x434;&#x43e;&#x432;&#x430;&#x442;&#x435;&#x43b;&#x44c;&#x441;&#x43a;&#x438;&#x445; &#x440;&#x430;&#x431;&#x43e;&#x442;:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel2">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="&#x41e;&#x43f;&#x438;&#x441;&#x430;&#x43d;&#x438;&#x435; &#x432;&#x44b;&#x431;&#x440;&#x430;&#x43d;&#x43d;&#x43e;&#x439; &#x440;&#x430;&#x431;&#x43e;&#x442;&#x44b;:"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JToolBar" name="jToolBar2">
+ <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>
+ <Property name="floatable" type="boolean" value="false"/>
+ <Property name="rollover" type="boolean" value="true"/>
+ </Properties>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel3">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="&#x41e;&#x442;&#x43e;&#x431;&#x440;&#x430;&#x436;&#x430;&#x442;&#x44c; &#x432; &#x441;&#x43f;&#x438;&#x441;&#x43a;&#x435;:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JToggleButton" name="jToggleId">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="&#x41f;&#x43e;&#x440;&#x44f;&#x434;&#x43a;&#x43e;&#x432;&#x44b;&#x439; &#x43d;&#x43e;&#x43c;&#x435;&#x440; "/>
+ <Property name="focusable" type="boolean" value="false"/>
+ <Property name="horizontalTextPosition" type="int" value="0"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[2, 20, 2, 20]"/>
+ </Property>
+ <Property name="verticalTextPosition" type="int" value="3"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jToggleIdActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JToggleButton" name="jToggleAuthor">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="&#x410;&#x432;&#x442;&#x43e;&#x440;"/>
+ <Property name="focusable" type="boolean" value="false"/>
+ <Property name="horizontalTextPosition" type="int" value="0"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[2, 20, 2, 20]"/>
+ </Property>
+ <Property name="verticalTextPosition" type="int" value="3"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jToggleAuthorActionPerformed"/>
+ </Events>
</Component>
</SubComponents>
</Container>
View
182 src/ru/icerow/zanti/DocumentsListUI.java
@@ -2,7 +2,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Vector;
import javax.swing.JOptionPane;
import ru.icerow.zanti.db.ZantiDao;
@@ -12,20 +11,26 @@
*/
public class DocumentsListUI extends javax.swing.JFrame {
+ private boolean showId = false;
+ private boolean showAuthor = true;
+ private ZantiDao dao;
+ private List<Document> documentsList;
+
/**
* Creates new form DocumentsListUI
*/
public DocumentsListUI() {
initComponents();
- ZantiDao dao = new ZantiDao();
+ // Connect to DB
+ dao = new ZantiDao();
dao.connect();
- List<Document> list = dao.getListEntries();
- List<String> listItems = new ArrayList<>();
- for (Document d : list) {
- listItems.add(d.getId() + " - " + d.getName() + " - " + d.getAuthor());
- }
- jListDocuments.setListData(listItems.toArray());
+
+ // Get documents list from DB
+ getList();
+
+ // Fill in documents list
+ refreshList();
}
/**
@@ -39,31 +44,141 @@ private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jListDocuments = new javax.swing.JList();
+ jButtonExit = new javax.swing.JButton();
+ jScrollPane3 = new javax.swing.JScrollPane();
+ jTextAreaDescription = new javax.swing.JTextArea();
+ jLabel1 = new javax.swing.JLabel();
+ jLabel2 = new javax.swing.JLabel();
+ jToolBar2 = new javax.swing.JToolBar();
+ jLabel3 = new javax.swing.JLabel();
+ jToggleId = new javax.swing.JToggleButton();
+ jToggleAuthor = new javax.swing.JToggleButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("Система организации и порядка выполнения научно-исследовательских работ");
+ jListDocuments.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
+ public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
+ jListDocumentsValueChanged(evt);
+ }
+ });
jScrollPane1.setViewportView(jListDocuments);
+ jButtonExit.setText("Выход");
+ jButtonExit.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButtonExitActionPerformed(evt);
+ }
+ });
+
+ jTextAreaDescription.setColumns(20);
+ jTextAreaDescription.setEditable(false);
+ jTextAreaDescription.setRows(5);
+ jTextAreaDescription.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+ jTextAreaDescription.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
+ jScrollPane3.setViewportView(jTextAreaDescription);
+
+ jLabel1.setText("Список научно-исследовательских работ:");
+
+ jLabel2.setText("Описание выбранной работы:");
+
+ jToolBar2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
+ jToolBar2.setFloatable(false);
+ jToolBar2.setRollover(true);
+
+ jLabel3.setText("Отображать в списке:");
+ jToolBar2.add(jLabel3);
+
+ jToggleId.setText("Порядковый номер ");
+ jToggleId.setFocusable(false);
+ jToggleId.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ jToggleId.setMargin(new java.awt.Insets(2, 20, 2, 20));
+ jToggleId.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+ jToggleId.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jToggleIdActionPerformed(evt);
+ }
+ });
+ jToolBar2.add(jToggleId);
+
+ jToggleAuthor.setText("Автор");
+ jToggleAuthor.setFocusable(false);
+ jToggleAuthor.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ jToggleAuthor.setMargin(new java.awt.Insets(2, 20, 2, 20));
+ jToggleAuthor.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+ jToggleAuthor.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jToggleAuthorActionPerformed(evt);
+ }
+ });
+ jToolBar2.add(jToggleAuthor);
+
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(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
- .addContainerGap())
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jScrollPane3)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addGap(0, 0, Short.MAX_VALUE)
+ .addComponent(jButtonExit))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel1)
+ .addGap(0, 0, Short.MAX_VALUE)))
+ .addContainerGap())
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel2)
+ .addContainerGap())))
+ .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 510, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
+ .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
+ .addComponent(jLabel1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(jLabel2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButtonExit)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
+ private void jButtonExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExitActionPerformed
+ System.exit(0);
+ }//GEN-LAST:event_jButtonExitActionPerformed
+
+ private void jToggleIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleIdActionPerformed
+ showId = jToggleId.isSelected();
+ refreshList();
+ }//GEN-LAST:event_jToggleIdActionPerformed
+
+ private void jToggleAuthorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleAuthorActionPerformed
+ showAuthor = jToggleAuthor.isSelected();
+ refreshList();
+ }//GEN-LAST:event_jToggleAuthorActionPerformed
+
+ private void jListDocumentsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListDocumentsValueChanged
+ int index = jListDocuments.getSelectedIndex();
+ if (index!=-1) {
+ jTextAreaDescription.setText(documentsList.get(index).getDescription());
+ } else {
+ jTextAreaDescription.setText("");
+ }
+ }//GEN-LAST:event_jListDocumentsValueChanged
+
/**
* @param args the command line arguments
*/
@@ -106,7 +221,50 @@ public void run() {
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton jButtonExit;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
private javax.swing.JList jListDocuments;
private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JScrollPane jScrollPane3;
+ private javax.swing.JTextArea jTextAreaDescription;
+ private javax.swing.JToggleButton jToggleAuthor;
+ private javax.swing.JToggleButton jToggleId;
+ private javax.swing.JToolBar jToolBar2;
// End of variables declaration//GEN-END:variables
+
+ private void toggleStates() {
+ jToggleId.setSelected(showId);
+ jToggleAuthor.setSelected(showAuthor);
+ }
+
+ private void refreshList() {
+ // Remember selection of list
+ int selection = jListDocuments.getSelectedIndex();
+
+ // Toogle button states
+ this.toggleStates();
+
+ // Show list of documents
+ List<String> listItems = new ArrayList<>();
+ String listItem;
+ for (Document d : documentsList) {
+ listItem = "";
+ if (showId) {
+ listItem += d.getId() + " - ";
+ }
+ listItem += d.getName();
+ if (showAuthor) {
+ listItem += " - " + d.getAuthor();
+ }
+ listItems.add(listItem);
+ }
+ jListDocuments.setListData(listItems.toArray());
+ jListDocuments.setSelectedIndex(selection);
+ }
+
+ private void getList() {
+ documentsList = dao.getListEntries();
+ }
}
View
5 src/ru/icerow/zanti/db/ZantiDao.java
@@ -32,7 +32,7 @@
")";
private static final String strGetListDocuments =
- "SELECT ID, NAME, AUTHOR FROM APP.DOCUMENTS " +
+ "SELECT ID, NAME, AUTHOR, DESCRIPTION FROM APP.DOCUMENTS " +
"ORDER BY NAME ASC";
private static final String strAddDocument =
@@ -196,8 +196,9 @@ public int addDocument(Document document) {
int id = results.getInt(1);
String name = results.getString(2);
String author = results.getString(3);
+ String description = results.getString(4);
- Document entry = new Document(id, name, author);
+ Document entry = new Document(id, name, author, description);
listEntries.add(entry);
}

No commit comments for this range

Something went wrong with that request. Please try again.