diff --git a/iped-app/resources/localization/iped-desktop-messages.properties b/iped-app/resources/localization/iped-desktop-messages.properties index 67accf6540..a5a2b5ebb4 100644 --- a/iped-app/resources/localization/iped-desktop-messages.properties +++ b/iped-app/resources/localization/iped-desktop-messages.properties @@ -55,6 +55,11 @@ BookmarksManager.ConfirmDelTitle=Confirm BookmarksManager.Dataset=Dataset: BookmarksManager.Delete=Delete BookmarksManager.Delete.Tip=Delete selected bookmarks +BookmarksManager.Edit=Edit +BookmarksManager.Edit.Color=Color +BookmarksManager.Edit.Name=Name +BookmarksManager.Edit.Tip=Edit selected bookmark name and color +BookmarksManager.Edit.Title=Edit Bookmark BookmarksManager.Highlighted=Highlighted items BookmarksManager.KeyStrokeBookmark=Type a key (combination) to define a shortcut to 'Add'.
ALT+key always 'Remove'. BookmarksManager.KeyStrokeAlert1=Select just one bookmark to define key shortcut. @@ -65,10 +70,8 @@ BookmarksManager.LoadingHashes=Loading Hashes... BookmarksManager.New=New BookmarksManager.New.Tip=New bookmark BookmarksManager.NewBookmark.Tip=Enter bookmark name -BookmarksManager.NewName=New name to first selected bookmark BookmarksManager.Remove=Remove BookmarksManager.Remove.Tip=Remove items from selected bookmarks -BookmarksManager.Rename=Rename BookmarksManager.SearchingDuplicates=Searching Duplicates... BookmarksManager.Title=Bookmarks BookmarksManager.CommentsTooltip=Bookmark comments diff --git a/iped-app/resources/localization/iped-desktop-messages_de_DE.properties b/iped-app/resources/localization/iped-desktop-messages_de_DE.properties index fa268b08b6..d0e5d9f3b4 100644 --- a/iped-app/resources/localization/iped-desktop-messages_de_DE.properties +++ b/iped-app/resources/localization/iped-desktop-messages_de_DE.properties @@ -55,6 +55,11 @@ BookmarksManager.ConfirmDelTitle=Bestätigung BookmarksManager.Dataset=Datensatz: BookmarksManager.Delete=Löschen BookmarksManager.Delete.Tip=lösche markierte Lesezeichen +BookmarksManager.Edit=Edit[TBT] +BookmarksManager.Edit.Color=Color[TBT] +BookmarksManager.Edit.Name=Name[TBT] +BookmarksManager.Edit.Tip=Edit selected bookmark name and color[TBT] +BookmarksManager.Edit.Title=Edit Bookmark[TBT] BookmarksManager.Highlighted=markierte Objekte BookmarksManager.KeyStrokeBookmark=Drücke eine Taste(nkombination) um einen Kurzbefehl für das Hinzufügen zu erstellen.
Alt+key bedeutet 'Entfernen'. BookmarksManager.KeyStrokeAlert1=Bitte ein Lesezeichen wählen um einen Kurzbefehl zu definieren. @@ -65,10 +70,8 @@ BookmarksManager.LoadingHashes=Lade Hashes... BookmarksManager.New=Neu BookmarksManager.New.Tip=Neues Lesezeichen BookmarksManager.NewBookmark.Tip=Name für Lesezeichen eingeben -BookmarksManager.NewName=Neue Bezeichnung für erstes ausgewähltes Lesezeichen BookmarksManager.Remove=Entfernen BookmarksManager.Remove.Tip=Entferne Objekte von ausgewähltem Lesezeichen -BookmarksManager.Rename=Umbenennen BookmarksManager.SearchingDuplicates=Suche Duplikate... BookmarksManager.Title=Lesezeichen BookmarksManager.CommentsTooltip=Kommentare zu Lesezeichen diff --git a/iped-app/resources/localization/iped-desktop-messages_es_AR.properties b/iped-app/resources/localization/iped-desktop-messages_es_AR.properties index cbfc91cdf0..e4ce751d51 100644 --- a/iped-app/resources/localization/iped-desktop-messages_es_AR.properties +++ b/iped-app/resources/localization/iped-desktop-messages_es_AR.properties @@ -55,6 +55,11 @@ BookmarksManager.ConfirmDelTitle=Confirmar BookmarksManager.Dataset=Conjunto de datos: BookmarksManager.Delete=Eliminar BookmarksManager.Delete.Tip=Eliminar marcadores seleccionados +BookmarksManager.Edit=Edit[TBT] +BookmarksManager.Edit.Color=Color[TBT] +BookmarksManager.Edit.Name=Name[TBT] +BookmarksManager.Edit.Tip=Edit selected bookmark name and color[TBT] +BookmarksManager.Edit.Title=Edit Bookmark[TBT] BookmarksManager.Highlighted=Elementos resaltados BookmarksManager.KeyStrokeBookmark=Escriba (o combine) teclas para establecer un atajo para 'Añadir'.
Alt+tecla siempre activa 'Eliminar'. BookmarksManager.KeyStrokeAlert1=Seleccione solo 1 marcador para definir el atajo de teclas. @@ -65,10 +70,8 @@ BookmarksManager.LoadingHashes=Cargando hashes... BookmarksManager.New=Nuevo BookmarksManager.New.Tip=Nuevo marcador BookmarksManager.NewBookmark.Tip=Ingrese el nombre del marcador -BookmarksManager.NewName=Nuevo nombre para el primer marcador seleccionado BookmarksManager.Remove=Eliminar BookmarksManager.Remove.Tip=Eliminar elementos de los marcadores seleccionados -BookmarksManager.Rename=Renombrar BookmarksManager.SearchingDuplicates=Buscando duplicados... BookmarksManager.Title=Marcadores BookmarksManager.CommentsTooltip=Marcar comentarios diff --git a/iped-app/resources/localization/iped-desktop-messages_it_IT.properties b/iped-app/resources/localization/iped-desktop-messages_it_IT.properties index df53ee5ca8..8aff274679 100644 --- a/iped-app/resources/localization/iped-desktop-messages_it_IT.properties +++ b/iped-app/resources/localization/iped-desktop-messages_it_IT.properties @@ -55,6 +55,11 @@ BookmarksManager.ConfirmDelTitle=Conferma BookmarksManager.Dataset=Set di dati: BookmarksManager.Delete=Elimina BookmarksManager.Delete.Tip=Elimina i segnalibri selezionati +BookmarksManager.Edit=Edit[TBT] +BookmarksManager.Edit.Color=Color[TBT] +BookmarksManager.Edit.Name=Name[TBT] +BookmarksManager.Edit.Tip=Edit selected bookmark name and color[TBT] +BookmarksManager.Edit.Title=Edit Bookmark[TBT] BookmarksManager.Highlighted=Elementi evidenziati BookmarksManager.KeyStrokeBookmark=Digita un tasto (combinazione) per definire una scorciatoia per 'Aggiungi'.
Alt+key 'Rimuovi' sempre. BookmarksManager.KeyStrokeAlert1=Seleziona solo un segnalibro per definire una scorciatoia. @@ -65,10 +70,8 @@ BookmarksManager.LoadingHashes=Caricamento Hash... BookmarksManager.New=Nuovo BookmarksManager.New.Tip=Nuovo segnalibro BookmarksManager.NewBookmark.Tip=Inserisci il nome del segnalibro -BookmarksManager.NewName=Nuovo nome al primo segnalibro selezionato BookmarksManager.Remove=Rimuovi BookmarksManager.Remove.Tip=Rimuovi elementi dai segnalibri selezionati -BookmarksManager.Rename=Rinomina BookmarksManager.SearchingDuplicates=Trova duplicati... BookmarksManager.Title=Segnalibri BookmarksManager.CommentsTooltip=Commenti ai segnalibri diff --git a/iped-app/resources/localization/iped-desktop-messages_pt_BR.properties b/iped-app/resources/localization/iped-desktop-messages_pt_BR.properties index 57490b02a9..ad4103e644 100644 --- a/iped-app/resources/localization/iped-desktop-messages_pt_BR.properties +++ b/iped-app/resources/localization/iped-desktop-messages_pt_BR.properties @@ -55,6 +55,11 @@ BookmarksManager.ConfirmDelTitle=Confirmar BookmarksManager.Dataset=Conjunto de dados: BookmarksManager.Delete=Apagar BookmarksManager.Delete.Tip=Apagar marcadores selecionados +BookmarksManager.Edit=Editar +BookmarksManager.Edit.Color=Cor +BookmarksManager.Edit.Name=Nome +BookmarksManager.Edit.Tip=Editar nome e cor do marcador selecionado +BookmarksManager.Edit.Title=Editar Marcador BookmarksManager.Highlighted=Itens Destacados BookmarksManager.KeyStrokeBookmark=Digite (ou combine) teclas para definir atalho p/ 'Adicionar'.
ALT+tecla sempre aciona 'Remover'. BookmarksManager.KeyStrokeAlert1=Selecione apenas um marcador para definir a tecla de atalho. @@ -65,10 +70,8 @@ BookmarksManager.LoadingHashes=Obtendo hashes... BookmarksManager.New=Criar novo BookmarksManager.New.Tip=Novo marcador BookmarksManager.NewBookmark.Tip=Novo marcador -BookmarksManager.NewName=Novo nome para o primeiro marcador selecionado BookmarksManager.Remove=Remover BookmarksManager.Remove.Tip=Remover itens dos marcadores selecionados -BookmarksManager.Rename=Renomear BookmarksManager.SearchingDuplicates=Pesquisando duplicatas... BookmarksManager.Title=Marcadores BookmarksManager.CommentsTooltip=Comentários do marcador diff --git a/iped-app/src/main/java/iped/app/ui/BookmarksManager.java b/iped-app/src/main/java/iped/app/ui/BookmarksManager.java index e6cced5d8d..1d83c9295b 100644 --- a/iped-app/src/main/java/iped/app/ui/BookmarksManager.java +++ b/iped-app/src/main/java/iped/app/ui/BookmarksManager.java @@ -19,6 +19,7 @@ package iped.app.ui; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; @@ -71,6 +72,7 @@ import iped.app.ui.bookmarks.BookmarkAndKey; import iped.app.ui.bookmarks.BookmarkColorsManager; +import iped.app.ui.bookmarks.BookmarkEditDialog; import iped.app.ui.bookmarks.BookmarkListRenderer; import iped.data.IItem; import iped.data.IItemId; @@ -100,7 +102,7 @@ public class BookmarksManager implements ActionListener, ListSelectionListener, JCheckBox duplicates = new JCheckBox(); JButton butAdd = new JButton(Messages.getString("BookmarksManager.Add")); //$NON-NLS-1$ JButton butRemove = new JButton(Messages.getString("BookmarksManager.Remove")); //$NON-NLS-1$ - JButton butRename = new JButton(Messages.getString("BookmarksManager.Rename")); //$NON-NLS-1$ + JButton butEdit = new JButton(Messages.getString("BookmarksManager.Edit")); //$NON-NLS-1$ JTextField newBookmark = new JTextField(); JTextArea comments = new JTextArea(); JButton butNew = new JButton(Messages.getString("BookmarksManager.New")); //$NON-NLS-1$ @@ -154,6 +156,7 @@ private BookmarksManager() { butAdd.setToolTipText(Messages.getString("BookmarksManager.Add.Tip")); //$NON-NLS-1$ butRemove.setToolTipText(Messages.getString("BookmarksManager.Remove.Tip")); //$NON-NLS-1$ butDelete.setToolTipText(Messages.getString("BookmarksManager.Delete.Tip")); //$NON-NLS-1$ + butEdit.setToolTipText(Messages.getString("BookmarksManager.Edit.Tip")); //$NON-NLS-1$ JPanel top = new JPanel(new GridLayout(3, 2, 0, 5)); top.add(msg); @@ -178,7 +181,7 @@ private BookmarksManager() { left1.add(left3); JPanel left2 = new JPanel(new GridLayout(0, 1, 0, 0)); - left2.add(butRename); + left2.add(butEdit); left2.add(butDelete); JPanel left = new JPanel(new BorderLayout()); @@ -211,7 +214,7 @@ private BookmarksManager() { butAdd.addActionListener(this); butUpdateComment.addActionListener(this); butRemove.addActionListener(this); - butRename.addActionListener(this); + butEdit.addActionListener(this); butNew.addActionListener(this); butDelete.addActionListener(this); @@ -408,7 +411,7 @@ private void includeDuplicates(ArrayList uniqueSelectedIds) { @Override public void actionPerformed(final ActionEvent evt) { if (evt.getSource() == butAdd || evt.getSource() == butRemove || evt.getSource() == butUpdateComment - || evt.getSource() == butRename || evt.getSource() == butDelete) { + || evt.getSource() == butEdit || evt.getSource() == butDelete) { // Check if there is at least one bookmark selected if (list.getSelectedIndex() == -1) { showMessage(Messages.getString("BookmarksManager.AlertNoSelectedBookmarks")); @@ -416,7 +419,7 @@ public void actionPerformed(final ActionEvent evt) { } } - if (evt.getSource() == butUpdateComment || evt.getSource() == butRename) { + if (evt.getSource() == butUpdateComment || evt.getSource() == butEdit) { // Check if there is more than one bookmark selected if (list.getSelectedIndices().length > 1) { showMessage(Messages.getString("BookmarksManager.AlertMultipleSelectedBookmarks")); @@ -475,21 +478,36 @@ public void actionPerformed(final ActionEvent evt) { } - } else if (evt.getSource() == butRename) { - String newBookmark = JOptionPane.showInputDialog(dialog, Messages.getString("BookmarksManager.NewName"), //$NON-NLS-1$ - list.getSelectedValue().getName()); - if (newBookmark != null && !newBookmark.trim().isEmpty()) { - newBookmark = newBookmark.trim(); - int selIdx = list.getSelectedIndex(); - String bookmark = list.getModel().getElementAt(selIdx).getName(); - if (!bookmark.equalsIgnoreCase(newBookmark) && listModel.contains(new BookmarkAndKey(newBookmark))) { - JOptionPane.showMessageDialog(dialog, Messages.getString("BookmarksManager.AlreadyExists")); - return; + } else if (evt.getSource() == butEdit) { + String currentName = list.getSelectedValue().getName(); + Color currentColor = multiBookmarks.getBookmarkColor(currentName); + BookmarkEditDialog editDialog = new BookmarkEditDialog(dialog, currentName, currentColor); + editDialog.setVisible(true); + + boolean changed = false; + String newName = editDialog.getNewName(); + if (newName != null) { + if (!newName.isEmpty() && !newName.equals(currentName)) { + if (!currentName.equalsIgnoreCase(newName) && listModel.contains(new BookmarkAndKey(newName))) { + JOptionPane.showMessageDialog(dialog, Messages.getString("BookmarksManager.AlreadyExists")); + } else { + multiBookmarks.renameBookmark(currentName, newName); + updateList(currentName, newName); + currentName = newName; + changed = true; + } } - multiBookmarks.renameBookmark(bookmark, newBookmark); - updateList(bookmark, newBookmark); + } + Color newColor = editDialog.getNewColor(); + if (newColor != null && !newColor.equals(currentColor)) { + multiBookmarks.setBookmarkColor(currentName, newColor); + changed = true; + } + + if (changed) { multiBookmarks.saveState(); BookmarksController.get().updateUI(); + list.repaint(); } } diff --git a/iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkEditDialog.java b/iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkEditDialog.java new file mode 100644 index 0000000000..0ce31cca9f --- /dev/null +++ b/iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkEditDialog.java @@ -0,0 +1,152 @@ +package iped.app.ui.bookmarks; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.UIManager; + +import iped.app.ui.Messages; + +public class BookmarkEditDialog extends JDialog { + private static final long serialVersionUID = -8204366293115657785L; + + private String newName; + private Color newColor; + + private JButton selButton; + + public BookmarkEditDialog(JDialog parent, String currentName, Color currentColor) { + super(parent, ModalityType.APPLICATION_MODAL); + setTitle(Messages.getString("BookmarksManager.Edit.Title")); + setLocationRelativeTo(parent); + setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + + JPanel content = new JPanel(new BorderLayout(10, 10)); + content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + setContentPane(content); + + // Bookmark name + JPanel p1 = new JPanel(new BorderLayout(2, 2)); + add(p1, BorderLayout.NORTH); + + p1.add(new JLabel(Messages.getString("BookmarksManager.Edit.Name") + ":"), BorderLayout.NORTH); + + JTextField txtName = new JTextField(); + txtName.setText(currentName); + txtName.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + txtName.selectAll(); + } + }); + p1.add(txtName, BorderLayout.CENTER); + + // Bookmark color + JPanel p2 = new JPanel(new BorderLayout(2, 2)); + add(p2, BorderLayout.CENTER); + + p2.add(new JLabel(Messages.getString("BookmarksManager.Edit.Color") + ":"), BorderLayout.NORTH); + + int numColors = BookmarkStandardColors.colors.length + 1; + JPanel colorGrid = new JPanel(new GridLayout(BookmarkStandardColors.numStandardColors / 9, 10, 2, 2)); + int x = 0; + int y = 0; + boolean seen = false; + newColor = currentColor; + for (int i = 0; i < numColors; i++) { + int idx = x < 9 ? x + y * 9 : BookmarkStandardColors.numStandardColors + y; + Color color = idx < BookmarkStandardColors.colors.length ? BookmarkStandardColors.colors[idx] : null; + boolean checked = false; + if (color == null) { + if (seen) { + break; + } + color = currentColor; + checked = true; + } else if (color.equals(currentColor)) { + checked = true; + seen = true; + } + BookmarkIcon icon = BookmarkIcon.getIcon(color, checked); + JButton but = new JButton(icon); + if (checked) { + selButton = but; + } + colorGrid.add(but); + but.setFocusable(true); + but.setFocusPainted(false); + but.setBorder(null); + but.setContentAreaFilled(false); + but.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (selButton != null) { + ((BookmarkIcon) (selButton.getIcon())).setChecked(false); + selButton.repaint(); + } + newColor = icon.getColor(); + icon.setChecked(true); + selButton = but; + } + }); + + if (++x == 10) { + x = 0; + y++; + } + } + p2.add(colorGrid, BorderLayout.CENTER); + + // Buttons + JPanel p3 = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 2)); + add(p3, BorderLayout.SOUTH); + + Dimension dim = new Dimension(90, 30); + JButton butOk = new JButton(); + butOk.setText(UIManager.get("OptionPane.okButtonText").toString()); + butOk.setPreferredSize(dim); + p3.add(butOk); + + JButton butCancel = new JButton(); + butCancel.setPreferredSize(dim); + butCancel.setText(UIManager.get("OptionPane.cancelButtonText").toString()); + p3.add(butCancel); + + butOk.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + newName = txtName.getText().trim(); + setVisible(false); + } + }); + + butCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + newName = null; + newColor = null; + setVisible(false); + } + }); + + pack(); + } + + public String getNewName() { + return newName; + } + + public Color getNewColor() { + return newColor; + } +} diff --git a/iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkIcon.java b/iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkIcon.java index a1399f62cc..7526fb0255 100644 --- a/iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkIcon.java +++ b/iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkIcon.java @@ -9,6 +9,7 @@ import java.awt.RenderingHints.Key; import java.awt.Shape; import java.awt.Stroke; +import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import java.util.HashMap; import java.util.Map; @@ -24,6 +25,7 @@ public class BookmarkIcon implements Icon { private static final Map iconPerColor = new HashMap(); private static final Map iconPerBookmarkStr = new HashMap(); private static final Stroke strokeBorder = new BasicStroke(1f); + private static final Stroke strokeChecked = new BasicStroke(2.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); private static final RenderingHints renderingHints; static { @@ -38,6 +40,7 @@ public class BookmarkIcon implements Icon { private final Color color; private final Color[] colors; + private Boolean checked; public static Icon getIcon(IMultiBookmarks bookmarks, String str) { if (str == null || str.isEmpty()) { @@ -73,6 +76,10 @@ public static synchronized Icon getIcon(Color color) { return icon; } + public static BookmarkIcon getIcon(Color color, boolean checked) { + return new BookmarkIcon(color, checked); + } + private BookmarkIcon(Color color) { this.color = color; this.colors = null; @@ -83,6 +90,12 @@ private BookmarkIcon(Color[] colors) { this.colors = colors; } + private BookmarkIcon(Color color, Boolean checked) { + this.color = color; + this.colors = null; + this.checked = checked; + } + @Override public void paintIcon(Component comp, Graphics g, int x, int y) { Graphics2D g2 = (Graphics2D) g; @@ -93,8 +106,18 @@ public void paintIcon(Component comp, Graphics g, int x, int y) { int arc = size / 3 + 2; if (colors == null) { - g2.setColor(color == null ? BookmarkStandardColors.defaultColor : color); + Color c = color == null ? BookmarkStandardColors.defaultColor : color; + g2.setColor(c); g2.fillRoundRect(x + 1, y + 1, size - 2, size - 2, arc, arc); + if (checked == Boolean.TRUE) { + g2.setColor(Color.WHITE); + g2.setStroke(strokeChecked); + GeneralPath gp = new GeneralPath(); + gp.moveTo(x + 1 + size / 5.0, y + 1 + size * 2 / 5.0); + gp.lineTo(x + size / 2.0, y - 1 + size * 4 / 5.0); + gp.lineTo(x - 1 + size * 4 / 5.0, y + 1 + size / 5.0); + g2.draw(gp); + } } else { double w = (size - 2) / (double) colors.length; double d = x + 1; @@ -123,11 +146,23 @@ public void paintIcon(Component comp, Graphics g, int x, int y) { @Override public int getIconWidth() { - return IconManager.getIconSize() - 2; + return IconManager.getIconSize() + (checked != null ? 2 : -2); } @Override public int getIconHeight() { - return IconManager.getIconSize() - 2; + return getIconWidth(); + } + + public Color getColor() { + return color; + } + + public Boolean getChecked() { + return checked; + } + + public void setChecked(Boolean checked) { + this.checked = checked; } }