예제 #1
0
  private void createTabbedPane() {
    tabbedPane = new JTabbedPane();

    createTextPropertiesPanel();
    createComponentPropertiesPanel();

    tabbedPane.addTab(TLanguage.getString("TTextAreaDialog.TAB_TEXT"), textPropertiesPanel);
    tabbedPane.addTab(
        TLanguage.getString("TTextAreaDialog.TAB_PROPERTIES"), componentPropertiesPanel);
  }
예제 #2
0
 public void actionPerformed(ActionEvent evt) {
   progressBar.setValue(task.getCurrent());
   if (stop) {
     task.stop();
   }
   if (cancel) {
     task.cancel();
   }
   if (task.done()) {
     Toolkit.getDefaultToolkit().beep();
     timer.stop();
     myResults.clear();
     update(myResults);
     deleteButton.setEnabled(true);
     progressBar.setValue(progressBar.getMinimum());
     if (!cancel) {
       JOptionPane.showConfirmDialog(
           null,
           TLanguage.getString("TIGDeleteImagesDialog.DELETE_COMPLETED"),
           "",
           JOptionPane.CLOSED_OPTION,
           JOptionPane.INFORMATION_MESSAGE);
     }
     dispose();
   }
 }
예제 #3
0
  private void createIdField() {
    idFieldPanel = new JPanel();

    idFieldPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    idFieldPanel.add(new JLabel(TLanguage.getString("TTextAreaDialog.ID")));

    idTextField = new TIdTextField();
    idFieldPanel.add(idTextField);

    idTextField.setText(TBoardConstants.getId(getAttributeMap()));
  }
예제 #4
0
  private void createTextField() {
    Map map = getAttributeMap();

    textFieldPanel = new JPanel();

    textFieldPanel.setBorder(
        new TitledBorder(
            BorderFactory.createEtchedBorder(Color.WHITE, new Color(165, 163, 151)),
            TLanguage.getString("TTextAreaDialog.TEXT")));

    textField = new TTextField(TBoardConstants.getText(map));
    textField.setColumns(30);

    textFieldPanel.add(textField);
  }
예제 #5
0
  public JPanel createProgressDialog() {

    progressBar = new JProgressBar();
    progressBar.setValue(0);
    progressBar.setStringPainted(true);
    // progressBar.setIndeterminate(true);
    progressBar.setMaximum(task.getLengthOfTask());

    JPanel panel = new JPanel();
    text = new JTextField("", 20);
    text.setEditable(false);

    c = new GridBagConstraints();
    setLayout(new GridBagLayout());

    c.fill = GridBagConstraints.CENTER;
    c.insets = new Insets(5, 10, 5, 10);
    c.gridx = 0;
    c.gridy = 0;
    panel.add(text, c);

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(5, 10, 5, 10);
    c.gridx = 0;
    c.gridy = 1;
    panel.add(progressBar, c);

    contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(panel, BorderLayout.NORTH);
    // contentPane.add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    contentPane.setBorder(
        new TitledBorder(
            BorderFactory.createEtchedBorder(Color.WHITE, new Color(165, 163, 151)),
            TLanguage.getString("TIGImportDBDialog.PROGRESS")));

    // create a timer
    timer = new Timer(100, new TimerListener());

    return contentPane;
  }
예제 #6
0
public class TIGTableModel extends AbstractTableModel {

  final String[] columnNames = {
    TLanguage.getString("TIGTableModel.FIRST_COLUMN"),
    TLanguage.getString("TIGTableModel.SECOND_COLUMN")
  };

  private Vector data = new Vector();

  Class[] types = new Class[] {java.lang.String.class, java.lang.Boolean.class};

  public TIGTableModel(Vector keyWords) {

    Vector row;

    for (int i = 0; i < keyWords.size(); i++) {
      row = new Vector(2);
      row.addElement(keyWords.elementAt(i));
      row.addElement(new Boolean(false));
      data.addElement(row);
    }
  }

  /*
   * Returns the number of columns of the table
   */
  public int getColumnCount() {
    return columnNames.length;
  }

  /*
   * Returns the number of rows of the table
   */
  public int getRowCount() {
    return data.size();
  }

  /*
   * Returns the name of the column indicated
   */
  @Override
  public String getColumnName(int col) {
    return columnNames[col];
  }

  /*
   * Returns the value of the cell indicated
   */
  public Object getValueAt(int row, int col) {

    Vector myRow = new Vector(2);

    if ((row < data.size()) & (col < 2)) {
      myRow = (Vector) (data.elementAt(row));
      return myRow.elementAt(col);
    } else return null;
  }

