Java 类weka.core.EnvironmentHandler 实例源码

项目:repo.kmeanspp.silhouette_score    文件:Saver.java   
/**
 * Pass the environment variables on the the wrapped saver
 */
private void passEnvOnToSaver() {
  // set environment variables
  if (m_SaverTemplate instanceof EnvironmentHandler && m_env != null) {
    ((EnvironmentHandler) m_Saver).setEnvironment(m_env);
  }
}
项目:repo.kmeanspp.silhouette_score    文件:Loader.java   
protected void newStructure(boolean... notificationOnly) throws Exception {

    if (notificationOnly != null && notificationOnly.length > 0) {
      // If incremental then specify whether this FORMAT_AVAILABLE
      // event is actually the start of stream processing or just
      // due to a file/source change
      m_ie.m_formatNotificationOnly = notificationOnly[0];
    } else {
      m_ie.m_formatNotificationOnly = false;
    }

    try {
      m_Loader.reset();

      // Set environment variables
      if (m_Loader instanceof EnvironmentHandler && m_env != null) {
        try {
          ((EnvironmentHandler) m_Loader).setEnvironment(m_env);
        } catch (Exception ex) {
        }
      }
      m_dataFormat = m_Loader.getStructure();
      System.out
        .println("[Loader] Notifying listeners of instance structure avail.");
      notifyStructureAvailable(m_dataFormat);
    } catch (StructureNotReadyException e) {
      if (m_log != null) {
        m_log.statusMessage(statusMessagePrefix() + "WARNING: "
          + e.getMessage());
        m_log.logMessage("[Loader] " + statusMessagePrefix() + " "
          + e.getMessage());
      }
    }
  }
项目:repo.kmeanspp.silhouette_score    文件:KnowledgeFlowApp.java   
private void setEnvironment() {
  // pass m_flowEnvironment to all components
  // that implement EnvironmentHandler
  Vector<Object> beans = BeanInstance.getBeanInstances(m_mainKFPerspective
    .getCurrentTabIndex());
  for (int i = 0; i < beans.size(); i++) {
    Object temp = ((BeanInstance) beans.elementAt(i)).getBean();

    if (temp instanceof EnvironmentHandler) {
      ((EnvironmentHandler) temp).setEnvironment(m_flowEnvironment);
    }
  }
}
项目:autoweka    文件:Saver.java   
/**
 * Pass the environment variables on the the wrapped saver
 */
private void passEnvOnToSaver() {
  // set environment variables
  if (m_SaverTemplate instanceof EnvironmentHandler && m_env != null) {
    ((EnvironmentHandler)m_Saver).setEnvironment(m_env);
  }
}
项目:autoweka    文件:Loader.java   
protected void newStructure() throws Exception {

  m_Loader.reset();

  // Set environment variables
  if (m_Loader instanceof EnvironmentHandler && m_env != null) {
    try {
      ((EnvironmentHandler)m_Loader).setEnvironment(m_env);
    }catch (Exception ex) {
    }
  }
  m_dataFormat = m_Loader.getStructure();
  System.out.println("[Loader] Notifying listeners of instance structure avail.");
  notifyStructureAvailable(m_dataFormat);
}
项目:autoweka    文件:KnowledgeFlowApp.java   
private void setEnvironment() {
  // pass m_flowEnvironment to all components
  // that implement EnvironmentHandler
  Vector beans = BeanInstance.getBeanInstances(m_mainKFPerspective.getCurrentTabIndex());
  for (int i = 0; i < beans.size(); i++) {
    Object temp = ((BeanInstance) beans.elementAt(i)).getBean();

    if (temp instanceof EnvironmentHandler) {
      ((EnvironmentHandler) temp).setEnvironment(m_flowEnvironment);
    }
  }
}
项目:umple    文件:Saver.java   
/**
 * Pass the environment variables on the the wrapped saver
 */
