Example #1
0
	/**
	 * Returns the text area that fired the specified event.
	 * @param evt The event
	 */
	public static JEditTextArea getTextArea(EventObject evt)
	{
		if(evt != null)
		{
			Object o = evt.getSource();
			if(o instanceof Component)
			{
				// find the parent text area
				Component c = (Component)o;
				for(;;)
				{
					if(c instanceof JEditTextArea)
						return (JEditTextArea)c;
					else if(c == null)
						break;
					if(c instanceof JPopupMenu)
						c = ((JPopupMenu)c)
							.getInvoker();
					else
						c = c.getParent();
				}
			}
		}

		// this shouldn't happen
		System.err.println("BUG: getTextArea() returning null");
		System.err.println("Report this to Slava Pestov <*****@*****.**>");
		return null;
	}
Example #2
0
  /**
   * Send an event to all registered listeners, except the named one.
   *
   * @param event the event to be sent: public void method_name( event_class event)
   */
  public void sendEventExcludeSource(java.util.EventObject event) {
    if (!hasListeners) {
      return;
    }

    Object source = event.getSource();
    Object[] args = new Object[1];
    args[0] = event;

    // send event to all listeners except the source
    ListIterator iter = listeners.listIterator();
    while (iter.hasNext()) {
      Object client = iter.next();
      if (client == source) {
        continue;
      }

      try {
        method.invoke(client, args);
      } catch (IllegalAccessException e) {
        iter.remove();
        System.err.println("ListenerManager IllegalAccessException = " + e);
      } catch (IllegalArgumentException e) {
        iter.remove();
        System.err.println("ListenerManager IllegalArgumentException = " + e);
      } catch (InvocationTargetException e) {
        iter.remove();
        System.err.println("ListenerManager InvocationTargetException on " + method);
        System.err.println("   threw exception " + e.getTargetException());
        e.printStackTrace();
      }
    }
  }
Example #3
0
  @Override
  protected boolean doAction(EventObject e) {
    this.settingsFrm.setWaitCursor(true);

    boolean rv = false;
    Object src = e.getSource();
    if (src != null) {
      if ((src == this.btnMon31_64x16)
          || (src == this.btnMon31_64x32)
          || (src == this.btnMonSCCH80)
          || (src == this.btnMonSCCH1088)
          || (src == this.btnMon2010)) {
        rv = true;
        upd2010FieldsEnabled();
        updSCCHFieldsEnabled();
        fireDataChanged();
      } else if (src instanceof AbstractButton) {
        rv = true;
        fireDataChanged();
      }
    }
    if (!rv) {
      rv = this.tabGIDE.doAction(e);
    }
    this.settingsFrm.setWaitCursor(false);
    return rv;
  }
  protected void listMouseClicked(EventObject e) {
    for (ListLevel listLevelTuple : depthLists) {
      listLevelTuple.list.setCellRenderer(new SceneDepthListCellRender());
    }

    JList list = (JList) e.getSource();
    selectedScene = (Scene) list.getSelectedValue();
    jumpToBt.setEnabled(true);
    jumpToBt.setText("Jump to [" + selectedScene.getName() + "]");

    int idx = depthLists.indexOf(new ListLevel(-1, list));
    assert idx != -1 : "Should have found a scenesList";

    if (idx == 0) {
      JList startList = depthLists.get(1).list;
      startList.setCellRenderer(new ToCellRenderer(selectedScene));
      Util.showComponent(startList);
    } else if (idx > 0) {
      JList fromList = depthLists.get(idx - 1).list;
      logger.debug("Before: " + fromList.getSelectedValue());

      fromList.setCellRenderer(new FromCellRenderer(selectedScene));
      Util.showComponent(fromList);

      if (idx + 1 < depthLists.size()) {
        JList afterList = depthLists.get(idx + 1).list;
        logger.debug("After: " + afterList.getSelectedValue());

        afterList.setCellRenderer(new ToCellRenderer(selectedScene));
        Util.showComponent(afterList);
      }
    }

    Util.showComponent(panel);
  }
