mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added capacitor
This commit is contained in:
+19
-27
@@ -6,6 +6,7 @@ import java.awt.GridBagLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -23,6 +24,7 @@ import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.presenter.ComparatorFactory;
|
||||
import org.diylc.presenter.ComponentProcessor;
|
||||
|
||||
import com.diyfever.gui.MemoryBar;
|
||||
@@ -166,6 +168,8 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
case AVAILABLE_CTRL_POINTS_CHANGED:
|
||||
componentsUnderCursor = new ArrayList<IDIYComponent>(
|
||||
((Map<IDIYComponent, ControlPointWrapper>) params[0]).keySet());
|
||||
Collections.sort(componentsUnderCursor, ComparatorFactory.getInstance()
|
||||
.getComponentNameComparator());
|
||||
refreshStatusText();
|
||||
break;
|
||||
}
|
||||
@@ -176,34 +180,22 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
if ((componentsUnderCursor == null) || (componentsUnderCursor.isEmpty())) {
|
||||
getStatusLabel().setText("");
|
||||
} else {
|
||||
// String formattedNames = "";
|
||||
// int n = 1;
|
||||
// for (IDIYComponent component : componentsUnderCursor) {
|
||||
// if (n > 1) {
|
||||
// formattedNames += ", ";
|
||||
// }
|
||||
// formattedNames +=
|
||||
// ComponentProcessor.getInstance().extractBomName(component);//
|
||||
// +
|
||||
// // " (<b><font color=\"blue\">"
|
||||
// // +
|
||||
// // n++
|
||||
// // +
|
||||
// // "</font></b>)";
|
||||
// }
|
||||
if (componentsUnderCursor.size() == 1) {
|
||||
getStatusLabel().setText(
|
||||
"Drag \""
|
||||
+ ComponentProcessor.getInstance().extractComponentName(
|
||||
componentsUnderCursor.get(0)) + "\"");
|
||||
} else {
|
||||
getStatusLabel().setText(
|
||||
"Hold CTRL key to drag all "
|
||||
+ componentsUnderCursor.size()
|
||||
+ " components under the cursor or drag only \""
|
||||
+ ComponentProcessor.getInstance().extractComponentName(
|
||||
componentsUnderCursor.get(0)) + "\"");
|
||||
String formattedNames = "";
|
||||
int n = 1;
|
||||
for (IDIYComponent component : componentsUnderCursor) {
|
||||
if (n > 1) {
|
||||
formattedNames += ", ";
|
||||
}
|
||||
formattedNames += ComponentProcessor.getInstance().extractComponentName(
|
||||
component);//
|
||||
// +
|
||||
// " (<b><font color=\"blue\">"
|
||||
// +
|
||||
n++;
|
||||
// +
|
||||
// "</font></b>)";
|
||||
}
|
||||
getStatusLabel().setText("Drag " + formattedNames + "");
|
||||
}
|
||||
} else {
|
||||
getStatusLabel().setText(
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class ComparatorFactory {
|
||||
|
||||
private static ComparatorFactory instance;
|
||||
|
||||
private Comparator<IDIYComponent> componentNameComparator;
|
||||
|
||||
public static ComparatorFactory getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ComparatorFactory();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Comparator<IDIYComponent> getComponentNameComparator() {
|
||||
if (componentNameComparator == null) {
|
||||
componentNameComparator = new Comparator<IDIYComponent>() {
|
||||
|
||||
@Override
|
||||
public int compare(IDIYComponent o1, IDIYComponent o2) {
|
||||
String name1 = ComponentProcessor.getInstance().extractComponentName(o1);
|
||||
String name2 = ComponentProcessor.getInstance().extractComponentName(o2);
|
||||
if (name1 == null || name2 == null) {
|
||||
return 0;
|
||||
}
|
||||
return name1.compareToIgnoreCase(name2);
|
||||
}
|
||||
};
|
||||
}
|
||||
return componentNameComparator;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user