private void passEnvOnToSaver() {
  // set environment variables
  if (m_SaverTemplate instanceof EnvironmentHandler && m_env != null) {
    ((EnvironmentHandler) m_Saver).setEnvironment(m_env);
  }
}
项目:umple    文件:Loader.java   
protected void newStructure(boolean... notificationOnly) throws Exception {

    if (notificationOnly != null && notificationOnly.length > 0) {
      // If incremental then specify whether this FORMAT_AVAILABLE
      // event is actually the start of stream processing or just
      // due to a file/source change
      m_ie.m_formatNotificationOnly = notificationOnly[0];
    } else {
      m_ie.m_formatNotificationOnly = false;
    }

    try {
      m_Loader.reset();

      // Set environment variables
      if (m_Loader instanceof EnvironmentHandler && m_env != null) {
        try {
          ((EnvironmentHandler) m_Loader).setEnvironment(m_env);
        } catch (Exception ex) {
        }
      }
      m_dataFormat = m_Loader.getStructure();
      System.out
        .println("[Loader] Notifying listeners of instance structure avail.");
      notifyStructureAvailable(m_dataFormat);
    } catch (StructureNotReadyException e) {
      if (m_log != null) {
        m_log.statusMessage(statusMessagePrefix() + "WARNING: "
          + e.getMessage());
        m_log.logMessage("[Loader] " + statusMessagePrefix() + " "
          + e.getMessage());
      }
    }
  }
项目:umple    文件:KnowledgeFlowApp.java   
private void setEnvironment() {
  // pass m_flowEnvironment to all components
  // that implement EnvironmentHandler
  Vector<Object> beans = BeanInstance.getBeanInstances(m_mainKFPerspective
    .getCurrentTabIndex());
  for (int i = 0; i < beans.size(); i++) {
    Object temp = ((BeanInstance) beans.elementAt(i)).getBean();

    if (temp instanceof EnvironmentHandler) {
      ((EnvironmentHandler) temp).setEnvironment(m_flowEnvironment);
    }
  }
}
项目:jbossBA    文件:Saver.java   
/**
 * Pass the environment variables on the the wrapped saver
 */
private void passEnvOnToSaver() {
  // set environment variables
  if (m_SaverTemplate instanceof EnvironmentHandler && m_env != null) {
    ((EnvironmentHandler) m_Saver).setEnvironment(m_env);
  }
}
项目:jbossBA    文件:Loader.java   
protected void newStructure() throws Exception {
    if (m_Loader instanceof EnvironmentHandler && m_env != null) {
      try {
        ((EnvironmentHandler)m_Loader).setEnvironment(m_env);
      } catch (Exception ex) {}
    }
    m_dataFormat = m_Loader.getStructure();
//    System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("Loader_NewFileSelected_Text"));
//    notifyStructureAvailable(m_dataFormat);
  }
项目:jbossBA    文件:KnowledgeFlowApp.java   
private void setEnvironment() {
  // pass m_flowEnvironment to all components
  // that implement EnvironmentHandler
  Vector beans = BeanInstance.getBeanInstances();
  for (int i = 0; i < beans.size(); i++) {
    Object temp = ((BeanInstance) beans.elementAt(i)).getBean();

    if (temp instanceof EnvironmentHandler) {
      ((EnvironmentHandler) temp).setEnvironment(m_flowEnvironment);
    }
  }
}
项目:jbossBA    文件:KnowledgeFlowApp.java   
/**
 * Popup the customizer for this bean
 * 
 * @param custClass the class of the customizer
 * @param bc the bean to be customized
 */