  /*
   * JTable uses this method to determine the default renderer/
   * editor for each cell.  If we didn't implement this method,
   * then the last column would contain text ("true"/"false"),
   * rather than a check box.
   */
  @Override
  public Class getColumnClass(int c) {
    return types[c];
  }

  /*
   * Returns true if the cell is editable
   */
  @Override
  public boolean isCellEditable(int row, int col) {
    // Note that the data/cell address is constant,
    // no matter where the cell appears on screen.
    if (col != 1) return false;
    else return true;
  }

  /*
   * Sets the value of the indicated cell to value
   */
  @Override
  public void setValueAt(Object value, int row, int col) {

    if ((row < getRowCount()) & (col < 2)) {
      Vector myRow = new Vector(2);
      myRow = (Vector) data.elementAt(row);
      myRow.setElementAt(value, col);
      data.setElementAt(myRow, row);

      // Create a TableModelEvent
      TableModelEvent evento;
      evento = new TableModelEvent(this, row, row, 0, TableModelEvent.UPDATE);
      // and tell the listeners
      tellListeners(evento);
    }
  }

  /*
   * Return all the data
   */
  public Vector returnData() {
    return ((Vector) data.clone());
  }

  /*
   * Adds an element to the table but in the rigth place
   */
  public void addElement(String element) {
    Vector newRow = new Vector(2);
    if (!isElement(element)) {
      newRow.add(element);
      newRow.add(new Boolean(true));

      // Let's order the data
      int i = 0;
      boolean inserted = false;
      while ((i < data.size()) && (!inserted)) {
        if (order((String) getValueAt(i, 0)).compareTo(order(element)) > 0) {
          data.insertElementAt(newRow, i);
          inserted = true;
        } else i++;
      }
      if (!inserted) {
        data.addElement(newRow);
      }

      // Create a TableModelEvent
      TableModelEvent evento;
      evento =
          new TableModelEvent(
              this,
              this.getRowCount() - 1,
              this.getRowCount() - 1,
              TableModelEvent.ALL_COLUMNS,
              TableModelEvent.INSERT);
      // and tell the listeners
      tellListeners(evento);
    } else setValueAt(new Boolean(true), whereIsElement(element), 1);
  }

  /*
   * Returns true if the element is in the table
   */
  public boolean isElement(String word) {
    boolean is = false;
    int i = 0;
    while ((i < data.size()) && (!is)) {
      if (order(word).equals(order((String) getValueAt(i, 0)))) {
        is = true;
      } else i++;
    }
    return is;
  }

  /*
   * Returns the index of word in the table
   */
  public int whereIsElement(String word) {
    boolean is = false;
    int i = 0;
    while ((i < data.size()) && (!is)) {
      if (order(word).equals(order((String) getValueAt(i, 0)))) {
        is = true;
      } else i++;
    }
    if (is) return i;
    else return 0;
  }

  /** Deletes the row indicated */
  public void deleteKeyWord(int row) {

    // Delete the row
    data.remove(row);

    // Create a TableModelEvent
    TableModelEvent evento =
        new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE);

    // and tell the listeners
    tellListeners(evento);
  }

  /**
   * Adds a listener to the list that is notified each time a change to the data model occurs.
   *
   * @param l the TableModelListener
   */
  @Override
  public void addTableModelListener(TableModelListener l) {

    listeners.add(l);
  }

  /** Tells the listeners the event */
  private void tellListeners(TableModelEvent evento) {
    int i;

    for (i = 0; i < listeners.size(); i++)
      ((TableModelListener) listeners.get(i)).tableChanged(evento);
  }

  /** Listeners list */
  private LinkedList listeners = new LinkedList();

  public void updateTable(int row) {
    // Create a TableModelEvent
    TableModelEvent evento =
        new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE);

    // and tell the listeners
    tellListeners(evento);
  }

  private static String order(String word) {
    String result =
        word.replace(' ', '_')
            .replace(',', '-')
            .replace('á', 'a')
            .replace('é', 'e')
            .replace('í', 'i')
            .replace('ó', 'o')
            .replace('ú', 'u')
            .replace('Á', 'A')
            .replace('É', 'E')
            .replace('Í', 'I')
            .replace('Ó', 'O')
            .replace('Ú', 'U')
            .toLowerCase();
    return result;
  }
}
예제 #7
0
/**
 * Dialog to change <code>TTextAreaDialog</code> attributes.
 *
 * @author Pablo Muñoz
 * @version 1.0 Nov 20, 2006
 */
public class TTextAreaDialog extends TComponentDialog {
  private static String DEFAULT_TITLE = TLanguage.getString("TTextAreaDialog.TITLE");

