This question already has answers here:
IntelliJ: Never use wildcard imports
(14 answers)
Closed 5 years ago.
Goal:
Say I have a line of code: payout.setPayoutStatusType(PayoutStatusType.REJECTED); but PayoutStatusType is not imported in the models which currently look like this:
import models.ApprovedLead;
import models.IdentityProviderType;
import models.ImportJob;
import models.ImportJobStatus;
import models.Offer;
import models.OfferSource;
import models.OfferViewedStatus;
import models.PaymentAccount;
import models.PaymentAccountType;
import models.PayoutStatusType;
import models.Payout;
import models.PendingPayout;
import models.RawOffer;
import models.User;
import models.UserDevice;
import models.UserDeviceType;
import models.UserOffer;
My issue is if I click on PayoutStatusType, and have it create the import for this it will remove all the static imports, and just do it in one line: import models.* which I don't want it to do.
My question is this: How do I set up my IDE which is Intellij to just make it import models.PayoutStatusType
You can configure the threshold above which IntelliJ starts to 'import *':
Preferences > Editor > Code Style > Java > Imports > Class count to use import with '*'
It looks like your latest import has exceeded this threshold thereby causing IntelliJ to collapse numerous imports under a *.
Related
I got this error when I was launching my app in the emulator does anybody know whats wrong sorry I am kind of new to android studio
lib/Pages/ChattingPage.dart:15:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
But I did everything correctly it's RIGHT THERE
import 'dart:async';
import 'dart:io' as io;
import 'package:file/file.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:telegramchatapp/Widgets/FullImageWidget.dart';
import 'package:telegramchatapp/Widgets/ProgressWidget.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'dart:html' as html;
You can not import dart:html in app for mobile (android or iOS). Remove it.
If you want use it for web application, you can use conditional import explained here.
I am using iText 7 and I am trying to set the background color of my pdf table.
Cell cell = new Cell(1, 3)
.add((IBlockElement) new Paragraph("This is a header"))
.setFont(f)
.setFontSize(13)
.setFontColor(DeviceGray.WHITE)
.setBackgroundColor(DeviceGray.BLACK)
.setTextAlignment(TextAlignment.CENTER);
But DeviceGray.WHITE and DeviceGray.BLACK give errors saying that they are not compatible. The message says that setBackgroundColor(com.itextpdf.kernel.colors.color) cannot be applied to com.itextpdf.kernel.color.DeviceGray
I also have the following imports
import com.itextpdf.io.font.constants.StandardFonts;
import com.itextpdf.kernel.color.DeviceGray;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.geom.PageSize;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Cell;
import com.itextpdf.layout.element.IBlockElement;
import com.itextpdf.layout.element.Paragraph;
import com.itextpdf.layout.element.Table;
import com.itextpdf.layout.property.TextAlignment;
import com.itextpdf.layout.property.UnitValue;
I realized the cause of my problem was mixing versions of io, kernel and layout. Set all of them to 7.1.10 and it works.
I have an app. Which is in RC state. I've started finalizing works by splitting the classes to separate files with appropriate import sets at another location but suddenly I've found that cleaner version cannot read from any folder. So I investigated that if I compile the code in another location except the actual (original) app cannot read from any folder.
Strange is that from folders from those cannot be read can be obtained path (subdirectories included).
I have packed this app to executable jar file before started this works. Maybe somewhere in JVM is something stuck?
Note: New files are compiled without error. I've tried both original source and new sources.
Failure is in methods File.list() or File.listFiles(). The same using directory stream.
Used packages:
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.LineNumberReader;
import java.io.FileReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.FilenameFilter;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.UnsupportedLookAndFeelException;
For sure at this part:
private void loadFiles(){
cesta=folderPicker.getSelectedFile();
if(folder==null||loadedCesta!=cesta||(cesta==folderPicker.getSelectedFile()&vetsiPismoVisible==true)){
folder=new File(cesta.getName());
String datFiles[]=folder.list(new FilenameFilter() {
public boolean accept(File folder, String fileName) {
return fileName.endsWith(".dat");}});
If I try:
folder.canRead()
on every folder on my PC and also e.g.on my workstation these new compilations get false as a result. Variable:
folderPicker
is reffering to JFileChooser that is limited to folders and folders are obtained via actionListener of special JButton (not classic Open and Cancel). You can try it from Karolina_RC.jar from link provided in commentary under conditions said.
Problem solved. For some reason is no longer possible to use only folder name to make File type (folder). Now it is required to use path.
E.g.
File folder=new File(path.getName());
File folder=new File(path.getPath());
Former no longer working. Latter does. I am guessing some JVM-compile issue.
I want to load a drl file at runtime. The posts I've found including this one work for version 5.0 but I can't figure out how to do it for drools version 6.0.
In Drools 6, your rules packages are deployed to Maven. A KieScanner is provided, which you can attach to your KieContainer. This polls your repository at a defined interval to see whether a package has been updated and downloads the latest if that's the case.
A full explanation of how to define a KieScanner (including code samples) is provided in the Drools documentation here:
https://docs.jboss.org/drools/release/latest/drools-docs/html/ch04.html
I used info taken from those two docs:
https://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html_single/#d0e109
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/CommonTestMethodBase.java
I've came out with this snippet that loads rules defined in the /drl/file/path file into the stateful session you obtain at the last line.
File path = new File("/drl/file/path");
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newFileResource(path), ResourceType.DRL);
if (kbuilder.hasErrors()) {
throw new RuntimeException("Errors: " + kbuilder.getErrors());
}
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Some methods are deprecated, so, don't expect this solution to be valid in the following releases.
Please, double check the imports, they are all from org.kie, not from drools packages. I admit those imports are too much, but I'm pasting the code from an example I'm trying to develop, so I have more things on my code, sorry for that.
import java.io.File;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
import org.kie.api.builder.KieScanner;
import org.kie.api.builder.ReleaseId;
import org.kie.api.builder.model.KieBaseModel;
import org.kie.api.builder.model.KieModuleModel;
import org.kie.api.builder.model.KieSessionModel;
import org.kie.api.conf.EqualityBehaviorOption;
import org.kie.api.conf.EventProcessingOption;
import org.kie.api.io.Resource;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.conf.ClockTypeOption;
import org.kie.internal.KnowledgeBase;
import org.kie.internal.KnowledgeBaseFactory;
import org.kie.internal.builder.KnowledgeBuilder;
import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.io.ResourceFactory;
import org.kie.internal.runtime.StatefulKnowledgeSession;
Hope it helps.
java.io.FileSystem is not public in java.io; cannot be accessed from outside package
This is the line the complier points to
FileSystem fs = FileSystem.get(configuration);
I don't understand why it cannot be accessed. Here are the imports
import java.io.*;
import java.io.FileSystem;
import java.nio.file.Paths;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.SequenceFile.Writer;
import org.apache.hadoop.io.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.*;
import java.util.*;
import java.io.Writer;
import org.apache.hadoop.*;
wrong FileSystem object as well as the wrong Paths object. You want:
org.apache.hadoop.fs.FileSystem
org.apache.hadoop.fs.Path
You are dealing with the Hadoop FileSystem not the default Java implementation. Recall that you do hadoop fs -ls where fs means file system on the command line.
Replace
import java.io.FileSystem;
with
import org.apache.hadoop.fs.FileSystem;