Cannot type "q" letter in any of the boxes around the app

This commit is contained in:
bancika
2017-01-05 16:10:52 +01:00
parent 980055d4c0
commit 8a3f017468
8 changed files with 30 additions and 15 deletions
@@ -94,9 +94,10 @@ public class MainFrame extends JFrame implements ISwingUI {
DialogFactory.getInstance().initialize(this);
this.presenter = new Presenter(this);
canvasPlugin = new CanvasPlugin(this);
presenter.installPlugin(new ToolBox(this));
presenter.installPlugin(new ComponentTree(this));
presenter.installPlugin(new ToolBox(this));
presenter.installPlugin(new FileMenuPlugin(this));
presenter.installPlugin(new EditMenuPlugin(this));
presenter.installPlugin(new ConfigPlugin(this));
@@ -105,8 +106,10 @@ public class MainFrame extends JFrame implements ISwingUI {
presenter.installPlugin(new HelpMenuPlugin(this));
presenter.installPlugin(new StatusBar(this));
canvasPlugin = new CanvasPlugin(this);
presenter.installPlugin(canvasPlugin);
presenter.installPlugin(new ComponentTree(this, canvasPlugin.getCanvasPanel()));
presenter.installPlugin(new FramePlugin());
try {
@@ -34,7 +34,7 @@ import org.diylc.common.IPlugInPort;
*
* @author Branislav Stojkovic
*/
class CanvasPanel extends JComponent implements Autoscroll {
public class CanvasPanel extends JComponent implements Autoscroll {
private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import java.util.EnumSet;
import javax.swing.JComponent;
import javax.swing.SwingConstants;
import org.apache.log4j.Logger;
@@ -27,9 +28,11 @@ public class ComponentTree implements IPlugIn {
private IPlugInPort plugInPort;
private TreePanel treePanel;
private JComponent canvasPanel;
public ComponentTree(ISwingUI swingUI) {
public ComponentTree(ISwingUI swingUI, JComponent canvasPanel) {
this.swingUI = swingUI;
this.canvasPanel = canvasPanel;
}
@Override
@@ -57,7 +60,11 @@ public class ComponentTree implements IPlugIn {
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getKeyChar() == 'q') {
if ((canvasPanel.hasFocus() || treePanel.hasFocus())
&& e.getKeyChar() == 'q'
&& ConfigurationManager.getInstance()
.readString(ConfigPlugin.COMPONENT_BROWSER, ConfigPlugin.SEARCHABLE_TREE)
.equals(ConfigPlugin.SEARCHABLE_TREE)) {
getTreePanel().getSearchField().requestFocusInWindow();
return true;
}