当前位置: 首页>>代码示例>>Java>>正文


Java JfaceMenupopup类代码示例

本文整理汇总了Java中org.pentaho.ui.xul.jface.tags.JfaceMenupopup的典型用法代码示例。如果您正苦于以下问题:Java JfaceMenupopup类的具体用法?Java JfaceMenupopup怎么用?Java JfaceMenupopup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JfaceMenupopup类属于org.pentaho.ui.xul.jface.tags包,在下文中一共展示了JfaceMenupopup类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addMenuLast

import org.pentaho.ui.xul.jface.tags.JfaceMenupopup; //导入依赖的package包/类
public void addMenuLast() {
  org.pentaho.ui.xul.dom.Document doc = (org.pentaho.ui.xul.dom.Document) mainSpoonContainer.getDocumentRoot();
  XulMenupopup recentFilesPopup = (XulMenupopup) doc.getElementById("file-open-recent-popup");

  int max = recentFilesPopup.getChildNodes().size();
  for (int i = max - 1; i >= 0; i--) {
    XulComponent mi = recentFilesPopup.getChildNodes().get(i);
    mi.getParent().removeChild(mi);
  }

  // Previously loaded files...
  List<LastUsedFile> lastUsedFiles = props.getLastUsedFiles();
  for (int i = 0; i < lastUsedFiles.size(); i++) {
    final LastUsedFile lastUsedFile = lastUsedFiles.get(i);

    char chr = (char) ('1' + i);
    String accessKey = "ctrl-" + chr; //$NON-NLS-1$
    String accessText = "CTRL-" + chr; //$NON-NLS-1$
    String text = lastUsedFile.toString();
    String id = "last-file-" + i; //$NON-NLS-1$

    if (i > 9) {
      accessKey = null;
      accessText = null;
    }

    XulMenuitem miFileLast = ((JfaceMenupopup) recentFilesPopup).createNewMenuitem();

    // shorten the filename if necessary
    int targetLength = 40;
    if (text.length() > targetLength) {
      int lastSep = text.replace('\\', '/').lastIndexOf('/');
      if (lastSep != -1) {
        String fileName = "..." + text.substring(lastSep);
        if (fileName.length() < targetLength) {
          // add the start of the file path
          int leadSize = targetLength - fileName.length();
          text = text.substring(0, leadSize) + fileName;
        } else {
          text = fileName;
        }
      }
    }

    miFileLast.setLabel(text);
    miFileLast.setId(id);
    miFileLast.setAcceltext(accessText);
    miFileLast.setAccesskey(accessKey);

    if (lastUsedFile.isTransformation()) {
  	  ((JfaceMenuitem) miFileLast).setImage(GUIResource.getInstance().getImageTransGraph());
    } else if (lastUsedFile.isJob()) {
  	  ((JfaceMenuitem) miFileLast).setImage(GUIResource.getInstance().getImageJobGraph());
    }
    miFileLast.setCommand("spoon.lastFileSelect('" + i + "')");
  }
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:58,代码来源:Spoon.java

示例2: addMenuLast

import org.pentaho.ui.xul.jface.tags.JfaceMenupopup; //导入依赖的package包/类
public void addMenuLast() {
  org.pentaho.ui.xul.dom.Document doc = mainSpoonContainer.getDocumentRoot();
  JfaceMenupopup recentFilesPopup = (JfaceMenupopup) doc.getElementById( "file-open-recent-popup" );

  recentFilesPopup.removeChildren();

  // Previously loaded files...
  List<LastUsedFile> lastUsedFiles = props.getLastUsedFiles();
  for ( int i = 0; i < lastUsedFiles.size(); i++ ) {
    final LastUsedFile lastUsedFile = lastUsedFiles.get( i );

    char chr = (char) ( '1' + i );
    String accessKey = "ctrl-" + chr;
    String accessText = "CTRL-" + chr;
    String text = lastUsedFile.toString();
    String id = "last-file-" + i;

    if ( i > 8 ) {
      accessKey = null;
      accessText = null;
    }

    final String lastFileId = Integer.toString( i );

    Action action = new Action( "open-last-file-" + ( i + 1 ), Action.AS_DROP_DOWN_MENU ) {
      @Override
      public void run() {
        lastFileSelect( lastFileId );
      }
    };

    // shorten the filename if necessary
    int targetLength = 40;
    if ( text.length() > targetLength ) {
      int lastSep = text.replace( '\\', '/' ).lastIndexOf( '/' );
      if ( lastSep != -1 ) {
        String fileName = "..." + text.substring( lastSep );
        if ( fileName.length() < targetLength ) {
          // add the start of the file path
          int leadSize = targetLength - fileName.length();
          text = text.substring( 0, leadSize ) + fileName;
        } else {
          text = fileName;
        }
      }
    }

    JfaceMenuitem miFileLast = new JfaceMenuitem( null, recentFilesPopup, mainSpoonContainer, text, 0, action );

    miFileLast.setLabel( text );
    miFileLast.setId( id );
    if ( accessText != null && accessKey != null ) {
      miFileLast.setAcceltext( accessText );
      miFileLast.setAccesskey( accessKey );
    }

    if ( lastUsedFile.isTransformation() ) {
      miFileLast.setImage( GUIResource.getInstance().getImageTransGraph() );
    } else if ( lastUsedFile.isJob() ) {
      miFileLast.setImage( GUIResource.getInstance().getImageJobGraph() );
    }
    miFileLast.setCommand( "spoon.lastFileSelect('" + i + "')" );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:65,代码来源:Spoon.java


注:本文中的org.pentaho.ui.xul.jface.tags.JfaceMenupopup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。