public void setShdPopupOnBtnClick(boolean shdPopup) { this.shdPopup = shdPopup; if (shdPopup) { main.addActionListener(pl); } else { main.removeActionListener(pl); } }
public void addActions(JPanel buttPanel) { AbstractAction netcdfAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { String location = ds.getLocation(); if (location == null) location = "test"; int pos = location.lastIndexOf("."); if (pos > 0) location = location.substring(0, pos); String filename = fileChooser.chooseFilenameToSave(location + ".nc"); if (filename == null) return; writeNetCDF(filename); } }; BAMutil.setActionProperties(netcdfAction, "netcdf", "Write netCDF-3 file", false, 'S', -1); BAMutil.addActionToContainer(buttPanel, netcdfAction); AbstractAction ncstreamAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { String location = ds.getLocation(); if (location == null) location = "test"; int pos = location.lastIndexOf("."); if (pos > 0) location = location.substring(0, pos); String filename = fileChooser.chooseFilenameToSave(location + ".ncs"); if (filename == null) return; writeNcstream(filename); } }; BAMutil.setActionProperties(ncstreamAction, "netcdf", "Write ncstream file", false, 'S', -1); BAMutil.addActionToContainer(buttPanel, ncstreamAction); AbstractButton compareButton = BAMutil.makeButtcon("Select", "Compare to another file", false); compareButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { compareDataset(); } }); buttPanel.add(compareButton); AbstractAction attAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { showAtts(); } }; BAMutil.setActionProperties(attAction, "FontDecr", "global attributes", false, 'A', -1); BAMutil.addActionToContainer(buttPanel, attAction); }
/** * Default constructor. * * @param man view manager */ public TextView(final ViewNotifier man) { super(TEXTVIEW, man); border(5).layout(new BorderLayout(0, 5)); header = new BaseXHeader(RESULT); home = BaseXButton.command(GUIMenuCmd.C_HOME, gui); home.setEnabled(false); text = new TextPanel(false, gui); text.setSyntax(new SyntaxXML()); search = new SearchEditor(gui, text); final AbstractButton save = BaseXButton.get("c_save", SAVE, false, gui); final AbstractButton find = search.button(FIND); final BaseXBack buttons = new BaseXBack(false); buttons.layout(new TableLayout(1, 3, 1, 0)).border(0, 0, 4, 0); buttons.add(save); buttons.add(home); buttons.add(find); final BaseXBack b = new BaseXBack(false).layout(new BorderLayout()); b.add(buttons, BorderLayout.WEST); b.add(header, BorderLayout.EAST); add(b, BorderLayout.NORTH); add(search, BorderLayout.CENTER); save.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { save(); } }); refreshLayout(); }
public void addActionListener(ActionListener l) { main.addActionListener(l); listener = l; }
private void guiSetup() throws IOException { setContentPane(root); // control commandMap.put(btnForward, Command.FORWARD); commandMap.put(btnBackward, Command.BACKWARD); commandMap.put(btnLeft, Command.TURN_LEFT); commandMap.put(btnRight, Command.TURN_RIGHT); commandMap.put(btnStop, Command.STOP); // Servo && Camera commandMap.put(btnServoDown, Command.SERVO_DOWN); commandMap.put(btnServoLeft, Command.SERVO_LEFT); commandMap.put(btnServoRight, Command.SERVO_RIGHT); commandMap.put(btnServoUp, Command.SERVO_UP); commandMap.put(btnCamera, Command.TOGGLE_CAMERA); // LEDs commandMap.put(btnLeftLed, Command.TOGGLE_LEFT_BLINK); commandMap.put(btnRightLed, Command.TOGGLE_RIGHT_BLINK); commandMap.put(btnLED, Command.TOGGLE_LED); // speeds commandMap.put(btnSpeed1, Command.SPEED); commandMap.put(btnSpeed2, Command.SPEED); commandMap.put(btnSpeed3, Command.SPEED); commandMap.put(btnSpeed4, Command.SPEED); commandMap.put(btnSpeed5, Command.SPEED); // debugs commandMap.put(btnLF, Command.LEFT_FORWARD); commandMap.put(btnLB, Command.LEFT_BACKWARD); commandMap.put(btnLP, Command.LEFT_PAUSE); commandMap.put(btnRF, Command.RIGHT_FORWARD); commandMap.put(btnRB, Command.RIGHT_BACKWARD); commandMap.put(btnRP, Command.RIGHT_PAUSE); for (AbstractButton button : commandMap.keySet()) { button.addActionListener(this); } btnQuit.addActionListener(this); btnConnection.addActionListener(this); btnReset.addActionListener(this); btnShutdown.addActionListener(this); /* btnForward.addActionListener (this); btnLeft.addActionListener (this); btnBackward.addActionListener (this); btnRight.addActionListener (this); btnStop.addActionListener (this); btnSpeed1.addActionListener (this); btnSpeed2.addActionListener (this); btnSpeed3.addActionListener (this); btnSpeed4.addActionListener (this); btnSpeed5.addActionListener (this); btnLeftLed.addActionListener (this); btnRightLed.addActionListener (this); btnServoLeft.addActionListener (this); btnServoUp.addActionListener (this); btnServoRight.addActionListener (this); btnServoDown.addActionListener (this); btnLED.addActionListener (this); btnCamera.addActionListener (this); btnLF.addActionListener (this); btnLB.addActionListener (this); btnLP.addActionListener (this); btnRF.addActionListener (this); btnRB.addActionListener (this); btnRP.addActionListener (this); */ ButtonGroup group1 = new ButtonGroup(); group1.add(btnSpeed1); group1.add(btnSpeed2); group1.add(btnSpeed3); group1.add(btnSpeed4); group1.add(btnSpeed5); btnSpeed3.setSelected(true); setButtonStatus(false); }
public NcmlEditor(JPanel buttPanel, PreferencesExt prefs) { this.prefs = prefs; fileChooser = new FileManager(null, null, null, (PreferencesExt) prefs.node("FileManager")); AbstractAction coordAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { addCoords = (Boolean) getValue(BAMutil.STATE); String tooltip = addCoords ? "add Coordinates is ON" : "add Coordinates is OFF"; coordButt.setToolTipText(tooltip); } }; addCoords = prefs.getBoolean("coordState", false); String tooltip2 = addCoords ? "add Coordinates is ON" : "add Coordinates is OFF"; BAMutil.setActionProperties(coordAction, "addCoords", tooltip2, true, 'C', -1); coordAction.putValue(BAMutil.STATE, Boolean.valueOf(addCoords)); coordButt = BAMutil.addActionToContainer(buttPanel, coordAction); protoChooser = new ComboBox((PreferencesExt) prefs.node("protoChooser")); addProtoChoices(); buttPanel.add(protoChooser); protoChooser.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String ptype = (String) protoChooser.getSelectedItem(); String proto = protoMap.get(ptype); if (proto != null) { editor.setText(proto); } } }); editor = new JEditorPane(); // Instantiate a XMLEditorKit with wrapping enabled. XMLEditorKit kit = new XMLEditorKit(false); // Set the wrapping style. kit.setWrapStyleWord(true); editor.setEditorKit(kit); // Set the font style. editor.setFont(new Font("Monospaced", Font.PLAIN, 12)); // Set the tab size editor.getDocument().putProperty(PlainDocument.tabSizeAttribute, 2); // Enable auto indentation. editor.getDocument().putProperty(XMLDocument.AUTO_INDENTATION_ATTRIBUTE, true); // Enable tag completion. editor.getDocument().putProperty(XMLDocument.TAG_COMPLETION_ATTRIBUTE, true); // Initialise the folding kit.setFolding(true); // Set a style kit.setStyle(XMLStyleConstants.ATTRIBUTE_NAME, Color.RED, Font.BOLD); // Put the editor in a panel that will force it to resize, when a different view is choosen. ScrollableEditorPanel editorPanel = new ScrollableEditorPanel(editor); JScrollPane scroller = new JScrollPane(editorPanel); // Add the number margin as a Row Header View scroller.setRowHeaderView(new LineNumberMargin(editor)); AbstractAction wrapAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { XMLEditorKit kit = (XMLEditorKit) editor.getEditorKit(); kit.setLineWrappingEnabled(!kit.isLineWrapping()); editor.updateUI(); } }; BAMutil.setActionProperties(wrapAction, "Wrap", "Toggle Wrapping", false, 'W', -1); BAMutil.addActionToContainer(buttPanel, wrapAction); AbstractAction saveAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { String location = (ds == null) ? ncmlLocation : ds.getLocation(); if (location == null) location = "test"; int pos = location.lastIndexOf("."); if (pos > 0) location = location.substring(0, pos); String filename = fileChooser.chooseFilenameToSave(location + ".ncml"); if (filename == null) return; if (doSaveNcml(editor.getText(), filename)) ncmlLocation = filename; } }; BAMutil.setActionProperties(saveAction, "Save", "Save NcML", false, 'S', -1); BAMutil.addActionToContainer(buttPanel, saveAction); AbstractAction netcdfAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (outChooser == null) { outChooser = new NetcdfOutputChooser((Frame) null); outChooser.addPropertyChangeListener( "OK", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { writeNetcdf((NetcdfOutputChooser.Data) evt.getNewValue()); } }); } String location = (ds == null) ? ncmlLocation : ds.getLocation(); if (location == null) location = "test"; int pos = location.lastIndexOf("."); if (pos > 0) location = location.substring(0, pos); outChooser.setOutputFilename(location); outChooser.setVisible(true); } }; BAMutil.setActionProperties(netcdfAction, "netcdf", "Write netCDF file", false, 'N', -1); BAMutil.addActionToContainer(buttPanel, netcdfAction); AbstractAction transAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { doTransform(editor.getText()); } }; BAMutil.setActionProperties( transAction, "Import", "read textArea through NcMLReader\n write NcML back out via resulting dataset", false, 'T', -1); BAMutil.addActionToContainer(buttPanel, transAction); AbstractButton compareButton = BAMutil.makeButtcon("Select", "Check NcML", false); compareButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Formatter f = new Formatter(); checkNcml(f); infoTA.setText(f.toString()); infoTA.gotoTop(); infoWindow.show(); } }); buttPanel.add(compareButton); setLayout(new BorderLayout()); add(scroller, BorderLayout.CENTER); // the info window infoTA = new TextHistoryPane(); infoWindow = new IndependentWindow("Extra Information", BAMutil.getImage("netcdfUI"), infoTA); infoWindow.setBounds( (Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300))); }
public void ajouterActionListener(ActionListener actionListener, AbstractButton abstractButton) { abstractButton.addActionListener(actionListener); }