private void popupCustomizer(Class custClass, JComponent bc) {
  try {
    // instantiate
    final Object customizer = custClass.newInstance();
    // set environment **before** setting object!!
    if (customizer instanceof EnvironmentHandler) {
      ((EnvironmentHandler) customizer).setEnvironment(m_flowEnvironment);
    }
    ((Customizer) customizer).setObject(bc);
    final javax.swing.JFrame jf = new javax.swing.JFrame();
    jf.getContentPane().setLayout(new BorderLayout());
    jf.getContentPane().add((JComponent) customizer, BorderLayout.CENTER);
    if (customizer instanceof CustomizerCloseRequester) {
      ((CustomizerCloseRequester) customizer).setParentFrame(jf);
    }
    jf.addWindowListener(new java.awt.event.WindowAdapter() {
      @Override
      public void windowClosing(java.awt.event.WindowEvent e) {
        if (customizer instanceof CustomizerClosingListener) {
          ((CustomizerClosingListener) customizer).customizerClosing();
        }
        jf.dispose();
      }
    });
    jf.pack();
    jf.setVisible(true);
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * adds the given Loader to a DOM structure.
 * 
 * @param parent the parent of this object, e.g. the class this object is a
 *          member of
 * @param o the Object to describe in XML
 * @param name the name of the object
 * @return the node that was created
 * @throws Exception if the DOM creation fails
 */
public Element writeLoader(Element parent, Object o, String name)
  throws Exception {

  Element node;
  weka.core.converters.Loader loader;
  File file;
  boolean known;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), name);
  }

  m_CurrentNode = parent;

  loader = (weka.core.converters.Loader) o;
  node = addElement(parent, name, loader.getClass().getName(), false);
  known = true;
  file = null;

  // file
  if (loader instanceof weka.core.converters.AbstractFileLoader) {
    file = ((weka.core.converters.AbstractFileLoader) loader).retrieveFile();
  } else {
    known = false;
  }

  if (!known) {
    System.out.println("WARNING: unknown loader class '"
      + loader.getClass().getName() + "' - cannot retrieve file!");
  }

  Boolean relativeB = null;
  if (loader instanceof weka.core.converters.FileSourcedConverter) {
    boolean relative = ((weka.core.converters.FileSourcedConverter) loader)
      .getUseRelativePath();
    relativeB = new Boolean(relative);
  }

  // only save it, if it's a real file!
  if ((file == null) || (file.isDirectory())) {
    invokeWriteToXML(node, "", VAL_FILE);
  } else {
    String withResourceSeparators = file.getPath().replace(
      File.pathSeparatorChar, '/');
    boolean notAbsolute = (((weka.core.converters.AbstractFileLoader) loader)
      .getUseRelativePath()
      || (loader instanceof EnvironmentHandler && Environment
        .containsEnvVariables(file.getPath()))
      || this.getClass().getClassLoader().getResource(withResourceSeparators) != null || !file
      .exists());

    String path = (notAbsolute) ? file.getPath() : file.getAbsolutePath();
    // Replace any windows file separators with forward slashes (Java under
    // windows can
    // read paths with forward slashes (apparantly)
    path = path.replace('\\', '/');
    invokeWriteToXML(node, path, VAL_FILE);
  }
  if (relativeB != null) {
    invokeWriteToXML(node, relativeB.toString(), VAL_RELATIVE_PATH);
  }

  if (loader instanceof weka.core.OptionHandler) {
    String[] opts = ((weka.core.OptionHandler) loader).getOptions();
    invokeWriteToXML(node, opts, VAL_OPTIONS);
  }

  return node;
}
项目:repo.kmeanspp.silhouette_score    文件:KnowledgeFlowApp.java   
/**
 * Popup the customizer for this bean
 * 
 * @param custClass the class of the customizer
 * @param bc the bean to be customized
 */
