|
|
@ -1,12 +1,10 @@ |
|
|
|
package ru.egspt; |
|
|
|
package ru.egspt; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JFrame; |
|
|
|
|
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JTextArea; |
|
|
|
import javax.swing.JTextArea; |
|
|
|
import javax.swing.JTextField; |
|
|
|
import javax.swing.JTextField; |
|
|
|
import javax.swing.WindowConstants; |
|
|
|
|
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
import javax.swing.border.TitledBorder; |
|
|
|
import javax.swing.border.TitledBorder; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
@ -17,36 +15,18 @@ public class TagPane extends JPanel{ |
|
|
|
private JButton addTagButton = new JButton("Добавить"); |
|
|
|
private JButton addTagButton = new JButton("Добавить"); |
|
|
|
private JButton removeTagButton = new JButton("Удалить"); |
|
|
|
private JButton removeTagButton = new JButton("Удалить"); |
|
|
|
private JTextArea tagArea = new JTextArea(); |
|
|
|
private JTextArea tagArea = new JTextArea(); |
|
|
|
public TagPane(Base base, TagModel tm){ |
|
|
|
public TagPane(App app){ |
|
|
|
this.add(newTagLabel); |
|
|
|
this.add(newTagLabel); |
|
|
|
this.add(CurrentTagField); |
|
|
|
this.add(CurrentTagField); |
|
|
|
this.add(addTagButton); |
|
|
|
this.add(addTagButton); |
|
|
|
addTagButton.addActionListener(e -> TagControls.addTag(base, tm, this)); |
|
|
|
addTagButton.addActionListener(e -> TagControls.addTag(app)); |
|
|
|
this.add(removeTagButton); |
|
|
|
this.add(removeTagButton); |
|
|
|
removeTagButton.addActionListener(e -> TagControls.removeTag(tm, this)); |
|
|
|
removeTagButton.addActionListener(e -> TagControls.removeTag(app)); |
|
|
|
//заполняем tagArea
|
|
|
|
//заполняем tagArea
|
|
|
|
tagArea.setText("Перечень тегов:"); |
|
|
|
tagArea.setText("Перечень тегов:"); |
|
|
|
int i = 0; |
|
|
|
int i = 0; |
|
|
|
while (i < tm.getTags().size()){ |
|
|
|
while (i < app.getTagModel().getTags().size()){ |
|
|
|
tagArea.append(tm.getTags().get(i)); |
|
|
|
tagArea.append(app.getTagModel().getTags().get(i)); |
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.add(tagArea); |
|
|
|
|
|
|
|
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "tag-controls", TitledBorder.CENTER, TitledBorder.CENTER); |
|
|
|
|
|
|
|
this.setBorder(border); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public TagPane(TagModel tm){ |
|
|
|
|
|
|
|
this.add(newTagLabel); |
|
|
|
|
|
|
|
this.add(CurrentTagField); |
|
|
|
|
|
|
|
this.add(addTagButton); |
|
|
|
|
|
|
|
addTagButton.addActionListener(e -> TagControls.addTag(tm, this)); |
|
|
|
|
|
|
|
this.add(removeTagButton); |
|
|
|
|
|
|
|
removeTagButton.addActionListener(e -> TagControls.removeTag(tm, this)); |
|
|
|
|
|
|
|
//заполняем tagArea
|
|
|
|
|
|
|
|
tagArea.setText("Перечень тегов:"); |
|
|
|
|
|
|
|
int i = 0; |
|
|
|
|
|
|
|
while (i < tm.getTags().size()){ |
|
|
|
|
|
|
|
tagArea.append(tm.getTags().get(i)); |
|
|
|
|
|
|
|
i++; |
|
|
|
i++; |
|
|
|
} |
|
|
|
} |
|
|
|
this.add(tagArea); |
|
|
|
this.add(tagArea); |
|
|
@ -80,16 +60,4 @@ public class TagPane extends JPanel{ |
|
|
|
public JTextField getCurrentTagField() { |
|
|
|
public JTextField getCurrentTagField() { |
|
|
|
return CurrentTagField; |
|
|
|
return CurrentTagField; |
|
|
|
} |
|
|
|
} |
|
|
|
public static void main( String[] args ){ |
|
|
|
|
|
|
|
//Base base = new Base();
|
|
|
|
|
|
|
|
//Data data;
|
|
|
|
|
|
|
|
TagModel tm = new TagModel(); |
|
|
|
|
|
|
|
System.out.println( "Проверка работоспособности класса TagPane ..." ); |
|
|
|
|
|
|
|
JFrame mainframe = new JFrame("TagPane-test"); |
|
|
|
|
|
|
|
TagPane tp = new TagPane(tm); |
|
|
|
|
|
|
|
mainframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|
|
|
|
|
|
|
mainframe.add(tp); |
|
|
|
|
|
|
|
mainframe.setSize(320, 240); |
|
|
|
|
|
|
|
mainframe.setVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|