List of usage examples for com.vaadin.ui TabSheet getCaption
@Override
public String getCaption()
From source file:org.apache.openaz.xacml.admin.components.PolicyWorkspace.java
License:Apache License
protected void initializeTree() { ///*www . ja v a 2s . c o m*/ // This is where the user's Git repository is located // final Path gitPath = ((XacmlAdminUI) UI.getCurrent()).getUserGitPath(); // // Create our Git file system container // this.treeContainer = new GitRepositoryContainer(gitPath, gitPath.toFile()); // // Create our own filter to filter out File extensions and // also the Git directory. // this.treeContainer.setFilter(new FilenameFilter() { @Override public boolean accept(File dir, String name) { // // We don't want any of the hidden files // if (name.startsWith(".git") || name.equals(".DS_Store")) { return false; } // // We definitely want xml files // if (name.endsWith(".xml")) { return true; } // // We should test if its a directory, we want those // included. // Path path = Paths.get(dir.getAbsolutePath(), name); if (Files.isDirectory(path)) { return true; } logger.warn("Filtering out: " + path.toString()); return false; } }); // // Set TreeTables datasource as our git container // this.treeWorkspace.setContainerDataSource(this.treeContainer); // // Setup other properties etc. // this.treeWorkspace.setItemIconPropertyId("Icon"); this.treeWorkspace.setVisibleColumns(new Object[] { "Name", "Version", "Size", "Last Modified", "Status" }); this.treeWorkspace.setSizeFull(); this.treeWorkspace.setSelectable(true); this.treeWorkspace.setEditable(false); // // Expand the first couple of directories // for (Object id : this.treeWorkspace.getItemIds()) { this.treeWorkspace.setCollapsed(id, false); for (Object child : this.treeWorkspace.getChildren(id)) { this.treeWorkspace.setCollapsed(child, false); } } // // Respond to table selections // /* this.treeWorkspace.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { File selection = (File) self.treeWorkspace.getValue(); if (selection != null) { self.buttonImport.setEnabled(selection.isDirectory()); self.buttonExport.setEnabled(selection.isFile()); } else { } } }); */ this.treeWorkspace.addItemClickListener(new ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick() && event.getItemId() instanceof File && ((File) event.getItemId()).isFile()) { self.openPolicyTab((File) event.getItemId(), true); } } }); // // Setup our action handlers // this.treeWorkspace.addActionHandler(new Handler() { private static final long serialVersionUID = 1L; @Override public Action[] getActions(Object target, Object sender) { if (target == null) { // // Nothing is selected, they right-clicked empty space // return new Action[] { SYNCHRONIZE_REPOSITORY, EXPORT_REPOSITORY, CREATE_SUBDOMAIN }; } if (!(target instanceof File)) { return null; } if (((File) target).isDirectory()) { // // Selected a directory // return new Action[] { CREATE_SUBDOMAIN, RENAME_SUBDOMAIN, DELETE_SUBDOMAIN, CREATE_NEWPOLICY, IMPORT_POLICY, PUSH_CHANGES }; } if (((File) target).isFile()) { // // Selected a policy file // return new Action[] { VIEW_POLICY, EDIT_POLICY, CLONE_POLICY, EXPORT_POLICY, RENAME_POLICY, DELETE_POLICY, PUSH_CHANGES }; } return null; } @Override public void handleAction(Action action, Object sender, Object target) { if (action == SYNCHRONIZE_REPOSITORY) { self.synchronizeRepository(); return; } if (action == EXPORT_REPOSITORY) { self.exportRepository(); return; } if (action == PUSH_CHANGES) { self.pushChanges((File) target); return; } if (action == CREATE_SUBDOMAIN) { self.editSubDomain((File) target, null); return; } if (action == RENAME_SUBDOMAIN) { self.editSubDomain((File) self.treeWorkspace.getParent(target), ((File) target).getName()); return; } if (action == CREATE_NEWPOLICY) { self.createPolicy((File) target); return; } if (action == RENAME_POLICY) { self.renamePolicy((File) target); return; } if (action == IMPORT_POLICY) { self.importPolicy((File) target); return; } if (action == DELETE_SUBDOMAIN) { self.deleteSubDomain((File) target); return; } if (action == CLONE_POLICY) { self.clonePolicy((File) target); return; } if (action == VIEW_POLICY) { self.openPolicyTab((File) target, true); return; } if (action == EDIT_POLICY) { self.openPolicyTab((File) target, false); return; } if (action == EXPORT_POLICY) { return; } if (action == DELETE_POLICY) { self.deletePolicy((File) target); return; } } }); // // Set the drop handler // this.treeWorkspace.setDragMode(TableDragMode.ROW); this.treeWorkspace.setDropHandler(this); // // Detect when a tab closes and remove it from the // tab sheet. // this.tabSheet.setCloseHandler(new CloseHandler() { private static final long serialVersionUID = 1L; @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { logger.info("tabsheet closing: " + tabsheet.getCaption()); tabsheet.removeTab(tabsheet.getTab(tabContent)); } }); }