Example #5
0
 /**
  * Método que pide confirmación al usuario antes de salir de la aplicación.
  *
  * @param e El evento generado.
  * @return Si se puede salir o no (elección del usuario).
  */
 public boolean canExit(EventObject e) {
   // Si se ha modificado el modelo, pedir confirmación de salida
   if (DelphSimApp.getApplication().getInterfaz().getArchivoModificado()) {
     org.jdesktop.application.ResourceMap resourceMap =
         org.jdesktop.application.Application.getInstance(delphsim.DelphSimApp.class)
             .getContext()
             .getResourceMap(DelphSimView.class);
     Object source = (e != null) ? e.getSource() : null;
     Component owner = (source instanceof Component) ? (Component) source : null;
     String[] opciones = {"Sí", "No"};
     int option =
         JOptionPane.showOptionDialog(
             owner,
             resourceMap.getString("ExitListener.msg"),
             resourceMap.getString("ExitListener.title"),
             JOptionPane.YES_NO_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null,
             opciones,
             opciones[1]); // NOI18N
     return option == JOptionPane.YES_OPTION;
   } else {
     return true;
   }
 }
Example #6
0
 public synchronized void eventRegistered(EventObject e) {
   if (e.getSource() == model && model.isReady()) {
     setCanPaint(true);
     setWantsPaint(true);
     notifyListeners();
   }
 }
  public void lPStateChanged(EventObject e) throws Throwable {
    JTabbedPane tabbedPane = (JTabbedPane) ((JTabbedPane) e.getSource()).getSelectedComponent();
    int selectedCur = ((JTabbedPane) e.getSource()).getSelectedIndex();

    if (selectedCur == IDX_TABBED_PANE_PERSONAL) {
      createTabbedPanePersonal(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPanePersonal.lPEventObjectChanged(null);
    } else if (selectedCur == IDX_TABBED_PANE_ZEITMODELL) {
      createTabbedPaneZeitmodell(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPaneZeitmodell.lPEventObjectChanged(null);
    } else if (selectedCur == IDX_TABBED_PANE_BEREITSCHAFT) {
      createTabbedPaneBereitschaft(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPaneBereitschaft.lPEventObjectChanged(null);
    } else if (selectedCur == IDX_TABBED_PANE_BETRIEBSKALENDER) {
      createTabbedPaneBetriebskalender(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPaneBetriebskalender.lPEventObjectChanged(null);
    } else if (selectedCur == IDX_TABBED_PANE_GRUNDDATEN) {
      createTabbedPaneGrunddaten(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPaneGrunddaten.lPEventObjectChanged(null);
    } else if (selectedCur == IDX_TABBED_PANE_ARTIKELZULAGE) {
      createTabbedPaneArtikelzulage(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPaneArtikelzulage.lPEventObjectChanged(null);
    } else if (selectedCur == IDX_TABBED_PANE_KOLLEKTIV) {
      createTabbedPaneKollektiv(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPaneKollektiv.lPEventObjectChanged(null);
    } else if (selectedCur == IDX_TABBED_PANE_PERSONALGRUPPEN) {
      createTabbedPanePersonalgruppe(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPanePersonalgruppe.lPEventObjectChanged(null);
    } else if (selectedCur == IDX_TABBED_PANE_FAHRZEUG) {
      createTabbedPaneFahrzeug(tabbedPane);
      // Info an Tabbedpane, bist selektiert worden.
      tabbedPaneFahrzeug.lPEventObjectChanged(null);
    }
  }
 @Override
 public boolean isCellEditable(EventObject e) {
   if (e instanceof MouseEvent && e.getSource() instanceof JTree) {
     MouseEvent me = (MouseEvent) e;
     JTree tree = (JTree) e.getSource();
     TreePath path = tree.getPathForLocation(me.getX(), me.getY());
     Rectangle r = tree.getPathBounds(path);
     if (r == null) {
       return false;
     }
     Dimension d = getPreferredSize();
     r.setSize(new Dimension(d.width, r.height));
     if (r.contains(me.getX(), me.getY())) {
       if (str == null && System.getProperty("java.version").startsWith("1.7.0")) {
         setBounds(new Rectangle(0, 0, d.width, r.height));
       }
       // System.out.println(getBounds());
       return true;
     }
   }
   return false;
 }
 @Override
 public boolean isCellEditable(EventObject event) {
   boolean returnValue = false;
   if (event instanceof MouseEvent) {
     MouseEvent mouseEvent = (MouseEvent) event;
     if (mouseEvent.getClickCount() > 1) {
       JTree tree = (JTree) event.getSource();
       TreePath path = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY());
       if (path != null) {
         Object node = path.getLastPathComponent();
         if (node != null) {
           returnValue = (registerEditors.containsKey(node.getClass()));
           if (returnValue && (node instanceof ITEMType)) {
             ITEMType item = (ITEMType) node;
             returnValue = item.getVirtual().equals(YesnoType.NO);
           }
         }
       }
     }
   }
   return returnValue;
 }
  /** Captura los eventos de las cajas de texto */
  public void actionValueChanged(EventObject e) {
    if (!panel.isEnableValueChangedEvent()) return;

    // Niveles de la posterización
    if (e.getSource() == panel.getPosterizationPanel().getLevels().getDataInputField()) {
      String value = panel.getPosterizationPanel().getLevels().getValue();
      try {
        double doubleValue = Double.valueOf(value);
        if (doubleValue < 2) throw new NumberFormatException();
      } catch (NumberFormatException ex) {
        panel.setEnableValueChangedEvent(false);
        value = 2 + "";
        panel.getPosterizationPanel().getLevels().setValue(value);
        panel.setEnableValueChangedEvent(true);
      }

      data.setPosterizationLevels((int) Double.parseDouble(value));
      if ((int) Double.parseDouble(value) == 2)
        panel.getPosterizationPanel().getThreshold().setControlEnabled(true);
      else panel.getPosterizationPanel().getThreshold().setControlEnabled(false);
      refreshPreview();
    }
  }
Example #11
0
    /**
     * Called when an event is to be posed to the member.
     *
     * @param event Event to post.
     * @return true if event should be propogated, false if it should be cancelled.
     */
    public boolean eventPosted(EventObject event) {
      ElementTreeModel model = (ElementTreeModel) _tree.getModel();
      // XXX This crap needs cleaning up. Type switching is lazy...
      if (event instanceof PropertyChangeEvent) {
        // The project node has changed.
        model.fireNodeChanged((ACSElement) event.getSource());
      } else if (event instanceof NewElementEvent && model != null) {
        ACSElement element = ((NewElementEvent) event).getNewElement();
        model.fireNodeAdded(element);
        TreePath path = new TreePath(model.getPathToRoot(element));
        _selections.setSelectionPath(path);
        _tree.scrollPathToVisible(path);
      } else {
        ACSProjectElement project = null;
        if (event instanceof ProjectSelectedEvent) {
          ProjectSelectedEvent e = (ProjectSelectedEvent) event;
          project = e.getSelectedProject();
        }

        if (project == null) {
          // The project has been closed.
          // XXX this needs to be tested against
          // different version of Swing...
          _tree.setModel(null);
          _tree.setSelectionModel(null);
          // Send an empty selection event to notify others that
          // nothing is selected.
          ElementSelectionEvent.createEvent(getContext(), null);
        } else {
          _tree.setModel(new ElementTreeModel(project));
          _selections = new ElementTreeSelectionModel();
          _selections.addTreeSelectionListener(new SelectionForwarder());
          _tree.setSelectionModel(_selections);
        }
      }
      return true;
    }
Example #12
0
 private SipListener getSipListener(EventObject sipEvent) {
   SipProvider source = (SipProvider) sipEvent.getSource();
   SipListener listener = (SipListener) providerTable.get(source);
   return listener;
 }
 /** Only handles events of type : "jmx.attribute.change" for the supported resource. */
 public boolean isEventEnabled(String eventType, EventObject event) {
   // This will only handle SSOAgent related events :
   return source.equals(event.getSource());
 }
Example #14
0
 @Override
 public boolean shouldSelectCell(EventObject anEvent) {
   System.out.println("shouldSelectCell " + anEvent.getSource());
   return super.shouldSelectCell(anEvent);
 }
Example #15
0
  private ConferenceTestClient getClient(EventObject event) {

    SipProvider provider = (SipProvider) event.getSource();
    return testerClients.get(provider);
  }
Example #16
0
 @Override
 public boolean isCellEditable(EventObject anEvent) {
   System.out.println("isCellEditable " + anEvent.getSource());
   return super.isCellEditable(anEvent);
 }
Example #17
0
 public Object doTransform(Object src) throws TransformerException {
   EventObject event = (EventObject) src;
   return new MuleMessage(event.getSource(), null);
 }