Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
berndmoos committed Feb 15, 2025
1 parent 1e427dc commit 6fb9e82
Show file tree
Hide file tree
Showing 9 changed files with 522 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* WordWiseReversedSortAction.java
*
* Created on 19. Februar 2007, 13:45
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package org.exmaralda.exakt.exmaraldaSearch.KWICTableActions;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import org.exmaralda.exakt.exmaraldaSearch.swing.AdvancedSortDialog;
import org.exmaralda.exakt.exmaraldaSearch.swing.COMAKWICTable;

/**
*
* @author thomas
*/
public class AdvancedSortAction extends AbstractKWICTableAction {

/** Creates a new instance of WordWiseReversedSortAction
* @param t
* @param title */
public AdvancedSortAction(COMAKWICTable t, String title) {
super(t,title);
}

@Override
public void actionPerformed(ActionEvent e) {
AdvancedSortDialog advancedSortDialog = new AdvancedSortDialog((Frame) table.getTopLevelAncestor(), true, table);
advancedSortDialog.setLocationRelativeTo(table);
advancedSortDialog.setVisible(true);
if (!advancedSortDialog.approved){
return;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class RowsMenu extends javax.swing.JMenu {
private final JMenuItem selectHighlightedMenuItem;
private final JMenuItem deselectHighlightedMenuItem;
private final JMenuItem removeUnselectedMenuItem;
private final JMenuItem advancedSortMenuItem;



Expand Down Expand Up @@ -105,9 +106,25 @@ public void actionPerformed(ActionEvent e) {
}
});
this.add(deselectHighlightedMenuItem);

this.addSeparator();

advancedSortMenuItem = new JMenuItem("Advanced sorting...");
advancedSortMenuItem.addActionListener(new javax.swing.AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
advancedSorting(e);
}

});
this.add(advancedSortMenuItem);
}

void advancedSorting(ActionEvent e) {
if (exaktFrame.getActiveSearchPanel()==null) return;
exaktFrame.getActiveSearchPanel().getKWICTable().advancedSortAction.actionPerformed(e);
}


void sample(ActionEvent e){
if (exaktFrame.getActiveSearchPanel()==null) return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" value="Advanced sorting"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,77,0,0,1,-27"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="mainPanel">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 300]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 300]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="okCancelPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="okButton">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="addPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="West"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="addButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/exmaralda/exakt/exmaraldaSearch/swing/resources/list-add.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Add sort criterion"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
158 changes: 158 additions & 0 deletions src/org/exmaralda/exakt/exmaraldaSearch/swing/AdvancedSortDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JDialog.java to edit this template
*/
package org.exmaralda.exakt.exmaraldaSearch.swing;

import java.util.ArrayList;
import java.util.List;

/**
*
* @author bernd
*/
public class AdvancedSortDialog extends javax.swing.JDialog {


COMAKWICTable kwic;

List<AdvancedSortPanel> sortPanels = new ArrayList<>();

public boolean approved = false;

/**
* Creates new form AdvancedSortDialog
*/
public AdvancedSortDialog(java.awt.Frame parent, boolean modal, COMAKWICTable kwic) {
super(parent, modal);
this.kwic = kwic;
initComponents();
AdvancedSortPanel initialPanel = new AdvancedSortPanel(kwic);
sortPanels.add(initialPanel);
mainPanel.add(initialPanel);
pack();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

mainPanel = new javax.swing.JPanel();
okCancelPanel = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
addPanel = new javax.swing.JPanel();
addButton = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Advanced sorting");

mainPanel.setMaximumSize(new java.awt.Dimension(400, 300));
mainPanel.setMinimumSize(new java.awt.Dimension(400, 300));
mainPanel.setLayout(new javax.swing.BoxLayout(mainPanel, javax.swing.BoxLayout.Y_AXIS));
getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);

okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
okCancelPanel.add(okButton);

cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
okCancelPanel.add(cancelButton);

getContentPane().add(okCancelPanel, java.awt.BorderLayout.SOUTH);

addButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/exmaralda/exakt/exmaraldaSearch/swing/resources/list-add.png"))); // NOI18N
addButton.setToolTipText("Add sort criterion");
addButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addButtonActionPerformed(evt);
}
});
addPanel.add(addButton);

getContentPane().add(addPanel, java.awt.BorderLayout.WEST);

pack();
}// </editor-fold>//GEN-END:initComponents

private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
approved = true;
dispose();
}//GEN-LAST:event_okButtonActionPerformed

private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed

private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
AdvancedSortPanel addedPanel = new AdvancedSortPanel(kwic);
sortPanels.add(addedPanel);
mainPanel.add(addedPanel);
pack();
}//GEN-LAST:event_addButtonActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(AdvancedSortDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AdvancedSortDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AdvancedSortDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AdvancedSortDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
AdvancedSortDialog dialog = new AdvancedSortDialog(new javax.swing.JFrame(), true, null);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addButton;
private javax.swing.JPanel addPanel;
private javax.swing.JButton cancelButton;
private javax.swing.JPanel mainPanel;
private javax.swing.JButton okButton;
private javax.swing.JPanel okCancelPanel;
// End of variables declaration//GEN-END:variables
}
Loading

0 comments on commit 6fb9e82

Please sign in to comment.