  private JTabbedPane tabbedPane;

  private JPanel textPropertiesPanel;

  private JPanel textFieldPanel;

  private TTextField textField;

  private TTextAlignSelectorPanel textAlignSelectorPanel;

  private JPanel idFieldPanel;

  private TIdTextField idTextField;

  private TFontModelChooser fontModel;

  private JPanel componentPropertiesPanel;

  private TBorderSelectionPanel borderSelectionPanel;

  private TBackgroundSelectionPanel backgroundSelectionPanel;

  /**
   * Creates a new <code>TTextAreaDialog</code> to edit the <code>textArea</code> properties.
   *
   * @param boardContainer The <code>boardContainer</code> which contains the cell to be edited
   * @param textArea The <code>textArea</code> to be edited
   */
  public TTextAreaDialog(TBoardContainer boardContainer, TComponent textArea) {
    super(boardContainer, DEFAULT_TITLE, textArea);
  }

  /* (non-Javadoc)
   * @see tico.editor.dialogs.TComponentDialog#setComponentPane()
   */
  protected JPanel setComponentPane(TEditor editor) {
    JPanel componentPane = new JPanel();

    GridBagConstraints c = new GridBagConstraints();

    componentPane.setLayout(new GridBagLayout());

    createIdField();
    createTabbedPane();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 10, 0, 10);
    c.gridx = 0;
    c.gridy = 0;
    componentPane.add(idFieldPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(0, 5, 5, 5);
    c.gridx = 0;
    c.gridy = 1;
    componentPane.add(tabbedPane, c);

    return componentPane;
  }

  private void createIdField() {
    idFieldPanel = new JPanel();

    idFieldPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    idFieldPanel.add(new JLabel(TLanguage.getString("TTextAreaDialog.ID")));

    idTextField = new TIdTextField();
    idFieldPanel.add(idTextField);

    idTextField.setText(TBoardConstants.getId(getAttributeMap()));
  }

  private void createTabbedPane() {
    tabbedPane = new JTabbedPane();

    createTextPropertiesPanel();
    createComponentPropertiesPanel();

    tabbedPane.addTab(TLanguage.getString("TTextAreaDialog.TAB_TEXT"), textPropertiesPanel);
    tabbedPane.addTab(
        TLanguage.getString("TTextAreaDialog.TAB_PROPERTIES"), componentPropertiesPanel);
  }

  private void createTextPropertiesPanel() {
    textPropertiesPanel = new JPanel();

    GridBagConstraints c = new GridBagConstraints();

    textPropertiesPanel.setLayout(new GridBagLayout());

    createTextField();
    createTextAlignSelector();
    createFontModel();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 10, 0, 10);
    c.gridx = 0;
    c.gridy = 0;
    textPropertiesPanel.add(textFieldPanel, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 10, 0, 10);
    c.gridx = 0;
    c.gridy = 1;
    textPropertiesPanel.add(textAlignSelectorPanel, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 2;
    textPropertiesPanel.add(fontModel, c);
  }

  private void createComponentPropertiesPanel() {
    componentPropertiesPanel = new JPanel();

    GridBagConstraints c = new GridBagConstraints();

    componentPropertiesPanel.setLayout(new GridBagLayout());

    createBorderSelectionPanel();
    createBackgroundSelectionPanel();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 10, 0, 10);
    c.gridx = 0;
    c.gridy = 0;
    componentPropertiesPanel.add(borderSelectionPanel, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 1;
    componentPropertiesPanel.add(backgroundSelectionPanel, c);
  }

  private void createTextAlignSelector() {
    Map map = getAttributeMap();

    textAlignSelectorPanel = new TTextAlignSelectorPanel();

    textAlignSelectorPanel.setHorizontalAlignment(TBoardConstants.getHorizontalAlignment(map));
    textAlignSelectorPanel.setVerticalAlignment(TBoardConstants.getVerticalAlignment(map));
  }

  private void createTextField() {
    Map map = getAttributeMap();

    textFieldPanel = new JPanel();

    textFieldPanel.setBorder(
        new TitledBorder(
            BorderFactory.createEtchedBorder(Color.WHITE, new Color(165, 163, 151)),
            TLanguage.getString("TTextAreaDialog.TEXT")));

    textField = new TTextField(TBoardConstants.getText(map));
    textField.setColumns(30);

    textFieldPanel.add(textField);
  }

  private void createFontModel() {
    Map map = getAttributeMap();

    fontModel =
        new TFontModelChooser(
            TBoardConstants.getFont(map).getName(),
            TBoardConstants.getForeground(map),
            TBoardConstants.getFont(map).getSize(),
            TBoardConstants.getFont(map).getStyle());
  }

