Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagolizardo committed May 25, 2015
1 parent e864902 commit 26df199
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 177 deletions.
18 changes: 0 additions & 18 deletions src/main/java/com/santiagolizardo/madcommander/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import javax.swing.JTabbedPane;

import com.santiagolizardo.madcommander.components.BasicToolbar;
import com.santiagolizardo.madcommander.components.DrivesToolbar;
import com.santiagolizardo.madcommander.components.ExecuteBar;
import com.santiagolizardo.madcommander.components.MainMenu;
import com.santiagolizardo.madcommander.components.Panels;
Expand All @@ -55,8 +54,6 @@ public class MainWindow extends JFrame {

private BasicToolbar basicToolbar;

private DrivesToolbar driveToolbar;

private ShortcutsPanel shortcutsPanel;
private JPanel executePanel;

Expand Down Expand Up @@ -117,7 +114,6 @@ private void defineLayout() {
container.setLayout(new GridBagLayout());

addBasicToolbar(false);
addDrivesToolbar(false);
addPanels();
addExecutePanel(false);
addShortcutsPanel(false);
Expand Down Expand Up @@ -148,20 +144,6 @@ public void removeBasicToolbar() {
contentPane.validate();
}

public void addDrivesToolbar(boolean validate) {
driveToolbar = new DrivesToolbar(this);
contentPane.add(driveToolbar, BorderLayout.SOUTH);
if (validate) {
contentPane.validate();
}
}

public void removeDrivesToolbar() {
contentPane.remove(driveToolbar);
driveToolbar = null;
contentPane.validate();
}

public void addPanels() {
GridBagConstraints c = new GridBagConstraints();
// w
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@

class AddToBookmarksAction extends AbstractAction {

/**
*
*/
private static final long serialVersionUID = 6038164265710205238L;

private MainWindow mainWindow;

public AddToBookmarksAction(MainWindow mainWindow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

public class DrivesToolbar extends JToolBar {

private static final long serialVersionUID = 4975350309638036942L;

public DrivesToolbar(MainWindow mainWindow) {
super();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.santiagolizardo.madcommander.components;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JLabel;
Expand Down Expand Up @@ -43,13 +44,15 @@ public class SummaryPanel extends JPanel {
private JLabel dirs;

public SummaryPanel() {
sizes = new JLabel();
sizes = new JLabel();
sizes.setHorizontalAlignment(JLabel.CENTER);
files = new JLabel();
files.setHorizontalAlignment(JLabel.CENTER);
dirs = new JLabel();
dirs.setHorizontalAlignment(JLabel.CENTER);

Dimension preferredSize = getPreferredSize();
setMaximumSize(new Dimension(Integer.MAX_VALUE, preferredSize.height));
defineLayout();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import javax.swing.table.TableColumnModel;

import com.santiagolizardo.madcommander.MainWindow;
import com.santiagolizardo.madcommander.components.PathLabel;
import com.santiagolizardo.madcommander.components.SummaryPanel;
import com.santiagolizardo.madcommander.components.filelisting.model.FileListingColumn;
import com.santiagolizardo.madcommander.components.filelisting.model.FileListingModel;
Expand All @@ -44,11 +43,10 @@
import com.santiagolizardo.madcommander.util.gui.DialogFactory;
import com.santiagolizardo.madcommander.util.gui.SwingUtil;
import java.io.IOException;
import javax.swing.BoxLayout;

public class FileListing extends JPanel {

private static final long serialVersionUID = -796592552883729956L;

private static final Logger LOGGER = Logger.getLogger(FileListing.class
.getName());

Expand All @@ -66,9 +64,9 @@ public enum Format {

public SummaryPanel summaryLabel;

public PathLabel pathLabel;
public PathTextField pathTextField;

private JScrollPane scroll;
private JScrollPane scrollPane;

private Format format;

Expand Down Expand Up @@ -101,12 +99,15 @@ public FileListing(final MainWindow mainWindow, Position position) {

updateColumnRenderers();

pathLabel = new PathLabel();

pathTextField = new PathTextField(this);
summaryLabel = new SummaryPanel();

scroll = new JScrollPane(table);
scroll.getViewport().setBackground(Color.WHITE);

scrollPane = new JScrollPane(table);
scrollPane.setOpaque(true);
scrollPane.setBackground(Color.BLUE);
scrollPane.setMinimumSize(scrollPane.getPreferredSize());
scrollPane.getViewport().setBackground(Color.WHITE);

SelectionListener listener = new SelectionListener(mainWindow, table, summaryLabel);
table.getSelectionModel().addListSelectionListener(listener);
Expand All @@ -124,7 +125,7 @@ public FileListing(final MainWindow mainWindow, Position position) {
private void updateColumnRenderers() {
TableColumnModel columnModel = table.getColumnModel();

for (byte i = 0; i < (format == Format.Full ? 5 : 3); i++) {
for (int i = 0; i < (format == Format.Full ? 5 : 3); i++) {
TableColumn tableColumn = columnModel.getColumn(i);
tableColumn.setCellRenderer(cellRenderer);
}
Expand Down Expand Up @@ -249,14 +250,19 @@ public void setFilter(FileFilter filter) {
public void selectGroup(String type, String searchPattern,
boolean caseSensitive) {
StringBuilder reBuffer = new StringBuilder();
if ("Contains".equals(type)) {
reBuffer.append(".*").append(searchPattern).append(".*");
} else if ("Starts with".equals(type)) {
reBuffer.append("^").append(searchPattern).append(".*");
} else if ("Ends with".equals(type)) {
reBuffer.append(".*").append(searchPattern).append("$");
} else {
reBuffer.append("^").append(searchPattern).append("$");
if (null != type) switch (type) {
case "Contains":
reBuffer.append(".*").append(searchPattern).append(".*");
break;
case "Starts with":
reBuffer.append("^").append(searchPattern).append(".*");
break;
case "Ends with":
reBuffer.append(".*").append(searchPattern).append("$");
break;
default:
reBuffer.append("^").append(searchPattern).append("$");
break;
}
String regexp = reBuffer.toString();
Pattern pattern = (caseSensitive ? Pattern.compile(regexp) : Pattern
Expand All @@ -276,14 +282,19 @@ public void selectGroup(String type, String searchPattern,
public void unselectGroup(String type, String searchPattern,
boolean caseSensitive) {
StringBuilder reBuffer = new StringBuilder();
if ("Contains".equals(type)) {
reBuffer.append(".*").append(searchPattern).append(".*");
} else if ("Starts with".equals(type)) {
reBuffer.append("^").append(searchPattern).append(".*");
} else if ("Ends with".equals(type)) {
reBuffer.append(".*").append(searchPattern).append("$");
} else {
reBuffer.append("^").append(searchPattern).append("$");
if (null != type) switch (type) {
case "Contains":
reBuffer.append(".*").append(searchPattern).append(".*");
break;
case "Starts with":
reBuffer.append("^").append(searchPattern).append(".*");
break;
case "Ends with":
reBuffer.append(".*").append(searchPattern).append("$");
break;
default:
reBuffer.append("^").append(searchPattern).append("$");
break;
}
String regexp = reBuffer.toString();
Pattern pattern = (caseSensitive ? Pattern.compile(regexp) : Pattern
Expand Down Expand Up @@ -345,29 +356,12 @@ public void execute() {
}

private void defineLayout() {
setLayout(new GridBagLayout());

GridBagConstraints c = new GridBagConstraints();

c.weightx = 1.0;

c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = 1;
c.weighty = 0.0;
add(pathLabel, c);

c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = 2;
c.weighty = 1.0;
add(scroll, c);

c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = 3;
c.weighty = 0.0;
add(summaryLabel, c);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(pathTextField);
add(scrollPane);
add(summaryLabel);

setMinimumSize(getPreferredSize());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
import com.santiagolizardo.madcommander.components.filelisting.FileListing.Format;
import javax.swing.SwingUtilities;


public class FileListingHeader extends JTableHeader implements MouseListener {

private static final long serialVersionUID = -7521856271497035896L;

private FileListingTable listingTable;

public Format format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.santiagolizardo.madcommander.components.filelisting.model.NameComparator;
import com.santiagolizardo.madcommander.components.filelisting.model.SizeComparator;
import com.santiagolizardo.madcommander.util.actions.InputMapUtil;
import java.awt.Color;
import java.util.logging.Logger;

public class FileListingTable extends JTable implements Runnable {
Expand Down Expand Up @@ -102,6 +103,10 @@ public FileListingTable(final MainWindow mainWindow,
dropTarget = new DropTarget(this, dropIn);

defineKeyBindings();
setOpaque(true);
setBackground(Color.LIGHT_GRAY);

setMinimumSize(getPreferredSize());
}

private void defineKeyBindings() {
Expand Down Expand Up @@ -141,7 +146,7 @@ public void run() {
if (dir.exists() == false) {
dir = new File(System.getProperty("user.dir"));
}
fileListing.pathLabel.setText(dir.getAbsolutePath());
fileListing.pathTextField.setText(dir.getAbsolutePath());

fileListing.summaryLabel.clearTotals();
File[] files = dir.listFiles(filter);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* This file is part of MadCommander, a file manager with two panels.
*
* MadCommander is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* MadCommander is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* MadCommander. If not, see <http://www.gnu.org/licenses/>.
*/
package com.santiagolizardo.madcommander.components.filelisting;

import java.awt.Dimension;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;
import javax.swing.JTextField;

public class PathTextField extends JTextField {

private FileListing fileListing;

public PathTextField(FileListing fileListing) {
super(30);

this.fileListing = fileListing;

Dimension preferredSize = getPreferredSize();
setMaximumSize(new Dimension(Integer.MAX_VALUE, preferredSize.height));

addKeyListener(new KeyAdapter() {

@Override
public void keyPressed(KeyEvent ev) {
if (ev.getKeyCode() == KeyEvent.VK_ENTER) {
String newPathString = getText();
File newPath = new File(newPathString);
if (newPath.isDirectory()) {
fileListing.setPath(newPathString);
} else {
setText(fileListing.getPath());
}
}
}
});
}
}
Loading

0 comments on commit 26df199

Please sign in to comment.