private void popupCustomizer(Class<?> custClass, JComponent bc) {
  try {
    // instantiate
    final Object customizer = custClass.newInstance();
    // set environment **before** setting object!!
    if (customizer instanceof EnvironmentHandler) {
      ((EnvironmentHandler) customizer).setEnvironment(m_flowEnvironment);
    }

    if (customizer instanceof BeanCustomizer) {
      ((BeanCustomizer) customizer).setModifiedListener(this);
    }

    ((Customizer) customizer).setObject(bc);
    // final javax.swing.JFrame jf = new javax.swing.JFrame();
    final JDialog d = new JDialog(
      (java.awt.Frame) KnowledgeFlowApp.this.getTopLevelAncestor(),
      ModalityType.DOCUMENT_MODAL);
    d.setLayout(new BorderLayout());
    d.getContentPane().add((JComponent) customizer, BorderLayout.CENTER);

    // jf.getContentPane().setLayout(new BorderLayout());
    // jf.getContentPane().add((JComponent)customizer, BorderLayout.CENTER);
    if (customizer instanceof CustomizerCloseRequester) {
      ((CustomizerCloseRequester) customizer).setParentWindow(d);
    }
    d.addWindowListener(new java.awt.event.WindowAdapter() {
      @Override
      public void windowClosing(java.awt.event.WindowEvent e) {
        if (customizer instanceof CustomizerClosingListener) {
          ((CustomizerClosingListener) customizer).customizerClosing();
        }
        d.dispose();
      }
    });
    // jf.pack();
    // jf.setVisible(true);
    d.pack();
    d.setLocationRelativeTo(KnowledgeFlowApp.this);
    d.setVisible(true);
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
项目:repo.kmeanspp.silhouette_score    文件:KnowledgeFlowApp.java   
private void addComponent(BeanInstance comp, boolean repaint) {
  if (comp.getBean() instanceof Visible) {
    ((Visible) comp.getBean()).getVisual().addPropertyChangeListener(this);
  }
  if (comp.getBean() instanceof BeanCommon) {
    ((BeanCommon) comp.getBean()).setLog(m_logPanel);
  }
  if (comp.getBean() instanceof MetaBean) {
    // re-align sub-beans
    Vector<Object> list;

    list = ((MetaBean) comp.getBean()).getInputs();
    for (int i = 0; i < list.size(); i++) {
      ((BeanInstance) list.get(i)).setX(comp.getX());
      ((BeanInstance) list.get(i)).setY(comp.getY());
    }

    list = ((MetaBean) comp.getBean()).getOutputs();
    for (int i = 0; i < list.size(); i++) {
      ((BeanInstance) list.get(i)).setX(comp.getX());
      ((BeanInstance) list.get(i)).setY(comp.getY());
    }
  }

  if (comp.getBean() instanceof EnvironmentHandler) {
    ((EnvironmentHandler) comp.getBean()).setEnvironment(m_flowEnvironment);
  }

  // check for a duplicate name
  checkForDuplicateName(comp);

  KnowledgeFlowApp.this.setCursor(Cursor
    .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  if (repaint) {
    m_beanLayout.repaint();
  }
  m_pointerB.setSelected(true);
  m_mode = NONE;

  m_selectAllB.setEnabled(BeanInstance.getBeanInstances(
    m_mainKFPerspective.getCurrentTabIndex()).size() > 0);
}
项目:autoweka    文件:XMLBeans.java   
/**
 * adds the given Loader to a DOM structure.
 * 
 * @param parent the parent of this object, e.g. the class this object is a member of
 * @param o the Object to describe in XML
 * @param name the name of the object
 * @return the node that was created
 * @throws Exception if the DOM creation fails
 */
public Element writeLoader(Element parent, Object o, String name)
    throws Exception {

  Element                       node;
  weka.core.converters.Loader   loader;
  File                          file;
  boolean                       known;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), name);

  m_CurrentNode = parent;

  loader = (weka.core.converters.Loader) o;
  node   = addElement(parent, name, loader.getClass().getName(), false);
  known  = true;
  file   = null;

  // file
  if (loader instanceof weka.core.converters.AbstractFileLoader)
    file = ((weka.core.converters.AbstractFileLoader) loader).retrieveFile();
  else
    known = false;

  if (!known)
    System.out.println("WARNING: unknown loader class '" + loader.getClass().getName() + "' - cannot retrieve file!");

  Boolean relativeB = null;
  if (loader instanceof weka.core.converters.FileSourcedConverter) {
    boolean relative = ((weka.core.converters.FileSourcedConverter)loader).getUseRelativePath();
    relativeB = new Boolean(relative);
  }

  // only save it, if it's a real file!
  if ( (file == null) || (file.isDirectory()) ) {
    invokeWriteToXML(node, "", VAL_FILE);
  } else {
    String withResourceSeparators = file.getPath().replace(File.pathSeparatorChar, '/');
    boolean notAbsolute = 
      (((weka.core.converters.AbstractFileLoader) loader).getUseRelativePath() ||
      (loader instanceof EnvironmentHandler 
          && Environment.containsEnvVariables(file.getPath())) ||
          this.getClass().getClassLoader().getResource(withResourceSeparators) != null ||
          !file.exists());

    String path = (notAbsolute)
      ? file.getPath()
      : file.getAbsolutePath();
    // Replace any windows file separators with forward slashes (Java under windows can
    // read paths with forward slashes (apparantly)
    path = path.replace('\\', '/');
    invokeWriteToXML(node, path, VAL_FILE);
  }
  if (relativeB != null) {
    invokeWriteToXML(node, relativeB.toString(), VAL_RELATIVE_PATH);
  }

  if (loader instanceof weka.core.OptionHandler) {
    String[] opts = ((weka.core.OptionHandler)loader).getOptions();
    invokeWriteToXML(node, opts, VAL_OPTIONS);
  }

  return node;
}
项目:autoweka    文件:KnowledgeFlowApp.java   
private synchronized void loadDataAndSendToPerspective(final weka.core.converters.Loader loader, 
    final int perspectiveIndex, final boolean sendToAll) {
  if (m_perspectiveDataLoadThread == null) {
    m_perspectiveDataLoadThread = new Thread() {
      public void run() {
        try {
          Environment env = m_mainKFPerspective.getEnvironmentSettings();
          if (loader instanceof EnvironmentHandler) {
            ((EnvironmentHandler)loader).setEnvironment(env);
          }

          loader.reset();
          m_logPanel.statusMessage("[KnowledgeFlow]|Sending data to perspective(s)...");
          Instances data = loader.getDataSet();
          if (data != null) {
            // make sure the perspective toolbar is visible!!
            if (!m_configAndPerspectivesVisible) {
              KnowledgeFlowApp.this.add(m_configAndPerspectives, BorderLayout.NORTH);
              m_configAndPerspectivesVisible = true;
            }

            // need to disable all the perspective buttons
            for (int i = 0; i < m_perspectives.size(); i++) {
              m_perspectiveToolBar.getComponent(i).setEnabled(false);
            }

            if (sendToAll) {
              for (int i = 1; i < m_perspectives.size(); i++) {
                if (m_perspectives.get(i).acceptsInstances()) {
                  m_perspectives.get(i).setInstances(data);
                }
              }
            } else {
              KFPerspective currentP = 
                (KFPerspective)m_perspectiveHolder.getComponent(0);
              if (currentP != m_perspectives.get(perspectiveIndex)) {
                m_perspectives.get(perspectiveIndex).setInstances(data);
                currentP.setActive(false);
                m_perspectiveHolder.remove(0);
                m_perspectiveHolder.add((JComponent)m_perspectives.get(perspectiveIndex), 
                    BorderLayout.CENTER);
                m_perspectives.get(perspectiveIndex).setActive(true);
                ((JToggleButton)m_perspectiveToolBar.
                    getComponent(perspectiveIndex)).setSelected(true);
                //KnowledgeFlowApp.this.invalidate();
                KnowledgeFlowApp.this.revalidate();
                KnowledgeFlowApp.this.repaint();
                notifyIsDirty();
              }
            }
          }
        } catch (Exception ex) {
          System.err.println("[KnowledgeFlow] problem loading data for " +
              "perspective(s) : " + ex.getMessage());
          ex.printStackTrace();
        } finally {
          // re-enable all the perspective buttons
          for (int i = 0; i < m_perspectives.size(); i++) {
            m_perspectiveToolBar.getComponent(i).setEnabled(true);
          }
          m_perspectiveDataLoadThread = null;
          m_logPanel.statusMessage("[KnowledgeFlow]|OK");
        }
      }
    };
    m_perspectiveDataLoadThread.setPriority(Thread.MIN_PRIORITY);
    m_perspectiveDataLoadThread.start();
  }
}
项目:autoweka    文件:KnowledgeFlowApp.java   
/**
 * Popup the customizer for this bean
 *
 * @param custClass the class of the customizer
 * @param bc the bean to be customized
 */
private void popupCustomizer(Class custClass, JComponent bc) {
  try {
    // instantiate
    final Object customizer = custClass.newInstance();
    // set environment **before** setting object!!
    if (customizer instanceof EnvironmentHandler) {
      ((EnvironmentHandler)customizer).setEnvironment(m_flowEnvironment);
    }

    if (customizer instanceof BeanCustomizer) {
      ((BeanCustomizer)customizer).setModifiedListener(this);
    }

    ((Customizer)customizer).setObject(bc);
    // final javax.swing.JFrame jf = new javax.swing.JFrame();
    final JDialog d = new JDialog((java.awt.Frame)KnowledgeFlowApp.this.getTopLevelAncestor(), ModalityType.DOCUMENT_MODAL);
    d.setLayout(new BorderLayout());
    d.getContentPane().add((JComponent)customizer, BorderLayout.CENTER);

    //      jf.getContentPane().setLayout(new BorderLayout());
    //    jf.getContentPane().add((JComponent)customizer, BorderLayout.CENTER);
    if (customizer instanceof CustomizerCloseRequester) {
      ((CustomizerCloseRequester)customizer).setParentWindow(d);
    }
    d.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(java.awt.event.WindowEvent e) {
        if (customizer instanceof CustomizerClosingListener) {
          ((CustomizerClosingListener)customizer).customizerClosing();
        }
        d.dispose();
      }
    });
    //      jf.pack();
    //    jf.setVisible(true);
    d.pack();
    d.setLocationRelativeTo(KnowledgeFlowApp.this);
    d.setVisible(true);
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
项目:autoweka    文件:KnowledgeFlowApp.java   
private void addComponent(BeanInstance comp, boolean repaint) {
  if (comp.getBean() instanceof Visible) {
    ((Visible)comp.getBean()).getVisual().addPropertyChangeListener(this);
  }
  if (comp.getBean() instanceof BeanCommon) {
    ((BeanCommon)comp.getBean()).setLog(m_logPanel);
  }
  if (comp.getBean() instanceof MetaBean) {
    // re-align sub-beans
    Vector list;

    list = ((MetaBean) comp.getBean()).getInputs();
    for (int i = 0; i < list.size(); i++) {
      ((BeanInstance) list.get(i)).setX(comp.getX());
      ((BeanInstance) list.get(i)).setY(comp.getY());
    }

    list = ((MetaBean) comp.getBean()).getOutputs();
    for (int i = 0; i < list.size(); i++) {
      ((BeanInstance) list.get(i)).setX(comp.getX());
      ((BeanInstance) list.get(i)).setY(comp.getY());
    }            
  }

  if (comp.getBean() instanceof EnvironmentHandler) {
    ((EnvironmentHandler)comp.getBean()).setEnvironment(m_flowEnvironment);
  }

  // check for a duplicate name
  checkForDuplicateName(comp);

  KnowledgeFlowApp.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  if (repaint) {
    m_beanLayout.repaint();
  }
  m_pointerB.setSelected(true);
  m_mode = NONE;

  m_selectAllB.setEnabled(BeanInstance.
      getBeanInstances(m_mainKFPerspective.getCurrentTabIndex()).size() > 0);
}
项目:umple    文件:XMLBeans.java   
/**
 * adds the given Loader to a DOM structure.
 * 
 * @param parent the parent of this object, e.g. the class this object is a
 *          member of
 * @param o the Object to describe in XML
 * @param name the name of the object
 * @return the node that was created
 * @throws Exception if the DOM creation fails
 */
public Element writeLoader(Element parent, Object o, String name)
  throws Exception {

  Element node;
  weka.core.converters.Loader loader;
  File file;
  boolean known;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), name);
  }

  m_CurrentNode = parent;

  loader = (weka.core.converters.Loader) o;
  node = addElement(parent, name, loader.getClass().getName(), false);
  known = true;
  file = null;

  // file
  if (loader instanceof weka.core.converters.AbstractFileLoader) {
    file = ((weka.core.converters.AbstractFileLoader) loader).retrieveFile();
  } else {
    known = false;
  }

  if (!known) {
    System.out.println("WARNING: unknown loader class '"
      + loader.getClass().getName() + "' - cannot retrieve file!");
  }

  Boolean relativeB = null;
  if (loader instanceof weka.core.converters.FileSourcedConverter) {
    boolean relative = ((weka.core.converters.FileSourcedConverter) loader)
      .getUseRelativePath();
    relativeB = new Boolean(relative);
  }

  // only save it, if it's a real file!
  if ((file == null) || (file.isDirectory())) {
    invokeWriteToXML(node, "", VAL_FILE);
  } else {
    String withResourceSeparators = file.getPath().replace(
      File.pathSeparatorChar, '/');
    boolean notAbsolute = (((weka.core.converters.AbstractFileLoader) loader)
      .getUseRelativePath()
      || (loader instanceof EnvironmentHandler && Environment
        .containsEnvVariables(file.getPath()))
      || this.getClass().getClassLoader().getResource(withResourceSeparators) != null || !file
      .exists());

    String path = (notAbsolute) ? file.getPath() : file.getAbsolutePath();
    // Replace any windows file separators with forward slashes (Java under
    // windows can
    // read paths with forward slashes (apparantly)
    path = path.replace('\\', '/');
    invokeWriteToXML(node, path, VAL_FILE);
  }
  if (relativeB != null) {
    invokeWriteToXML(node, relativeB.toString(), VAL_RELATIVE_PATH);
  }

  if (loader instanceof weka.core.OptionHandler) {
    String[] opts = ((weka.core.OptionHandler) loader).getOptions();
    invokeWriteToXML(node, opts, VAL_OPTIONS);
  }

  return node;
}
项目:umple    文件:KnowledgeFlowApp.java   
/**
 * Popup the customizer for this bean
 * 
 * @param custClass the class of the customizer
 * @param bc the bean to be customized
 */
