Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions src/main/java/org/jmeld/ui/dnd/DragAndDropPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
public class DragAndDropPanel
extends JPanel
{
public static Color DND_SELECTED_NOT_USED = ColorUtil.brighter(Color.LIGHT_GRAY);

private JComponent leftDragAndDropArea;
private JComponent rightDragAndDropArea;
private String leftFileName = "";
private String rightFileName = "";
private String leftFileName;
private String rightFileName;

public DragAndDropPanel()
{
Expand All @@ -63,6 +65,14 @@ public DragAndDropPanel()

addHierarchyListener(getHierarchyListener());
addMouseListener(getMouseListener());
cleanFiles();
}

private void cleanFiles() {
leftFileName = "";
rightFileName = "";
leftDragAndDropArea.setBackground(DND_SELECTED_NOT_USED);
rightDragAndDropArea.setBackground(DND_SELECTED_NOT_USED);
}

private HierarchyListener getHierarchyListener()
Expand Down Expand Up @@ -251,7 +261,7 @@ private JComponent createDragAndDropArea()
p = new JPanel();
p.setOpaque(true);
p.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
p.setBackground(ColorUtil.brighter(Color.LIGHT_GRAY));
p.setBackground(DND_SELECTED_NOT_USED);
p.setPreferredSize(new Dimension(20,
0));

Expand All @@ -264,24 +274,27 @@ private MouseListener getMouseListener()
{
public void mousePressed(MouseEvent me)
{
if (StringUtil.isEmpty(leftFileName) || StringUtil.isEmpty(rightFileName))
{
return;
}

if (leftFileName.equals(rightFileName))
try
{
return;
}
if (StringUtil.isEmpty(leftFileName))
{
return;
}

leftDragAndDropArea.setBackground(Colors.DND_SELECTED_USED);
rightDragAndDropArea.setBackground(Colors.DND_SELECTED_USED);
String leftPath = new File(new URL(leftFileName).toURI()).getAbsolutePath();
leftDragAndDropArea.setBackground(Colors.DND_SELECTED_USED);

try
{
JMeld.getJMeldPanel().openComparison(new File(new URL(leftFileName).toURI()).getAbsolutePath(),
new File(new URL(rightFileName).toURI()).getAbsolutePath(),
null);
String rightPath = "";
if (!StringUtil.isEmpty(rightFileName)) {
if (leftFileName.equals(rightFileName))
{
return;
}
rightPath = new File(new URL(rightFileName).toURI()).getAbsolutePath();
rightDragAndDropArea.setBackground(Colors.DND_SELECTED_USED);
}
cleanFiles();
JMeld.getJMeldPanel().openComparison(leftPath, rightPath, null);
}
catch (Exception ex)
{
Expand Down