List of usage examples for java.util EnumSet allOf
public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
From source file:org.rdv.viz.spectrum.SpectrumViz.java
/** * Initializes the properties panel.//from w w w . j av a 2 s .c om */ private void initPropertiesPanel() { propertiesPanel = new JPanel(); propertiesPanel.setLayout(new SpringLayout()); propertiesPanel.setBorder(BorderFactory.createTitledBorder("Properties")); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { handlePropertiesUpdate((Component) ae.getSource()); } }; FocusAdapter focusListener = new FocusAdapter() { public void focusLost(FocusEvent fe) { handlePropertiesUpdate(fe.getComponent()); } }; propertiesPanel.add(new JLabel("Sample rate: ")); sampleRateTextField = new JTextField(Double.toString(spectrumAnalyzerPanel.getSampleRate())); sampleRateTextField.addActionListener(actionListener); sampleRateTextField.addFocusListener(focusListener); propertiesPanel.add(sampleRateTextField); propertiesPanel.add(new JLabel("Number of points: ")); numberOfSamplesTextField = new JTextField(Integer.toString(spectrumAnalyzerPanel.getNumberOfSamples())); numberOfSamplesTextField.addActionListener(actionListener); numberOfSamplesTextField.addFocusListener(focusListener); propertiesPanel.add(numberOfSamplesTextField); propertiesPanel.add(new JLabel("Window: ")); Object[] windowTypes = EnumSet.allOf(WindowFunction.class).toArray(); windowFunctionComboBox = new JComboBox(windowTypes); windowFunctionComboBox.setSelectedItem(spectrumAnalyzerPanel.getWindowFunction()); windowFunctionComboBox.addActionListener(actionListener); propertiesPanel.add(windowFunctionComboBox); propertiesPanel.add(new JLabel("Size: ")); segmentSizeTextField = new JTextField(Integer.toString(spectrumAnalyzerPanel.getSegmentSize())); segmentSizeTextField.addActionListener(actionListener); segmentSizeTextField.addFocusListener(focusListener); propertiesPanel.add(segmentSizeTextField); propertiesPanel.add(new JLabel("Overlap: ")); overlapTextField = new JTextField(Integer.toString(spectrumAnalyzerPanel.getOverlap())); overlapTextField.addActionListener(actionListener); overlapTextField.addFocusListener(focusListener); propertiesPanel.add(overlapTextField); SpringUtilities.makeCompactGrid(propertiesPanel, 5, 2, 5, 5, 5, 5); panel.add(propertiesPanel, BorderLayout.EAST); }
From source file:org.apache.sentry.policy.indexer.TestIndexerAuthorizationProviderGeneralCases.java
@Test public void testAnalyst() throws Exception { Set<IndexerModelAction> writeOnly = EnumSet.of(IndexerModelAction.WRITE); doTestAuthProviderOnIndexer(SUB_ANALYST, IND_PURCHASES, writeOnly); Set<IndexerModelAction> allActions = EnumSet.allOf(IndexerModelAction.class); doTestAuthProviderOnIndexer(SUB_ANALYST, IND_ANALYST1, allActions); doTestAuthProviderOnIndexer(SUB_ANALYST, IND_JRANALYST1, allActions); Set<IndexerModelAction> readWriteOnly = EnumSet.of(READ, WRITE); doTestAuthProviderOnIndexer(SUB_ANALYST, IND_TMP, readWriteOnly); Set<IndexerModelAction> noActions = EnumSet.noneOf(IndexerModelAction.class); doTestAuthProviderOnIndexer(SUB_ANALYST, IND_PURCHASES_PARTIAL, noActions); }
From source file:com.titankingdoms.dev.titanchat.core.channel.ChannelManager.java
/** * Loads the manager//from w w w .j a v a2 s . c o m */ public void load() { for (Status status : EnumSet.allOf(Status.class)) this.statuses.put(status, new HashMap<String, Channel>()); if (!plugin.getConfig().getBoolean("channels.enable", true)) { registerChannels(new ServerChannel()); return; } registerLoaders(new StandardLoader(), new TemporaryLoader()); registerLoaders(Loader.load(ChannelLoader.class, getLoaderDirectory()).toArray(new ChannelLoader[0])); if (!loaders.isEmpty()) plugin.log(Level.INFO, "ChannelLoaders loaded: " + StringUtils.join(loaders.keySet(), ", ")); for (File file : getChannelDirectory().listFiles(new ExtensionFilter(".yml"))) { String name = file.getName().substring(0, file.getName().lastIndexOf(".yml")); FileConfiguration config = YamlConfiguration.loadConfiguration(file); ChannelLoader loader = getLoader(config.getString("type", "")); if (loader == null) continue; Status status = Status.fromName(config.getString("status", "")); if (status == null) continue; Channel channel = loader.load(name, status, config); if (channel == null) continue; channel.init(); registerChannels(channel); } if (!channels.isEmpty()) plugin.log(Level.INFO, "Channels loaded: " + StringUtils.join(channels.keySet(), ", ")); }
From source file:org.apache.sentry.policy.search.TestSearchAuthorizationProviderGeneralCases.java
@Test public void testAnalyst() throws Exception { Set<SearchModelAction> updateOnly = EnumSet.of(SearchModelAction.UPDATE); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_PURCHASES, updateOnly); Set<SearchModelAction> allActions = EnumSet.allOf(SearchModelAction.class); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_ANALYST1, allActions); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_JRANALYST1, allActions); Set<SearchModelAction> queryUpdateOnly = EnumSet.of(QUERY, UPDATE); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_TMP, queryUpdateOnly); Set<SearchModelAction> noActions = EnumSet.noneOf(SearchModelAction.class); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_PURCHASES_PARTIAL, noActions); }
From source file:org.talend.updates.runtime.model.AbstractExtraFeature.java
@Override public EnumSet<UpdateSiteLocationType> getUpdateSiteCompatibleTypes() { return EnumSet.allOf(UpdateSiteLocationType.class); }
From source file:org.apache.sentry.policy.solr.TestSolrAuthorizationProviderGeneralCases.java
@Test public void testAnalyst() throws Exception { Set<SolrModelAction> updateOnly = EnumSet.of(SolrModelAction.UPDATE); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_PURCHASES, updateOnly); Set<SolrModelAction> allActions = EnumSet.allOf(SolrModelAction.class); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_ANALYST1, allActions); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_JRANALYST1, allActions); Set<SolrModelAction> queryUpdateOnly = EnumSet.of(QUERY, UPDATE); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_TMP, queryUpdateOnly); Set<SolrModelAction> noActions = EnumSet.noneOf(SolrModelAction.class); doTestAuthProviderOnCollection(SUB_ANALYST, COLL_PURCHASES_PARTIAL, noActions); }
From source file:org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryManagerOnTimelineStore.java
@Override public Map<ApplicationAttemptId, ApplicationAttemptReport> getApplicationAttempts(ApplicationId appId) throws YarnException, IOException { ApplicationReportExt app = getApplication(appId, ApplicationReportField.USER_AND_ACLS); checkAccess(app);//from w ww . j a v a 2s . c o m TimelineEntities entities = timelineDataManager.getEntities(AppAttemptMetricsConstants.ENTITY_TYPE, new NameValuePair(AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER, appId.toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); Map<ApplicationAttemptId, ApplicationAttemptReport> appAttempts = new LinkedHashMap<ApplicationAttemptId, ApplicationAttemptReport>(); for (TimelineEntity entity : entities.getEntities()) { ApplicationAttemptReport appAttempt = convertToApplicationAttemptReport(entity); appAttempts.put(appAttempt.getApplicationAttemptId(), appAttempt); } return appAttempts; }
From source file:com.netflix.conductor.server.ConductorServer.java
public synchronized void start(int port, boolean join) throws Exception { if (server != null) { throw new IllegalStateException("Server is already running"); }/* ww w. j a v a 2 s . c o m*/ Guice.createInjector(sm); //Swagger String resourceBasePath = Main.class.getResource("/swagger-ui").toExternalForm(); this.server = new Server(port); ServletContextHandler context = new ServletContextHandler(); context.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class)); context.setResourceBase(resourceBasePath); context.setWelcomeFiles(new String[] { "index.html" }); server.setHandler(context); DefaultServlet staticServlet = new DefaultServlet(); context.addServlet(new ServletHolder(staticServlet), "/*"); server.start(); System.out.println("Started server on http://localhost:" + port + "/"); try { boolean create = Boolean.getBoolean("loadSample"); if (create) { System.out.println("Creating kitchensink workflow"); createKitchenSink(port); } } catch (Exception e) { logger.error(e.getMessage(), e); } if (join) { server.join(); } }
From source file:com.baasbox.configuration.PropertiesConfigurationHelper.java
public static String dumpConfiguration(String section) { Class en = CONFIGURATION_SECTIONS.get(section); try {//w w w .j a v a2 s .co m StringBuilder sb = new StringBuilder(); String enumDescription = ""; Method getEnumDescription = en.getMethod("getEnumDescription"); if (getEnumDescription != null && getEnumDescription.getReturnType() == String.class && Modifier.isStatic(getEnumDescription.getModifiers())) enumDescription = (String) getEnumDescription.invoke(null); sb.append(enumDescription); sb.append("\n"); sb.append(section.toUpperCase()); sb.append("\n"); String lastSection = ""; EnumSet values = EnumSet.allOf(en); for (Object v : values) { String key = (String) ((Method) v.getClass().getMethod("getKey")).invoke(v); Object value = ((Method) en.getMethod("getValue")).invoke(v); String subsection = key.substring(0, key.indexOf('.')); if (!lastSection.equals(subsection)) { sb.append(" - "); sb.append(subsection.toUpperCase()); sb.append("\n"); lastSection = subsection; } sb.append(" + "); sb.append(key); sb.append(" = "); sb.append(value); sb.append("\n"); } return sb.toString(); } catch (Exception e) { BaasBoxLogger.error("Cannot generate a json for " + en.getSimpleName() + " Enum. Is it an Enum that implements the IProperties interface?", e); } return ""; }
From source file:org.photovault.swingui.JAIPhotoViewer.java
/** Finds the best instance of the current photo and shows it. The instance is selected so that it needs as little postprocessing as possible. Hovewer, the operations in {@link dynOps} must not be preapplied in the instance since these may be changing during viewing of the image. //from w w w . j av a 2 s . c o m */ private void showBestInstance() throws PhotovaultException { EnumSet<ImageOperations> allowedOps = EnumSet.allOf(ImageOperations.class); allowedOps.removeAll(dynOps); int w = imageView.getWidth(); int h = imageView.getHeight(); Dimension croppedSize = photo.getCroppedSize(); double ar = croppedSize.getWidth() / croppedSize.getHeight(); if (w > ar * h) { w = (int) (h * ar); } else { h = (int) (w / ar); } ImageDescriptorBase image = photo.getPreferredImage(EnumSet.noneOf(ImageOperations.class), allowedOps, w, h, Integer.MAX_VALUE, Integer.MAX_VALUE); if (image != null && image.getLocator().equals("image#0")) { File imageFile = image.getFile().findAvailableCopy(); if (imageFile != null && imageFile.canRead()) { // TODO: is this really needed? String fname = imageFile.getName(); int lastDotPos = fname.lastIndexOf("."); if (lastDotPos <= 0 || lastDotPos >= fname.length() - 1) { // TODO: error handling needs thinking!!!! // throw new IOException( "Cannot determine file type extension of " + imageFile.getAbsolutePath() ); fireViewChangeEvent(); return; } PhotovaultImageFactory imageFactory = new PhotovaultImageFactory(); PhotovaultImage img = null; try { /* Do not read the image yet since setting raw conversion parameters later may force a re-read. */ img = imageFactory.create(imageFile, false, false); } catch (PhotovaultException ex) { final JAIPhotoViewer component = this; final String msg = ex.getMessage(); SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(component, msg, "Error loading file", JOptionPane.ERROR_MESSAGE); } }); } if (img != null) { appliedOps = EnumSet.noneOf(ImageOperations.class); if (rawImage != null) { rawImage.removeChangeListener(this); } if (img instanceof RawImage) { rawImage = (RawImage) img; rawImage.setRawSettings( localRawSettings != null ? localRawSettings : photo.getRawSettings()); rawImage.addChangeListener(this); // Check the correct resolution for this image if (isFit) { fit(); } else { setScale(getScale()); } } else { rawImage = null; rawConvScaling = 1.0f; } } if (image instanceof CopyImageDescriptor) { // This is a copy, so it may be cropped already appliedOps = ((CopyImageDescriptor) image).getAppliedOperations(); if (!appliedOps.contains(ImageOperations.COLOR_MAP)) { img.setColorAdjustment( localChanMap != null ? localChanMap : photo.getColorChannelMapping()); } if (!appliedOps.contains(ImageOperations.CROP)) { instanceRotation = ((CopyImageDescriptor) image).getRotation(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation(rot); imageView.setCrop(photo.getCropBounds()); } } else { // This is original so we must apply corrections img.setColorAdjustment(localChanMap != null ? localChanMap : photo.getColorChannelMapping()); imageView.setRotation(photo.getPrefRotation()); imageView.setCrop(photo.getCropBounds()); } setImage(img); fireViewChangeEvent(); return; } } // if we get this far no instance of the original image has been found setImage(null); throw new PhotovaultException("No suitable instance of photo " + photo.getUuid() + " found"); }