  private void createBorderSelectionPanel() {
    Map map = getAttributeMap();

    borderSelectionPanel = new TBorderSelectionPanel();

    borderSelectionPanel.setBorderColor(TBoardConstants.getBorderColor(map));
    borderSelectionPanel.setBorderSize(Math.max(1, Math.round(TBoardConstants.getLineWidth(map))));
  }

  private void createBackgroundSelectionPanel() {
    Map map = getAttributeMap();

    backgroundSelectionPanel = new TBackgroundSelectionPanel();

    backgroundSelectionPanel.setBackgroundColor(TBoardConstants.getBackground(map));
    backgroundSelectionPanel.setGradientColor(TBoardConstants.getGradientColor(map));
  }

  /* (non-Javadoc)
   * @see tico.editor.dialogs.TComponentDialog#newComponentsAttributeMap()
   */
  protected Map newComponentsAttributeMap() {
    Map nested = new Hashtable();
    Map attributeMap = new Hashtable();
    Vector removalAttributes = new Vector();

    TBoardConstants.setText(attributeMap, textField.getText());

    TBoardConstants.setForeground(attributeMap, fontModel.getFontColor());
    TBoardConstants.setFont(
        attributeMap,
        new Font(fontModel.getFontFace(), fontModel.getFontStyle(), fontModel.getFontSize()));

    TBoardConstants.setHorizontalAlignment(
        attributeMap, textAlignSelectorPanel.getHorizontalAlignment());
    TBoardConstants.setVerticalAlignment(
        attributeMap, textAlignSelectorPanel.getVerticalAlignment());

    Color color = borderSelectionPanel.getBorderColor();
    if (color != null) TBoardConstants.setBorderColor(attributeMap, color);
    else removalAttributes.add(TBoardConstants.BORDERCOLOR);

    TBoardConstants.setLineWidth(attributeMap, borderSelectionPanel.getBorderSize());

    Color background = backgroundSelectionPanel.getBackgroundColor();
    if (background != null) TBoardConstants.setBackground(attributeMap, background);
    else removalAttributes.add(TBoardConstants.BACKGROUND);

    Color gradient = backgroundSelectionPanel.getGradientColor();
    if (gradient != null) TBoardConstants.setGradientColor(attributeMap, gradient);
    else removalAttributes.add(TBoardConstants.GRADIENTCOLOR);

    TBoardConstants.setRemoveAttributes(attributeMap, removalAttributes.toArray());

    TBoardConstants.setId(attributeMap, idTextField.getText());

    nested.put(getComponent(), attributeMap);

    return nested;
  }
}
예제 #8
0
  public TIGDeleteImagesDialog(TEditor editor, TIGDataBase dataBase) {
    super(editor, true);
    myEditor = editor;
    this.myDataBase = dataBase;

    TIGDataBase.conectDB();

    addWindowListener(
        new java.awt.event.WindowListener() {
          public void windowClosing(java.awt.event.WindowEvent e) {
            if (task.isRunning()) {
              stop = true;
              cancel = true;
              JOptionPane.showConfirmDialog(
                  null,
                  TLanguage.getString("TIGOperationDB.CANCELED"),
                  "",
                  JOptionPane.CLOSED_OPTION,
                  JOptionPane.INFORMATION_MESSAGE);
            }
            dispose();
          }

          public void windowActivated(java.awt.event.WindowEvent e) {}

          public void windowDeactivated(java.awt.event.WindowEvent e) {}

          public void windowDeiconified(java.awt.event.WindowEvent e) {}

          public void windowIconified(java.awt.event.WindowEvent e) {}

          public void windowOpened(java.awt.event.WindowEvent e) {}

          public void windowClosed(java.awt.event.WindowEvent e) {}
        });

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(TLanguage.getString("TEditorMenuBar.IMAGES_DELETE"));

    // Create components

    // All the images in the dataBase are shown
    // when the window is displayed

    images = TIGDataBase.imageSearchByName("*");
    myResults = null;

    // First, create the component that shows all the images
    thumbnailsPanel = new JPanel();
    thumbnailsDialog = new TIGThumbnails(true);
    // Create thumbnails panel with no selection of images
    thumbnailsPanel = thumbnailsDialog.createThumbnailsPanel(images, false);

    // Second, create the component that search the names of the images
    // JPanel searchNamePanel = new JPanel();
    TIGSearchName searchNamePanel = new TIGSearchName(thumbnailsDialog, this);
    // searchNamePanel = searchNameDialog.createSearchNamePanelDelete(this);

    // Third, create the component that search the images from its associations
    TIGSearchKeyWord keyWordSearchPanel = new TIGSearchKeyWord(thumbnailsDialog, this);
    // TIGSearchKeyWord keyWordSearchDialog = new TIGSearchKeyWord(this.myEditor,this.myDataBase);

    // Fourth, create three buttons, the first one to modify the image, the second one to
    // delete it, and the last one to exit the window
    JPanel buttons = new JPanel();

    // Fifth, create the progressBar dialog
    task = new TIGDeleteTask();
    contentPane = createProgressDialog();

    deleteButton =
        new TButton(
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {

                File directory;
                File[] directoryFiles;

                imagePath = thumbnailsDialog.pathImageSelected();

                if (myResults == null) {
                  JOptionPane.showConfirmDialog(
                      null,
                      TLanguage.getString("TIGSearchImageDialog.MESSAGE_NO_SEARCH"),
                      TLanguage.getString("TIGSearchImageDialog.DELETE_ALL"),
                      JOptionPane.CLOSED_OPTION,
                      JOptionPane.WARNING_MESSAGE);
                } else if (myResults.size() == 0) {
                  JOptionPane.showConfirmDialog(
                      null,
                      TLanguage.getString("TIGSearchImageDialog.MESSAGE_NO_IMAGES_FOUND"),
                      TLanguage.getString("TIGSearchImageDialog.DELETE_ALL"),
                      JOptionPane.CLOSED_OPTION,
                      JOptionPane.WARNING_MESSAGE);
                } else {
                  int choosenOption =
                      JOptionPane.showConfirmDialog(
                          null,
                          TLanguage.getString("TIGSearchImageDialog.DELETE_MESSAGE")
                              + " "
                              + myResults.size()
                              + " "
                              + TLanguage.getString("TIGSearchImageDialog.ENSURE_DELETE"),
                          TLanguage.getString("TIGSearchImageDialog.DELETE_ALL"),
                          JOptionPane.YES_NO_CANCEL_OPTION);
                  if (choosenOption == JOptionPane.YES_OPTION) {

                    text.setText(TLanguage.getString("TIGImportDBDialog.PROGRESS_TASK"));
                    deleteButton.setEnabled(false);
                    progressBar.setIndeterminate(false);

                    progressBar.setMaximum(myResults.size());
                    progressBar.setValue(0);

                    task.go(myEditor, myDataBase, myResults);
                    timer.start();
                  }
                }
              }
            });
    deleteButton.setText(TLanguage.getString("TIGSearchImageDialog.DELETE_ALL"));

    TButton cancelButton =
        new TButton(
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                stop = true;
                cancel = true;
                JOptionPane.showConfirmDialog(
                    null,
                    TLanguage.getString("TIGOperationDB.CANCELED"),
                    "",
                    JOptionPane.CLOSED_OPTION,
                    JOptionPane.INFORMATION_MESSAGE);
                dispose();
              }
            });
    cancelButton.setText(TLanguage.getString("TIGSearchImageDialog.CANCEL"));

    ButtonGroup actionGroup = new ButtonGroup();

    actionGroup.add(deleteButton);
    actionGroup.add(cancelButton);

    // Place buttons
    GridBagConstraints but = new GridBagConstraints();
    buttons.setLayout(new GridBagLayout());

    but.fill = GridBagConstraints.BOTH;
    but.insets = new Insets(10, 10, 10, 10);
    but.gridx = 0;
    but.gridy = 0;
    buttons.add(deleteButton, but);

    but.fill = GridBagConstraints.BOTH;
    but.insets = new Insets(10, 10, 10, 10);
    but.gridx = 2;
    but.gridy = 0;
    buttons.add(cancelButton, but);

    // Place components
    getContentPane().setLayout(new GridBagLayout());

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 0;
    getContentPane().add(keyWordSearchPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 1;
    getContentPane().add(searchNamePanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 2;
    getContentPane().add(thumbnailsPanel, c);

    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(10, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 3;
    getContentPane().add(buttons, c);

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridx = 0;
    c.gridy = 4;
    getContentPane().add(contentPane, c);

    // Display the dialog
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    setResizable(false);
    pack();

    setLocationRelativeTo(editor);
    setVisible(true);
  }
예제 #9
0
 /**
  * Constructor of the TAdjustVerticalGapAction.
  *
  * @param editor The boards' editor
  */
 public TAdjustVerticalGapAction(TEditor editor) {
   super(
       editor,
       TLanguage.getString("TAdjustVerticalGapAction.NAME"),
       TResourceManager.getImageIcon("align-vertical-gap-22.png"));
 }