private void popupCustomizer(Class<?> custClass, JComponent bc) {
  try {
    // instantiate
    final Object customizer = custClass.newInstance();
    // set environment **before** setting object!!
    if (customizer instanceof EnvironmentHandler) {
      ((EnvironmentHandler) customizer).setEnvironment(m_flowEnvironment);
    }

    if (customizer instanceof BeanCustomizer) {
      ((BeanCustomizer) customizer).setModifiedListener(this);
    }

    ((Customizer) customizer).setObject(bc);
    // final javax.swing.JFrame jf = new javax.swing.JFrame();
    final JDialog d = new JDialog(
      (java.awt.Frame) KnowledgeFlowApp.this.getTopLevelAncestor(),
      ModalityType.DOCUMENT_MODAL);
    d.setLayout(new BorderLayout());
    d.getContentPane().add((JComponent) customizer, BorderLayout.CENTER);

    // jf.getContentPane().setLayout(new BorderLayout());
    // jf.getContentPane().add((JComponent)customizer, BorderLayout.CENTER);
    if (customizer instanceof CustomizerCloseRequester) {
      ((CustomizerCloseRequester) customizer).setParentWindow(d);
    }
    d.addWindowListener(new java.awt.event.WindowAdapter() {
      @Override
      public void windowClosing(java.awt.event.WindowEvent e) {
        if (customizer instanceof CustomizerClosingListener) {
          ((CustomizerClosingListener) customizer).customizerClosing();
        }
        d.dispose();
      }
    });
    // jf.pack();
    // jf.setVisible(true);
    d.pack();
    d.setLocationRelativeTo(KnowledgeFlowApp.this);
    d.setVisible(true);
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
项目:umple    文件:KnowledgeFlowApp.java   
private void addComponent(BeanInstance comp, boolean repaint) {
  if (comp.getBean() instanceof Visible) {
    ((Visible) comp.getBean()).getVisual().addPropertyChangeListener(this);
  }
  if (comp.getBean() instanceof BeanCommon) {
    ((BeanCommon) comp.getBean()).setLog(m_logPanel);
  }
  if (comp.getBean() instanceof MetaBean) {
    // re-align sub-beans
    Vector<Object> list;

    list = ((MetaBean) comp.getBean()).getInputs();
    for (int i = 0; i < list.size(); i++) {
      ((BeanInstance) list.get(i)).setX(comp.getX());
      ((BeanInstance) list.get(i)).setY(comp.getY());
    }

    list = ((MetaBean) comp.getBean()).getOutputs();
    for (int i = 0; i < list.size(); i++) {
      ((BeanInstance) list.get(i)).setX(comp.getX());
      ((BeanInstance) list.get(i)).setY(comp.getY());
    }
  }

  if (comp.getBean() instanceof EnvironmentHandler) {
    ((EnvironmentHandler) comp.getBean()).setEnvironment(m_flowEnvironment);
  }

  // check for a duplicate name
  checkForDuplicateName(comp);

  KnowledgeFlowApp.this.setCursor(Cursor
    .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  if (repaint) {
    m_beanLayout.repaint();
  }
  m_pointerB.setSelected(true);
  m_mode = NONE;

  m_selectAllB.setEnabled(BeanInstance.getBeanInstances(
    m_mainKFPerspective.getCurrentTabIndex()).size() > 0);
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * adds the given Loader to a DOM structure.
 * 
 * @param parent the parent of this object, e.g. the class this object is a member of
 * @param o the Object to describe in XML
 * @param name the name of the object
 * @return the node that was created
 * @throws Exception if the DOM creation fails
 */
public Element writeLoader(Element parent, Object o, String name)
    throws Exception {

  Element                       node;
  weka.core.converters.Loader   loader;
  File                          file;
  boolean                       known;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), name);

  m_CurrentNode = parent;

  loader = (weka.core.converters.Loader) o;
  node   = addElement(parent, name, loader.getClass().getName(), false);
  known  = true;
  file   = null;

  // file
  if (loader instanceof weka.core.converters.AbstractFileLoader)
    file = ((weka.core.converters.AbstractFileLoader) loader).retrieveFile();
  else
    known = false;

  if (!known)
    System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_WriteLoader_Text_First") + loader.getClass().getName()
          + Messages.getInstance().getString("XMLBeans_WriteLoader_Text_Second"));

  Boolean relativeB = null;
  if (loader instanceof weka.core.converters.FileSourcedConverter) {
    boolean relative = ((weka.core.converters.FileSourcedConverter)loader).getUseRelativePath();
    relativeB = new Boolean(relative);
  }

  // only save it, if it's a real file!
  if ( (file == null) || (file.isDirectory()) ) {
    invokeWriteToXML(node, "", VAL_FILE);
  } else {
    boolean notAbsolute = 
      (((weka.core.converters.AbstractFileLoader) loader).getUseRelativePath() ||
      (loader instanceof EnvironmentHandler 
          && Environment.containsEnvVariables(file.getPath())));

    String path = (notAbsolute)
      ? file.getPath()
      : file.getAbsolutePath();
    // Replace any windows file separators with forward slashes (Java under windows can
    // read paths with forward slashes (apparantly)
    path = path.replace('\\', '/');
    invokeWriteToXML(node, path, VAL_FILE);
  }
  if (relativeB != null) {
    invokeWriteToXML(node, relativeB.toString(), VAL_RELATIVE_PATH);
  }

  return node;
}