레이블이 IT인 게시물을 표시합니다. 모든 게시물 표시
레이블이 IT인 게시물을 표시합니다. 모든 게시물 표시

2010년 10월 22일 금요일

[flex] 메뉴 간격 줄이기

http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/comment-page-1/#comment-8471

 

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/ -->
<mx:Application name="MenuBar_menuShow_menu_variableRowHeight_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            import mx.events.MenuEvent;
 
            protected function mBar_menuShowHandler(evt:MenuEvent):void {
                evt.menu.variableRowHeight = ch.selected;
                evt.menu.invalidateSize();
            }
        ]]>
    </mx:Script>
 
    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="ch" label="variableRowHeight" />
    </mx:ApplicationControlBar>
 
    <mx:MenuBar id="mBar"
            labelField="@label"
            menuShow="mBar_menuShowHandler(event);">
        <mx:dataProvider>
            <mx:XMLListCollection>
                <mx:XMLList xmlns="">
                    <menu label="File...">
                        <item label="New" />
                        <item label="Open" />
                        <item label="Save" />
                        <item label="Save As" />
                        <fake type="separator" />
                        <item label="Exit" />
                    </menu>
                    <menu label="Edit...">
                        <item label="Cut" />
                        <item label="Copy" />
                        <item label="Paste" />
                        <fake type="separator" />
                        <item label="Undo" />
                        <item label="Redo" />
                        <fake type="separator" />
                        <item label="radio button" type="radio" toggled="true" />
                        <item label="check box" type="check" toggled="true" />
                    </menu>
                </mx:XMLList>
            </mx:XMLListCollection>
        </mx:dataProvider>
    </mx:MenuBar>
 
</mx:Application>

2010년 10월 1일 금요일

[ActionScript] addEventListener시 파라미터 추가

현재 상황

  • 화면상에 여러개의 버튼과 textfield를 추가
  • script로 for문을 돌려서 실행하였고 그걸 다시 line 별로 같은 line의 textfield값의 받아서 처리 해야함
  • script에서 new로 button을 생성하다보니.. addEventListener 처리를 하다보니 받을 수 있는 값은 event 밖에 없음

처리 방법

  • button 상속후 버튼에 사용할 propeties 정의 setter/getter 추가
  • script에서 for문 이용해서 button 생성시 id값 넘겨줌
  • event 처리부에서 event.currentTarget.새로정의한properties 값 받아서 처리

[code]package custom
{
 import mx.controls.Button;  public class ExtendButton extends Button
 {
 
  private var _currentId:String;  public function ExtendButton()
  {
   super();
  }
 
  public function get currentId():String {
   return _currentId;
  }
  public function set currentId(currentId:String):void {
   _currentId = currentId;
  }
 
 
 }
}[/code]

 

위 처러 만든 후에

[code]var button:ExtendButton = new ExtendButton();
 for(var i:int=1;i<10;i++) {
  button.currentId = "a"+i;
 }
 
 button.addEventListener(MouseEvent.CLICK,function(event:MouseEvent):void{
  trace(event.currentTarget.currentId)
 });[/code]

 

이렇게 만들었음

 

------------------------------------------------------------------------------

여기서 부터는 질문

 http://blog.flashplatform.kr/tag/keep-generated-actionscript

 

위의 링크방식대로 한다고 하면

 

generated라고 옵션은 줘서 as 스크립트를 전부 만들어서 거기에서 추가적으로

 

처리를 해야지 처리가 가능한거지?? ㅡㅡ;;

 

아니면 안되는건지 알고 싶습니다.

 

 

2010년 9월 14일 화요일

eclispse monkey

