/** Creates new form QueueView */ public QueueView( ScanService scanService, EventManager eventManager, QueueManager queueProcessor, Queue queue, Repo repo) { this.queue = queue; this.scanService = scanService; this.repo = repo; this.queueProcessor = queueProcessor; this.eventManager = eventManager; this.setTitle("Queue: " + repo.getDescription()); initComponents(); TableUtils.setTimeColumn(tblQueue, "Started"); TableUtils.setTimeColumn(tblQueue, "Completed"); // TableRowSorter rowSorter = new TableRowSorter( tblQueue.getModel()); // tblQueue.setRowSorter( rowSorter ); File scanDir = scanService.getCurrentScanDir(); if (scanDir != null) { lblCurrentDirVal.setText(scanDir.getAbsolutePath()); } eventManager.registerEventListener(this, ScanDirEvent.class); eventManager.registerEventListener(this, ScanEvent.class); eventManager.registerEventListener(this, QueueProcessEvent.class); ImageIcon imageIcon = new ImageIcon(getClass().getResource("/logo16x16.png"), ""); setIconImage(imageIcon.getImage()); showNextScan(); initCurrent(); }
/** * Accessor for the candidate keys for this table. * * @return The indices */ protected List getExpectedCandidateKeys() { // The indices required by foreign keys (BaseTable) List candidateKeys = super.getExpectedCandidateKeys(); if (keyMapping instanceof EmbeddedKeyPCMapping) { // Add all candidate keys required by fields of the embedded key EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping) keyMapping; for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) { JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i); UniqueMetaData umd = embFieldMapping.getMemberMetaData().getUniqueMetaData(); if (umd != null) { CandidateKey ck = TableUtils.getCandidateKeyForField(this, umd, embFieldMapping); if (ck != null) { candidateKeys.add(ck); } } } } else if (mmd.getKeyMetaData() != null) { UniqueMetaData unimd = mmd.getKeyMetaData().getUniqueMetaData(); if (unimd != null) { CandidateKey ck = TableUtils.getCandidateKeyForField(this, unimd, keyMapping); if (ck != null) { candidateKeys.add(ck); } } } if (valueMapping instanceof EmbeddedValuePCMapping) { // Add all candidate keys required by fields of the embedded value EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping) valueMapping; for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) { JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i); UniqueMetaData umd = embFieldMapping.getMemberMetaData().getUniqueMetaData(); if (umd != null) { CandidateKey ck = TableUtils.getCandidateKeyForField(this, umd, embFieldMapping); if (ck != null) { candidateKeys.add(ck); } } } } else if (mmd.getValueMetaData() != null) { UniqueMetaData unimd = mmd.getValueMetaData().getUniqueMetaData(); if (unimd != null) { CandidateKey ck = TableUtils.getCandidateKeyForField(this, unimd, valueMapping); if (ck != null) { candidateKeys.add(ck); } } } return candidateKeys; }
public Component getDemoPanel() { TableModel model = new SampleTableModel(); _sortableTable = new SortableTable(model); _sortableTable.setAutoResizeMode(JideTable.AUTO_RESIZE_FILL); _sortableTable.setNestedTableHeader(true); _sortableTable.setFillsGrids(false); TableColumnGroup longText = new TableColumnGroup( "This is a very long column header title. You can resize the table header column and see how this long text automatically wraps according to the column width. " + "The current configuration specified {minimum two rows:f:red} and {maximum five rows:f:blue}. You could take a look at StyledLabelBuilderDemo to see what other annotations are available in the text.@r:3:2:5"); longText.add(_sortableTable.getColumnModel().getColumn(0)); longText.add(_sortableTable.getColumnModel().getColumn(1)); longText.add(_sortableTable.getColumnModel().getColumn(2)); longText.add(_sortableTable.getColumnModel().getColumn(3)); longText.add(_sortableTable.getColumnModel().getColumn(4)); longText.add(_sortableTable.getColumnModel().getColumn(5)); longText.add(_sortableTable.getColumnModel().getColumn(6)); if (_sortableTable.getTableHeader() instanceof NestedTableHeader) { NestedTableHeader header = (NestedTableHeader) _sortableTable.getTableHeader(); header.addColumnGroup(longText); } TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(_sortableTable); installer.addTableHeaderPopupMenuCustomizer(new TableColumnChooserPopupMenuCustomizer()); TableUtils.autoResizeAllColumns(_sortableTable); return new JScrollPane(_sortableTable); }
@Override protected void processFacetsAndChildren(FacesContext context, PhaseId phaseId) { Object oldPath = getRowKey(); HierarchyUtils.__setStartDepthPath(this, getLevel()); // process stamp for one level HierarchyUtils.__processLevel(context, phaseId, this); setRowKey(oldPath); // process the children TableUtils.__processChildren(context, this, phaseId); }
/** * Accessor for the indices for this table. This includes both the user-defined indices (via * MetaData), and the ones required by foreign keys (required by relationships). * * @param clr The ClassLoaderResolver * @return The indices */ protected Set getExpectedIndices(ClassLoaderResolver clr) { // The indices required by foreign keys (BaseTable) Set indices = super.getExpectedIndices(clr); if (keyMapping instanceof EmbeddedKeyPCMapping) { // Add all indices required by fields of the embedded key EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping) keyMapping; for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) { JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i); IndexMetaData imd = embFieldMapping.getMemberMetaData().getIndexMetaData(); if (imd != null) { Index index = TableUtils.getIndexForField(this, imd, embFieldMapping); if (index != null) { indices.add(index); } } } } if (valueMapping instanceof EmbeddedValuePCMapping) { // Add all indices required by fields of the embedded value EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping) valueMapping; for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) { JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i); IndexMetaData imd = embFieldMapping.getMemberMetaData().getIndexMetaData(); if (imd != null) { Index index = TableUtils.getIndexForField(this, imd, embFieldMapping); if (index != null) { indices.add(index); } } } } return indices; }
private TableEntity(DbManager db, Class<T> entityType) throws Throwable { this.db = db; this.entityType = entityType; this.constructor = entityType.getConstructor(); this.constructor.setAccessible(true); Table table = entityType.getAnnotation(Table.class); this.tableName = table.name(); this.runOnTableCreated = table.runOnTableCreated(); this.columnMap = TableUtils.findColumnMap(entityType); for (ColumnEntity column : columnMap.values()) { if (column.isId()) { this.id = column; } } }
@RequestMapping(value = "/jobs/{jobName}", method = RequestMethod.GET) public String details( ModelMap model, @ModelAttribute("jobName") String jobName, Errors errors, @RequestParam(defaultValue = "0") int startJobInstance, @RequestParam(defaultValue = "20") int pageSize) { boolean launchable = jobService.isLaunchable(jobName); try { Collection<JobInstance> result = jobService.listJobInstances(jobName, startJobInstance, pageSize); Collection<JobInstanceInfo> jobInstances = new ArrayList<JobInstanceInfo>(); model.addAttribute( "jobParameters", jobParametersExtractor.fromJobParameters(jobService.getLastJobParameters(jobName))); for (JobInstance jobInstance : result) { Collection<JobExecution> jobExecutions = jobService.getJobExecutionsForJobInstance(jobName, jobInstance.getId()); jobInstances.add(new JobInstanceInfo(jobInstance, jobExecutions, timeZone)); } model.addAttribute("jobInstances", jobInstances); int total = jobService.countJobInstances(jobName); TableUtils.addPagination(model, total, startJobInstance, pageSize, "JobInstance"); int count = jobService.countJobExecutionsForJob(jobName); model.addAttribute( "jobInfo", new JobInfo(jobName, count, launchable, jobService.isIncrementable(jobName))); } catch (NoSuchJobException e) { errors.reject( "no.such.job", new Object[] {jobName}, "There is no such job (" + HtmlUtils.htmlEscape(jobName) + ")"); } return "jobs/job"; }
@RequestMapping(value = "/jobs", method = RequestMethod.GET) public void jobs( ModelMap model, @RequestParam(defaultValue = "0") int startJob, @RequestParam(defaultValue = "20") int pageSize) { int total = jobService.countJobs(); TableUtils.addPagination(model, total, startJob, pageSize, "Job"); Collection<String> names = jobService.listJobs(startJob, pageSize); List<JobInfo> jobs = new ArrayList<JobInfo>(); for (String name : names) { int count = 0; try { count = jobService.countJobExecutionsForJob(name); } catch (NoSuchJobException e) { // shouldn't happen } boolean launchable = jobService.isLaunchable(name); boolean incrementable = jobService.isIncrementable(name); jobs.add(new JobInfo(name, count, null, launchable, incrementable)); } model.addAttribute("jobs", jobs); }
@Override public void setValue2Entity(Object entity, Cursor cursor, int index) { Object value = null; Class<?> columnType = columnField.getType(); Object finderValue = TableUtils.getColumnOrId(entity.getClass(), this.valueColumnName).getColumnValue(entity); if (columnType.equals(FinderLazyLoader.class)) { value = new FinderLazyLoader(this, finderValue); } else if (columnType.equals(List.class)) { try { value = new FinderLazyLoader(this, finderValue).getAllFromDb(); } catch (DbException e) { LogUtils.e(e.getMessage(), e); } } else { try { value = new FinderLazyLoader(this, finderValue).getFirstFromDb(); } catch (DbException e) { LogUtils.e(e.getMessage(), e); } } if (setMethod != null) { try { setMethod.invoke(entity, value); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } } else { try { this.columnField.setAccessible(true); this.columnField.set(entity, value); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } } }
/** * Accessor for the indices for this table. This includes both the user-defined indices (via * MetaData), and the ones required by foreign keys. * * @param clr The ClassLoaderResolver * @return The indices */ protected Set getExpectedIndices(ClassLoaderResolver clr) { Set indices = new HashSet(); // Index for FK back to owner if (mmd.getIndexMetaData() != null) { Index index = TableUtils.getIndexForField(this, mmd.getIndexMetaData(), ownerMapping); if (index != null) { indices.add(index); } } else if (mmd.getJoinMetaData() != null && mmd.getJoinMetaData().getIndexMetaData() != null) { Index index = TableUtils.getIndexForField(this, mmd.getJoinMetaData().getIndexMetaData(), ownerMapping); if (index != null) { indices.add(index); } } else { // Fallback to an index for the foreign-key to the owner Index index = TableUtils.getIndexForField(this, null, ownerMapping); if (index != null) { indices.add(index); } } // Index for the key FK (if required) if (keyMapping instanceof EmbeddedKeyPCMapping) { // Add all indices required by fields of the embedded key EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping) keyMapping; for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) { JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i); IndexMetaData imd = embFieldMapping.getMemberMetaData().getIndexMetaData(); if (imd != null) { Index index = TableUtils.getIndexForField(this, imd, embFieldMapping); if (index != null) { indices.add(index); } } } } else { KeyMetaData keymd = mmd.getKeyMetaData(); if (keymd != null && keymd.getIndexMetaData() != null) { IndexMetaData idxmd = mmd.getKeyMetaData().getIndexMetaData(); Index index = TableUtils.getIndexForField(this, idxmd, keyMapping); if (index != null) { indices.add(index); } } else { // Fallback to an index for any foreign-key to the key if (keyMapping instanceof PersistableMapping) { Index index = TableUtils.getIndexForField(this, null, keyMapping); if (index != null) { indices.add(index); } } } } // Index for the value FK (if required) if (valueMapping instanceof EmbeddedValuePCMapping) { // Add all indices required by fields of the embedded value EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping) valueMapping; for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) { JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i); IndexMetaData imd = embFieldMapping.getMemberMetaData().getIndexMetaData(); if (imd != null) { Index index = TableUtils.getIndexForField(this, imd, embFieldMapping); if (index != null) { indices.add(index); } } } } else { ValueMetaData valmd = mmd.getValueMetaData(); if (valmd != null && valmd.getIndexMetaData() != null) { IndexMetaData idxmd = mmd.getValueMetaData().getIndexMetaData(); Index index = TableUtils.getIndexForField(this, idxmd, valueMapping); if (index != null) { indices.add(index); } } else { // Fallback to an index for any foreign-key to the value if (valueMapping instanceof PersistableMapping) { Index index = TableUtils.getIndexForField(this, null, valueMapping); if (index != null) { indices.add(index); } } } } return indices; }
/** * Accessor for the expected foreign keys for this table. * * @param clr The ClassLoaderResolver * @return The expected foreign keys. */ public List getExpectedForeignKeys(ClassLoaderResolver clr) { assertIsInitialized(); boolean autoMode = false; if (storeMgr .getStringProperty(RDBMSPropertyNames.PROPERTY_RDBMS_CONSTRAINT_CREATE_MODE) .equals("DataNucleus")) { autoMode = true; } ArrayList foreignKeys = new ArrayList(); try { // FK from join table to owner table DatastoreClass referencedTable = storeMgr.getDatastoreClass(ownerType, clr); if (referencedTable != null) { // Take <foreign-key> from <join> ForeignKeyMetaData fkmd = null; if (mmd.getJoinMetaData() != null) { fkmd = mmd.getJoinMetaData().getForeignKeyMetaData(); } if (fkmd != null || autoMode) { ForeignKey fk = new ForeignKey(ownerMapping, dba, referencedTable, true); fk.setForMetaData(fkmd); foreignKeys.add(fk); } } if (!isSerialisedValuePC()) { if (isEmbeddedValuePC()) { // Add any FKs for the fields of the (embedded) value EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping) valueMapping; for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) { JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i); AbstractMemberMetaData embFmd = embFieldMapping.getMemberMetaData(); if (ClassUtils.isReferenceType(embFmd.getType()) && embFieldMapping instanceof ReferenceMapping) { // Field is a reference type, so add a FK to the table of the PC for each PC // implementation Collection fks = TableUtils.getForeignKeysForReferenceField( embFieldMapping, embFmd, autoMode, storeMgr, clr); foreignKeys.addAll(fks); } else if (storeMgr .getNucleusContext() .getMetaDataManager() .getMetaDataForClass(embFmd.getType(), clr) != null && embFieldMapping.getNumberOfDatastoreMappings() > 0 && embFieldMapping instanceof PersistableMapping) { // Field is for a PC class with the FK at this side, so add a FK to the table of this // PC ForeignKey fk = TableUtils.getForeignKeyForPCField( embFieldMapping, embFmd, autoMode, storeMgr, clr); if (fk != null) { foreignKeys.add(fk); } } } } else if (mmd.getMap().valueIsPersistent()) { // FK from join table to value table referencedTable = storeMgr.getDatastoreClass(mmd.getMap().getValueType(), clr); if (referencedTable != null) { // Take <foreign-key> from <value> ForeignKeyMetaData fkmd = null; if (mmd.getValueMetaData() != null) { fkmd = mmd.getValueMetaData().getForeignKeyMetaData(); } if (fkmd != null || autoMode) { ForeignKey fk = new ForeignKey(valueMapping, dba, referencedTable, true); fk.setForMetaData(fkmd); foreignKeys.add(fk); } } } } if (!isSerialisedKeyPC()) { if (isEmbeddedKeyPC()) { // Add any FKs for the fields of the (embedded) key EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping) keyMapping; for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) { JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i); AbstractMemberMetaData embFmd = embFieldMapping.getMemberMetaData(); if (ClassUtils.isReferenceType(embFmd.getType()) && embFieldMapping instanceof ReferenceMapping) { // Field is a reference type, so add a FK to the table of the PC for each PC // implementation Collection fks = TableUtils.getForeignKeysForReferenceField( embFieldMapping, embFmd, autoMode, storeMgr, clr); foreignKeys.addAll(fks); } else if (storeMgr .getNucleusContext() .getMetaDataManager() .getMetaDataForClass(embFmd.getType(), clr) != null && embFieldMapping.getNumberOfDatastoreMappings() > 0 && embFieldMapping instanceof PersistableMapping) { // Field is for a PC class with the FK at this side, so add a FK to the table of this // PC ForeignKey fk = TableUtils.getForeignKeyForPCField( embFieldMapping, embFmd, autoMode, storeMgr, clr); if (fk != null) { foreignKeys.add(fk); } } } } else if (mmd.getMap().keyIsPersistent()) { // FK from join table to key table referencedTable = storeMgr.getDatastoreClass(mmd.getMap().getKeyType(), clr); if (referencedTable != null) { // Take <foreign-key> from <key> ForeignKeyMetaData fkmd = null; if (mmd.getKeyMetaData() != null) { fkmd = mmd.getKeyMetaData().getForeignKeyMetaData(); } if (fkmd != null || autoMode) { ForeignKey fk = new ForeignKey(keyMapping, dba, referencedTable, true); fk.setForMetaData(fkmd); foreignKeys.add(fk); } } } } } catch (NoTableManagedException e) { // expected when no table exists } return foreignKeys; }