Difference between revisions of "TabWorkspaceExtension"

From OpenKM Documentation
Jump to: navigation, search
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Methods ==
 
== Methods ==
getTabText()
+
=== getTabText ===
getExtensionUUID()
+
Used by OpenKM to get the tab text.
  
== getTabText ==
+
=== setTab(TabBar tabBar, int tabIndex) ===
Used by OpenKM to get the tab text.
+
Used by openkm to set tabBar and tab index.
  
== getExtensionUUID() ==
+
=== getExtensionUUID() ===
 
Return the unique extension id
 
Return the unique extension id
  
Line 12: Line 12:
 
<source lang="java">
 
<source lang="java">
 
public class TabWorkspaceExample extends TabWorkspaceExtension {
 
public class TabWorkspaceExample extends TabWorkspaceExtension {
 
 
private VerticalPanel vPanel;
 
private VerticalPanel vPanel;
 
 
Line 31: Line 30:
 
return "tab workspace";
 
return "tab workspace";
 
}
 
}
 +
 +
        @Override
 +
public void setTab(TabBar tabBar, int tabIndex) {
 +
}
 +
 +
        @Override
 +
public String getExtensionUUID() {
 +
return String.valueOf("44f94470-d097-11df-bd3b-0800200c9a66");
 +
}
 +
}
 +
</source>
  
 +
 +
== Example with iframe ==
 +
<source lang="java">
 +
public class TabWorkspace extends TabWorkspaceExtension {
 +
private VerticalPanel vPanel;
 +
private Frame iframe;
 +
private String textLabel = "";
 +
private TabBar tabBar;
 +
private int tabIndex = 0;
 +
 +
/**
 +
* TabWorkspace
 +
*/
 +
public TabWorkspace() {
 +
vPanel = new VerticalPanel();
 +
iframe = new Frame("about:blank");
 +
 +
DOM.setElementProperty(iframe.getElement(), "frameborder", "0");
 +
DOM.setElementProperty(iframe.getElement(), "marginwidth", "0");
 +
DOM.setElementProperty(iframe.getElement(), "marginheight", "0");
 +
 +
// Commented because on IE show clear if allowtransparency=true
 +
DOM.setElementProperty(iframe.getElement(), "allowtransparency", "false");
 +
DOM.setElementProperty(iframe.getElement(), "scrolling", "no");
 +
 +
iframe.setUrl(Main.CONTEXT + "/sample/index.jsp");
 +
iframe.setStyleName("okm-Iframe");
 +
 +
vPanel.add(iframe);
 +
vPanel.setCellHorizontalAlignment(iframe, HasAlignment.ALIGN_CENTER);
 +
 +
vPanel.setWidth("100%");
 +
vPanel.setHeight("100%");
 +
 +
initWidget(vPanel);
 +
}
 +
 +
/**
 +
* Sets the size on initialization
 +
*
 +
* @param width The max width of the widget
 +
* @param height The max height of the widget
 +
*/
 +
public void setPixelSize(int width, int height) {
 +
iframe.setPixelSize(width - 2, height - 2);
 +
}
 +
 +
/**
 +
* setTextLabel
 +
*/
 +
public void setTextLabel(String textLabel) {
 +
this.textLabel = textLabel;
 +
}
 +
 +
@Override
 +
public String getTabText() {
 +
return textLabel;
 +
}
 +
 +
@Override
 +
public void setTab(TabBar tabBar, int tabIndex) {
 +
this.tabBar = tabBar;
 +
this.tabIndex = tabIndex;
 +
}
 +
 
         @Override
 
         @Override
 
public String getExtensionUUID() {
 
public String getExtensionUUID() {
Line 39: Line 114:
 
</source>
 
</source>
  
[[Category: OpenKM plugin extensions]]
+
[[Category: Extension Guide]]

Latest revision as of 11:13, 31 December 2013

Methods

getTabText

Used by OpenKM to get the tab text.

setTab(TabBar tabBar, int tabIndex)

Used by openkm to set tabBar and tab index.

getExtensionUUID()

Return the unique extension id

Example

public class TabWorkspaceExample extends TabWorkspaceExtension {
	private VerticalPanel vPanel;
	
	/**
	 * TabWorkspaceExample
	 */
	public TabWorkspaceExample() {
		vPanel = new VerticalPanel();
		vPanel.add(new HTML("new workspace example"));
		
		vPanel.setStyleName("okm-Input");
		
		initWidget(vPanel);
	}

	@Override
	public String getTabText() {
		return "tab workspace";
	}
 
        @Override
	public void setTab(TabBar tabBar, int tabIndex) {
	}

        @Override
	public String getExtensionUUID() {
		return String.valueOf("44f94470-d097-11df-bd3b-0800200c9a66");
	}
}


Example with iframe

public class TabWorkspace extends TabWorkspaceExtension {
	private VerticalPanel vPanel;
	private Frame iframe;
	private String textLabel = "";
	private TabBar tabBar;
	private int tabIndex = 0;
	
	/**
	 * TabWorkspace
	 */
	public TabWorkspace() {
		vPanel = new VerticalPanel();
		iframe = new Frame("about:blank");
		
		DOM.setElementProperty(iframe.getElement(), "frameborder", "0");
		DOM.setElementProperty(iframe.getElement(), "marginwidth", "0");
		DOM.setElementProperty(iframe.getElement(), "marginheight", "0");
		
		// Commented because on IE show clear if allowtransparency=true
		DOM.setElementProperty(iframe.getElement(), "allowtransparency", "false");
		DOM.setElementProperty(iframe.getElement(), "scrolling", "no");
		
		iframe.setUrl(Main.CONTEXT + "/sample/index.jsp");
		iframe.setStyleName("okm-Iframe");
		
		vPanel.add(iframe);
		vPanel.setCellHorizontalAlignment(iframe, HasAlignment.ALIGN_CENTER);
		
		vPanel.setWidth("100%");
		vPanel.setHeight("100%");
		
		initWidget(vPanel);
	}
	
	/**
	 * Sets the size on initialization
	 * 
	 * @param width The max width of the widget
	 * @param height The max height of the widget
	 */
	public void setPixelSize(int width, int height) {
		iframe.setPixelSize(width - 2, height - 2);
	}
	
	/**
	 * setTextLabel
	 */
	public void setTextLabel(String textLabel) {
		this.textLabel = textLabel;
	}
	
	@Override
	public String getTabText() {
		return textLabel;
	}
	
	@Override
	public void setTab(TabBar tabBar, int tabIndex) {
		this.tabBar = tabBar;
		this.tabIndex = tabIndex;
	}
	
        @Override
	public String getExtensionUUID() {
		return String.valueOf("44f94470-d097-11df-bd3b-0800200c9a66");
	}
}