Difference between revisions of "DocumentHandlerExtension"

From OpenKM Documentation
Jump to: navigation, search
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
Any extension that implements DocumentHandlerExtension will be watching all events fired from document tab
+
Any extension that implements DocumentHandlerExtension will be watching all events fired from document tab.
  
 
== Method ==
 
== Method ==
onChange(DocumentEventConstant event)
+
=== onChange(DocumentEventConstant event) ===
 
 
== onChange(DocumentEventConstant event) ==
 
 
Each time it'll be some new document event the method onChange it'll be fired by OpenKM
 
Each time it'll be some new document event the method onChange it'll be fired by OpenKM
  
Line 10: Line 8:
 
<source lang="java">
 
<source lang="java">
 
public class TabDocumentExample extends TabDocumentExtension implements DocumentHandlerExtension {
 
public class TabDocumentExample extends TabDocumentExtension implements DocumentHandlerExtension {
 
 
VerticalPanel vPanel;
 
VerticalPanel vPanel;
        String lang = "en-GB";
 
 
         String tabText = "Tab - example";
 
         String tabText = "Tab - example";
 
 
Line 26: Line 22:
 
public String getTabText() {
 
public String getTabText() {
 
return tabText;
 
return tabText;
}
 
 
@Override
 
public void langRefresh() {
 
if (lang.equals("en-GB")) {
 
                  tabText = "Tab - example";
 
} else {
 
                  tabText = "Tab - other";
 
                }
 
 
}
 
}
  
Line 46: Line 33:
 
// TODO Auto-generated method stub
 
// TODO Auto-generated method stub
 
 
}
 
 
@Override
 
public void setLang(String code) {
 
lang = code;
 
 
}
 
}
  
Line 78: Line 60:
 
</source>
 
</source>
  
[[Category: OpenKM plugin extensions]]
+
[[Category: Extension Guide]]

Latest revision as of 13:30, 2 December 2010

Any extension that implements DocumentHandlerExtension will be watching all events fired from document tab.

Method

onChange(DocumentEventConstant event)

Each time it'll be some new document event the method onChange it'll be fired by OpenKM

Example

public class TabDocumentExample extends TabDocumentExtension implements DocumentHandlerExtension {
	VerticalPanel vPanel;
        String tabText = "Tab - example";
	
	public TabDocumentExample() {
		HTML html = new HTML("Content tab example");
		vPanel = new VerticalPanel();
		vPanel.add(html);
		
		initWidget(vPanel);
	}

	@Override
	public String getTabText() {
		return tabText;
	}

	@Override
	public void set(GWTDocument doc) {
		// TODO Auto-generated method stub
	}

	@Override
	public void setVisibleButtons(boolean visible) {
		// TODO Auto-generated method stub
		
	}

        @Override
	public void onChange(DocumentEventConstant event) {
		if (event.equals(HasDocumentEvent.DOCUMENT_CHANGED)) {
			Window.alert("document changed - " +event.getType());
		} else if (event.equals(HasDocumentEvent.KEYWORD_ADDED)) {
			Window.alert("keyword added - " +event.getType());
		} else if (event.equals(HasDocumentEvent.KEYWORD_REMOVED)) {
			Window.alert("keyword removed - " +event.getType());
		} else if (event.equals(HasDocumentEvent.CATEGORY_ADDED)) {
			Window.alert("category added - " +event.getType());
		} else if (event.equals(HasDocumentEvent.CATEGORY_REMOVED)) {
			Window.alert("category removed - " +event.getType());
		} else if (event.equals(HasDocumentEvent.TAB_CHANGED)) {
			Window.alert("tab changed - " +event.getType() + " - actual tab " + TabDocumentComunicator.getSelectedTab());
		} else if (event.equals(HasDocumentEvent.PANEL_RESIZED)) {
			Window.alert("panel resized - " +event.getType());
		} else if (event.equals(HasDocumentEvent.SECURITY_CHANGED)) {
			Window.alert("security changed - " +event.getType());
		} else if (event.equals(HasDocumentEvent.NOTE_ADDED)) {
			Window.alert("note added - " +event.getType());
		}
	}
}