[code javascript] /* * Menu: Actionscript > Convention Generator * Key: M3+1 * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript * Author: Yi Tan * MoreInfo: http://code.google.com/p/yis-eclipse-monkey-scripts-for-flash-builder/ */ /** * [What's this] * This script automatically converts input to class properties. * * For example: * * Your enter: * -propertyName:n= * * It will be converted to: * private var propertyName:Number= 0; * * * [Shortcut Key] * * Alt + 1 * * [How to use] * * Pleae check the how to slides * * http://www.slideshare.net/halfmile/convention-generator-yis-eclipse-monkey-scripts-for-flash-builder * * [Change log] * * 2009/11/11 Fix bug: fail to parse property name when there is input for the data type * 2009/11/6 Add condition checking for nil selection * 2009/10/31 First version * */ var ACCESS_TYPE_PUBLIC = "+"; var ACCESS_TYPE_PRIVATE = "-"; var ACCESS_TYPE_PROTECTED = "*"; var ALL_ACCESS_TYPES = "+-*"; var ACCESS_TYPES = {"+":"public", "-":"private", "*":"protected"}; var MEMBER_TYPE_METHOD = "method"; var MEMBER_TYPE_PROPERTY = "property"; var DATA_TYPE_DEFAULT_VALUES = { "Object":"{}", "String":'""', "Boolean":"false", "Array":"[]", "Number":"0", "int":"0", "uint":"0", "Vector":"new Vector.<>()", "XML":'""' }; var DATA_TYPE_ABBRES = { "o":"Object", "s":"String", "b":"Boolean", "a":"Array", "n":"Number", "i":"int", "u":"uint", "v":"Vector", "x":"XML" } function main() { var editor = editors.activeEditor var source = editor.source if (!editor.selectionRange) return; var range = editor.selectionRange; var offset = range.startingOffset; var text = (offset == range.endingOffset)? editor.source.split(editor.lineDelimiter)[editor.getLineAtOffset(editor.currentOffset)].replace(/^\s+|\s+$/g, ''): source.substring (offset, range.endingOffset); if (range.startingOffset == range.endingOffset) // when there is no selection offset -= text.length; if (text.length < 1) { alert("Please select your input."); return; } // auto TODO if (text == "td") { editor.applyEdit(offset, range.endingOffset - offset, "// TODO: Need Implementation "); return; } // detect property type var memberType = (text.search(/\(\)/) != -1) ? MEMBER_TYPE_METHOD : MEMBER_TYPE_PROPERTY; // add default access type if (ALL_ACCESS_TYPES.indexOf(text[0]) == -1) text = "+"+text; switch(memberType){ case MEMBER_TYPE_METHOD: // result = generateMethod(text); text = text.replace(text[0], ACCESS_TYPES[text[0]] + " function "); var dataType = text.match(/\:\w+/) if(! dataType) { text += ":void"; } else { dataType = dataType[0].replace(":",""); // parse data type abbrevations if (dataType.length == 1) { var fullDataType = DATA_TYPE_ABBRES[dataType.toLowerCase()] || dataType; // alert("fullDataType :"+fullDataType ); text = text.replace(":"+dataType, ":"+fullDataType); } } text += "\n{\n\n}" ; break; case MEMBER_TYPE_PROPERTY: // get propertyName and data type if(text.indexOf(":") != -1) { var propertyName = text.match(/\w+\:/)[0].replace(/\:/,""); var dataType = text.match(/\:\w+/)[0].replace(":",""); } else { // no input for data type var propertyName = text.match(/\w+/)[0]; var dataType = "* "; } // append declaration var declaration = " var "; if (text.indexOf("$$") != -1) // $$ -> static const { declaration = " static const "; text = text.replace(propertyName, propertyName.toUpperCase()); text = text.replace("$$", ""); } else if(text.indexOf("$") != -1) // $ -> static { declaration = " static var "; text = text.replace("$", ""); } text = text.replace(text[0], ACCESS_TYPES[text[0]] + declaration); // parse data type abbrevations if (dataType.length == 1) { var fullDataType = DATA_TYPE_ABBRES[dataType.toLowerCase()] || dataType; // alert("fullDataType :"+fullDataType ); text = text.replace(":"+dataType, ":"+fullDataType); dataType = fullDataType; } // append default value if required if (text.lastIndexOf("=") == text.length -1 ) { var defaultValue = DATA_TYPE_DEFAULT_VALUES[dataType] || "null" ; text += " "+defaultValue; } if (text.lastIndexOf("n") == text.length -1 ) { var defaultValue = DATA_TYPE_DEFAULT_VALUES[dataType] || " new "+dataType+"()" ; text = text.substr(0,text.lastIndexOf("n"))+defaultValue; } text += ";"; // auto getter and setter if(propertyName[0] == "_") { // alert("// auto getter and setter"); var accessorName = propertyName.substr(1); text += "\n\t\tpublic function get " + accessorName + "():" + dataType + " {"; text += "\n\t\t\treturn " + propertyName + ";"; text += "\n\t\t}\n\n"; text += "\t\tpublic function set " + accessorName + "("+accessorName+":" + dataType + "):void {"; text += "\n\t\t\t" + propertyName + " = "+accessorName+";"; text += "\n\t\t}\n"; } break; } // var result = "public static const " + text + ":String = '" + text.toLowerCase() + "';"; editor.applyEdit(offset, range.endingOffset - offset, text); } [/code] 원래 출처: http://code.google.com/p/yis-eclipse-monkey-scripts-for-flash-builder/
원본 저자: Yi Tan (yi2004@gmail.com)

eclipse monkey

몇가지 불편한거 추가..

setter/getter 이상한거 수정
property:Type= n -> 실행시
property:Type= new Type(); 으로 변환 되는 기능 추가

2010년 9월 10일 금요일

[flex] ContextMenu 기능 정리

1. ContextMenuItem 추가시에 사용하는 이름이 동일하면 한개만 출력된다.

2. ContextMenuItem 추가시에 사용하는 이름이 "삭제","Del" 이런거 전부 안된다.

 

위의 내용들은 디버거 써도 에러도 잡히지도 않는다. ㅡㅡ

 

이걸로 며칠을 고생했는지 ㅠㅠ

 

슬프다.

2010년 8월 12일 목요일

[struts2] struts2 poi excel result

struts2에서 excel를 출력할 경우가 있는데

인터넷 검색결과 내가 하고 싶은 방식으로 되어 있는 소스가 없었다.

 

그래서 spring mvc abstractExcelView를 참고해서 struts2용 AbstractView를 만들었다.

 

 

[code java]package pmis.common.excel; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.Result; import com.opensymphony.xwork2.util.ValueStack; public abstract class AbstractExcelResult implements Result { /** The content type for an Excel response */ private static final String CONTENT_TYPE = "application/vnd.ms-excel"; /** The extension to look for existing templates */ private static final String EXTENSION = ".xls"; private String url; public void setUrl(String url) { this.url = url; } @Override public void execute(ActionInvocation invocation) throws Exception { try { HSSFWorkbook workbook; HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); String requestURI = request.getRequestURI(); workbook = new HSSFWorkbook(); buildExcelDocument(invocation.getStack(), workbook, ServletActionContext.getRequest(), ServletActionContext.getResponse()); // Set the content type. response.setContentType(CONTENT_TYPE); response.setHeader("Content-disposition", "attachment;filename="+StringUtils.defaultIfEmpty(url, StringUtils.substring(requestURI,StringUtils.lastIndexOf(requestURI, "/"), StringUtils.indexOf(requestURI, ".")))+EXTENSION); ServletOutputStream out = response.getOutputStream(); workbook.write(out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } } protected abstract void buildExcelDocument( ValueStack valueStack, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception; protected HSSFCell getCell(HSSFSheet sheet, int row, int col) { HSSFRow sheetRow = sheet.getRow(row); if (sheetRow == null) { sheetRow = sheet.createRow(row); } HSSFCell cell = sheetRow.getCell(col); if (cell == null) { cell = sheetRow.createCell(col); } return cell; } } [/code]

 

위의 소스를 확장해서 각각의 페이지별로 Excel를 만들때는

 

 

[code java]package pmis.system.loginstat; import java.math.BigDecimal; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.apache.poi.hssf.usermodel.HSSFRichTextString; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import pmis.common.excel.AbstractExcelResult; import com.opensymphony.xwork2.util.ValueStack; public class LoginStatExcelResult extends AbstractExcelResult { @Override protected void buildExcelDocument(ValueStack valueStack, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception { //여기에 구현 } } [/code]

 

그리고

xml 페이지에선

result type 선언

[code xml] [/code]

 

action 선언에선

[code xml] [/code]

2010년 8월 3일 화요일

[scala] Scala에서 사용하는 Actor가 ...

http://codemonkeyism.com/actor-myths/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+stephansblog+%28Code+Monkeyism+%7C+Stephans+Blog%29

 

항상 thread safe 하지 않다는 내용이다.

 

Erlang부분까지는 기억이 안 나는데 연결된 링크까지 가서 보게 되면

 

scala에서 사용하는 Actor 모델은 결코 deadlock에 안전하지 않다는 내용이다.

 

정확하게 읽으신 분들이 태클 부탁드립니다.

2010년 6월 24일 목요일

sms

private Cursor getItemsToSync() { 
        ContentResolver r = getContentResolver(); 
        String selection = String.format("%s > ? AND %s <> ?", 
                SmsConsts.DATE, SmsConsts.TYPE); 
        String[] selectionArgs = new String[] { 
                String.valueOf(getMaxSyncedDate()), String.valueOf(SmsConsts.MESSAGE_TYPE_DRAFT) 
        }; 
        String sortOrder = SmsConsts.DATE; 
        return r.query(Uri.parse("content://sms"), null, selection, selectionArgs, sortOrder); 
    } 

2009년 11월 30일 월요일

spring ldap 연동시 authentication method 설정법

spring ldap에선 기본이 Context.SECURITY_AUTHENTICATION 이 simple 이다.

그래서 아래와 같이 만들고

[code java] public class DigestMD5DirContextAuthenticationStrategy implements
DirContextAuthenticationStrategy {
 /*
  * (non-Javadoc)
  * @see org.springframework.ldap.core.support.DirContextAuthenticationStrategy#setupEnvironment(java.util.Hashtable,
  * java.lang.String, java.lang.String)
  */
 public void setupEnvironment(Hashtable env, String userDn, String password) {
  env.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5");
  env.put(Context.SECURITY_PRINCIPAL, userDn);
  env.put(Context.SECURITY_CREDENTIALS, password);
 }  /*
  * (non-Javadoc)
  * @see org.springframework.ldap.core.support.DirContextAuthenticationStrategy#processContextAfterCreation(javax.naming.directory.DirContext,
  * java.lang.String, java.lang.String)
  */
 public DirContext processContextAfterCreation(DirContext ctx, String userDn, String password) {
  return ctx; }
} [/code]

아래와 같이 설정하면 된다.

[code xml] <bean id="digestMD5DirContextAuthenticationStrategy" class="common.ldap.DigestMD5DirContextAuthenticationStrategy"/>
    
     <bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
      <constructor-arg value="연결정보">
      <property name="userDn" value="정보" />
      <property name="password" value="정보" />
      <property name="authenticationStrategy" ref="digestMD5DirContextAuthenticationStrategy" />
  </bean>
 [/code]


 

 

위와 같이 하면 된다.