public static void send() { SourcetrailOptions options = SourcetrailOptions.getInstance(); try { String text = "ping>>" + ApplicationNamesInfo.getInstance().getFullProductName() + "<EOM>"; Socket socket = new Socket(options.getIp(), options.getSourcetrailPort()); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); writer.write(text); writer.flush(); socket.close(); } catch(Exception e) { String errorMsg = "No connection to a Sourcetrail instance\n\n Make sure Sourcetrail is running and the right address is used(" + options.getIp() + ":" + options.getSourcetrailPort() + ")"; Messages.showMessageDialog(errorMsg, "SourcetrailPluginError", Messages.getErrorIcon()); e.printStackTrace(); } }
private void sendHtmlResponse(@NotNull HttpRequest request, @NotNull ChannelHandlerContext context, String pagePath) throws IOException { BufferExposingByteArrayOutputStream byteOut = new BufferExposingByteArrayOutputStream(); InputStream pageTemplateStream = getClass().getResourceAsStream(pagePath); String pageTemplate = StreamUtil.readText(pageTemplateStream, Charset.forName("UTF-8")); try { String pageWithProductName = pageTemplate.replaceAll("%IDE_NAME", ApplicationNamesInfo.getInstance().getFullProductName()); byteOut.write(StreamUtil.loadFromStream(new ByteArrayInputStream(pageWithProductName.getBytes(Charset.forName("UTF-8"))))); HttpResponse response = Responses.response("text/html", Unpooled.wrappedBuffer(byteOut.getInternalBuffer(), 0, byteOut.size())); Responses.addNoCache(response); response.headers().set("X-Frame-Options", "Deny"); Responses.send(response, context.channel(), request); } finally { byteOut.close(); pageTemplateStream.close(); } }
public static void processDuplicates(@NotNull MatchProvider provider, @NotNull Project project, @NotNull Editor editor) { Boolean hasDuplicates = provider.hasDuplicates(); if (hasDuplicates == null || hasDuplicates.booleanValue()) { List<Match> duplicates = provider.getDuplicates(); if (duplicates.size() == 1) { previewMatch(project, duplicates.get(0), editor); } final int answer = ApplicationManager.getApplication().isUnitTestMode() || hasDuplicates == null ? Messages.YES : Messages.showYesNoDialog(project, RefactoringBundle.message("0.has.detected.1.code.fragments.in.this.file.that.can.be.replaced.with.a.call.to.extracted.method", ApplicationNamesInfo.getInstance().getProductName(), duplicates.size()), "Process Duplicates", Messages.getQuestionIcon()); if (answer == Messages.YES) { PsiDocumentManager.getInstance(project).commitAllDocuments(); invoke(project, editor, provider, hasDuplicates != null); } } }
public JComponent getAdditionalSettings(final WizardContext wizardContext) { JTextField tfModuleFilePath = new JTextField(); final String productName = ApplicationNamesInfo.getInstance().getProductName(); final String message = IdeBundle.message("prompt.select.module.file.to.import", productName); final BrowseFilesListener listener = new BrowseFilesListener(tfModuleFilePath, message, null, new ModuleFileChooserDescriptor()) { @Override protected VirtualFile getFileToSelect() { final VirtualFile fileToSelect = super.getFileToSelect(); if (fileToSelect != null) { return fileToSelect; } final Project project = wizardContext.getProject(); return project != null ? project.getBaseDir() : null; } }; myModulePathFieldPanel = new TextFieldWithBrowseButton(tfModuleFilePath, listener); onChosen(false); return myModulePathFieldPanel; }
public FrameworkDetectionStep(final Icon icon, final ProjectFromSourcesBuilder builder) { super(ProjectBundle.message("message.text.stop.searching.for.frameworks", ApplicationNamesInfo.getInstance().getProductName())); myIcon = icon; myContext = new FrameworkDetectionInWizardContext() { @Override protected List<ModuleDescriptor> getModuleDescriptors() { return FrameworkDetectionStep.this.getModuleDescriptors(); } @Override protected String getContentPath() { return builder.getBaseProjectPath(); } }; myDetectedFrameworksComponent = new DetectedFrameworksComponent(myContext); }
public static boolean createDirectoryIfNotExists(final String promptPrefix, String directoryPath, boolean promptUser) { File dir = new File(directoryPath); if (!dir.exists()) { if (promptUser) { final int answer = Messages.showOkCancelDialog(IdeBundle.message("promot.projectwizard.directory.does.not.exist", promptPrefix, dir.getPath(), ApplicationNamesInfo.getInstance().getFullProductName()), IdeBundle.message("title.directory.does.not.exist"), Messages.getQuestionIcon()); if (answer != Messages.OK) { return false; } } try { VfsUtil.createDirectories(dir.getPath()); } catch (IOException e) { Messages.showErrorDialog(IdeBundle.message("error.failed.to.create.directory", dir.getPath()), CommonBundle.getErrorTitle()); return false; } } return true; }
public static Notification createNotification(@NotNull final String groupDisplayId, @Nullable NotificationListener listener) { final String productName = ApplicationNamesInfo.getInstance().getProductName(); Window recentFocusedWindow = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow(); String text = "<html>We have found out that you are using a non-english keyboard layout. You can <a href='enable'>enable</a> smart layout support for " + KeyboardSettingsExternalizable.getDisplayLanguageNameForComponent(recentFocusedWindow) + " language." + "You can change this option in the settings of " + productName + " <a href='settings'>more...</a></html>"; String title = "Enable smart keyboard internalization for " + productName + "."; return new Notification(groupDisplayId, title, text, NotificationType.INFORMATION, listener); }
private LibNotifyWrapper() { myLibNotify = (LibNotify)Native.loadLibrary("libnotify.so.4", LibNotify.class); String appName = ApplicationNamesInfo.getInstance().getProductName(); if (myLibNotify.notify_init(appName) == 0) { throw new IllegalStateException("notify_init failed"); } String icon = AppUIUtil.findIcon(PathManager.getBinPath()); myIcon = icon != null ? icon : "dialog-information"; MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(); connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() { @Override public void appClosing() { synchronized (myLock) { myDisposed = true; myLibNotify.notify_uninit(); } } }); }
@Override public Notification createNotification(@NotNull final String groupDisplayId, @Nullable NotificationListener listener) { final String fullProductName = ApplicationNamesInfo.getInstance().getFullProductName(); final String companyName = ApplicationInfo.getInstance().getCompanyName(); String text = "<html>Please click <a href='allow'>I agree</a> if you want to help make " + fullProductName + " better or <a href='decline'>I don't agree</a> otherwise. <a href='settings'>more...</a></html>"; String title = "Help improve " + fullProductName + " by sending anonymous usage statistics to " + companyName; return new Notification(groupDisplayId, title, text, NotificationType.INFORMATION, listener); }
private static void startLogging(final Logger log) { Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") { @Override public void run() { log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); } }); log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------"); ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance(); ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance(); String buildDate = new SimpleDateFormat("dd MMM yyyy HH:ss", Locale.US).format(appInfo.getBuildDate().getTime()); log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild().asStringWithAllDetails() + ", " + buildDate + ")"); log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ", " + SystemInfo.OS_ARCH + ")"); log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")"); log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.name", "-") + ")"); List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); if (arguments != null) { log.info("JVM Args: " + StringUtil.join(arguments, " ")); } }
public CustomizeIDEWizardDialog() { super(null, true, true); setTitle("Customize " + ApplicationNamesInfo.getInstance().getProductName()); getPeer().setAppIcons(); initSteps(); mySkipButton.addActionListener(this); myBackButton.addActionListener(this); myNextButton.addActionListener(this); AbstractCustomizeWizardStep.applyHeaderFooterStyle(myNavigationLabel); AbstractCustomizeWizardStep.applyHeaderFooterStyle(myHeaderLabel); AbstractCustomizeWizardStep.applyHeaderFooterStyle(myFooterLabel); init(); initCurrentStep(true); setSize(400, 300); System.setProperty(StartupActionScriptManager.STARTUP_WIZARD_MODE, "true"); }
public void prevTip() { if (myTips.size() == 0) { myBrowser.setText(IdeBundle.message("error.tips.not.found", ApplicationNamesInfo.getInstance().getFullProductName())); return; } final GeneralSettings settings = GeneralSettings.getInstance(); int lastTip = settings.getLastTip(); final TipAndTrickBean tip; lastTip--; if (lastTip <= 0) { tip = myTips.get(myTips.size() - 1); lastTip = myTips.size(); } else { tip = myTips.get(lastTip - 1); } setTip(tip, lastTip, myBrowser, settings); }
public void nextTip() { if (myTips.size() == 0) { myBrowser.setText(IdeBundle.message("error.tips.not.found", ApplicationNamesInfo.getInstance().getFullProductName())); return; } GeneralSettings settings = GeneralSettings.getInstance(); int lastTip = settings.getLastTip(); TipAndTrickBean tip; lastTip++; if (lastTip - 1 >= myTips.size()) { tip = myTips.get(0); lastTip = 1; } else { tip = myTips.get(lastTip - 1); } setTip(tip, lastTip, myBrowser, settings); }
@NotNull private static String doGetSettingsFilePath(boolean customLocation) { final String vmOptionsFile = System.getProperty("jb.vmOptionsFile"); if (!StringUtil.isEmptyOrSpaces(vmOptionsFile)) { return vmOptionsFile; } if (SystemInfo.isMac) { if (customLocation) { return PathManager.getConfigPath() + "/idea.vmoptions"; } else { return PathManager.getBinPath() + "/idea.vmoptions"; } } final String productName = ApplicationNamesInfo.getInstance().getProductName().toLowerCase(Locale.US); final String platformSuffix = SystemInfo.is64Bit ? "64" : ""; final String osSuffix = SystemInfo.isWindows ? ".exe" : ""; return PathManager.getBinPath() + File.separatorChar + productName + platformSuffix + osSuffix + ".vmoptions"; }
public void init(final Convertor<String, VcsShowConfirmationOption.Value> initOptions) { createSettingFor(VcsConfiguration.StandardOption.ADD); createSettingFor(VcsConfiguration.StandardOption.REMOVE); createSettingFor(VcsConfiguration.StandardOption.CHECKOUT); createSettingFor(VcsConfiguration.StandardOption.UPDATE); createSettingFor(VcsConfiguration.StandardOption.STATUS); createSettingFor(VcsConfiguration.StandardOption.EDIT); myConfirmations.put(VcsConfiguration.StandardConfirmation.ADD.getId(), new VcsShowConfirmationOptionImpl( VcsConfiguration.StandardConfirmation.ADD.getId(), VcsBundle.message("label.text.when.files.created.with.idea", ApplicationNamesInfo.getInstance().getProductName()), VcsBundle.message("radio.after.creation.do.not.add"), VcsBundle.message("radio.after.creation.show.options"), VcsBundle.message("radio.after.creation.add.silently"))); myConfirmations.put(VcsConfiguration.StandardConfirmation.REMOVE.getId(), new VcsShowConfirmationOptionImpl( VcsConfiguration.StandardConfirmation.REMOVE.getId(), VcsBundle.message("label.text.when.files.are.deleted.with.idea", ApplicationNamesInfo.getInstance().getProductName()), VcsBundle.message("radio.after.deletion.do.not.remove"), VcsBundle.message("radio.after.deletion.show.options"), VcsBundle.message("radio.after.deletion.remove.silently"))); restoreReadConfirm(VcsConfiguration.StandardConfirmation.ADD, initOptions); restoreReadConfirm(VcsConfiguration.StandardConfirmation.REMOVE, initOptions); }
public void startInspection(@NotNull InspectionToolWrapper toolWrapper) { myInspectionToolWrappers.add(toolWrapper); @NonNls StringBuffer buf = new StringBuffer(); buf.append("<HTML><HEAD><TITLE>"); buf.append(ApplicationNamesInfo.getInstance().getFullProductName()); buf.append(InspectionsBundle.message("inspection.export.title")); buf.append("</TITLE></HEAD>"); buf.append("<FRAMESET cols=\"30%,70%\"><FRAMESET rows=\"30%,70%\">"); buf.append("<FRAME src=\""); buf.append(toolWrapper.getFolderName()); buf.append("/index.html\" name=\"inspectionFrame\">"); buf.append("<FRAME src=\"empty.html\" name=\"packageFrame\">"); buf.append("</FRAMESET>"); buf.append("<FRAME src=\"empty.html\" name=\"elementFrame\">"); buf.append("</FRAMESET></BODY></HTML"); HTMLExportUtil.writeFile(myRootFolder, toolWrapper.getFolderName() + "-index.html", buf, myProject); }
private boolean checkReadOnlyFiles() throws IOException { List<File> files = getReadOnlyFiles(); if (!files.isEmpty()) { final String message = IdeBundle.message("message.text.unlock.read.only.files", ApplicationNamesInfo.getInstance().getFullProductName(), getFilesString(files)); final String[] options = {CommonBundle.getContinueButtonText(), CommonBundle.getCancelButtonText()}; if (Messages.showOkCancelDialog(myMainPanel, message, IdeBundle.message("dialog.title.convert.project"), options[0], options[1], null) != Messages.OK) { return false; } unlockFiles(files); files = getReadOnlyFiles(); if (!files.isEmpty()) { showErrorMessage(IdeBundle.message("error.message.cannot.make.files.writable", getFilesString(files))); return false; } } return true; }
@NonNull @Override public Notification createNotification(@NotNull final String groupDisplayId, @Nullable NotificationListener listener) { final String fullProductName = ApplicationNamesInfo.getInstance().getFullProductName(); final String companyName = ApplicationInfo.getInstance().getCompanyName(); String text = "<html>Please click <a href='allow'>I agree</a> if you want to help make " + fullProductName + " better or <a href='decline'>I don't agree</a> otherwise. <a href='settings'>more...</a></html>"; String title = "Help improve " + fullProductName + " by sending usage statistics to " + companyName; return new Notification(groupDisplayId, title, text, NotificationType.INFORMATION, listener); }
@Nullable @Override public Map<String, String> getStatisticsConfigurationLabels() { Map<String, String> labels = new HashMap<String, String>(); final String fullProductName = ApplicationNamesInfo.getInstance().getFullProductName(); final String companyName = ApplicationInfo.getInstance().getCompanyName(); labels.put(StatisticsService.TITLE, "Help improve " + fullProductName + " by sending usage statistics to " + companyName); labels.put(StatisticsService.ALLOW_CHECKBOX, "Send usage statistics to " + companyName); labels.put(StatisticsService.DETAILS, "<html>This allows " + companyName + " to collect usage information, such as data about your feature usage," + "<br>resource usage and plugin configuration.</html>"); // Note: we inline the constants corresponding to the following keys since the corresponding change in IJ // may not be in upstream as yet. labels.put("linkUrl", "http://www.google.com/policies/privacy/"); labels.put("linkBeforeText", "This data is collected in accordance with " + companyName + "'s "); labels.put("linkText", "privacy policy"); labels.put("linkAfterText", "."); return labels; }
@Override public void performFinishingActions() { List<IPkgDesc> skipped = myState.get(SKIPPED_INSTALL_REQUESTS_KEY); if (skipped != null && !skipped.isEmpty()) { StringBuilder warningBuilder = new StringBuilder("The following packages were not installed.\n\n Would you like to exit "); warningBuilder.append(ApplicationNamesInfo.getInstance().getFullProductName()); warningBuilder.append(" and install the following packages using the standalone SDK manager?"); for (IPkgDesc problemPkg : skipped) { warningBuilder.append("\n"); warningBuilder.append(problemPkg.getListDescription()); } String restartOption = String.format("Exit %s and launch SDK Manager", ApplicationNamesInfo.getInstance().getProductName()); int result = Messages.showDialog(getProject(), warningBuilder.toString(), "Warning", new String[]{restartOption, "Skip installation"}, 0, AllIcons.General.Warning); if (result == 0) { startSdkManagerAndExit(); } } // We've already installed things, so clearly there's an SDK. AndroidSdkData data = AndroidSdkUtils.tryToChooseAndroidSdk(); SdkState.getInstance(data).loadAsync(SdkState.DEFAULT_EXPIRATION_PERIOD_MS, false, null, null, null, true); }
/** * Adds specified <code>item</code> to the palette. * * @param item item to be added * @throws IllegalArgumentException if an item for the same class * is already exists in the palette */ public void addItem(@NotNull final GroupItem group, @NotNull final ComponentItem item) { // class -> item final String componentClassName = item.getClassName(); if (getItem(componentClassName) != null) { Messages.showMessageDialog( UIDesignerBundle.message("error.item.already.added", componentClassName), ApplicationNamesInfo.getInstance().getFullProductName(), Messages.getErrorIcon() ); return; } myClassName2Item.put(componentClassName, item); // group -> items group.addItem(item); // Process special predefined item for JPanel if ("javax.swing.JPanel".equals(item.getClassName())) { myPanelItem = item; } }
public List<VcsException> scheduleMissingFileForDeletion(List<FilePath> files) { for (FilePath file : files) { if (file.isDirectory()) { VcsBalloonProblemNotifier.showOverChangesView(myProject, "Locally deleted directories cannot be removed from CVS. To remove a locally " + "deleted directory from CVS, first invoke Rollback and then use " + ApplicationNamesInfo.getInstance().getFullProductName() + "'s Delete.", MessageType.WARNING); break; } } final CvsHandler handler = RemoveLocallyFileOrDirectoryAction.getDefaultHandler(myProject, ChangesUtil.filePathsToFiles(files)); final CvsOperationExecutor executor = new CvsOperationExecutor(myProject); executor.performActionSync(handler, CvsOperationExecutorCallback.EMPTY); return Collections.emptyList(); }
private void applyTo(ArrayRenderer renderer, boolean showBigRangeWarning) throws ConfigurationException { int newStartIndex = getInt(myStartIndex); int newEndIndex = getInt(myEndIndex); int newLimit = getInt(myEntriesLimit); if (newStartIndex < 0) { throw new ConfigurationException(DebuggerBundle.message("error.array.renderer.configurable.start.index.less.than.zero")); } if (newEndIndex < newStartIndex) { throw new ConfigurationException(DebuggerBundle.message("error.array.renderer.configurable.end.index.less.than.start")); } if (newStartIndex >= 0 && newEndIndex >= 0) { if (newStartIndex > newEndIndex) { int currentStartIndex = renderer.START_INDEX; int currentEndIndex = renderer.END_INDEX; newEndIndex = newStartIndex + (currentEndIndex - currentStartIndex); } if(newLimit <= 0) { newLimit = 1; } if(showBigRangeWarning && (newEndIndex - newStartIndex > 10000)) { final int answer = Messages.showOkCancelDialog( myPanel.getRootPane(), DebuggerBundle.message("warning.range.too.big", ApplicationNamesInfo.getInstance().getProductName()), DebuggerBundle.message("title.range.too.big"), Messages.getWarningIcon()); if(answer != Messages.OK) { return; } } } renderer.START_INDEX = newStartIndex; renderer.END_INDEX = newEndIndex; renderer.ENTRIES_LIMIT = newLimit; }
static String getProductNameWithArticle() { final ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance(); // example: "to create an IntelliJ IDEA project" (full product name is ok); // "to create a JetBrains Astella project" (better use not full product name: "to create an Astella project") final String productName = PlatformUtils.isIdeaUltimate() ? namesInfo.getFullProductName() : namesInfo.getProductName(); final String article = StringUtil.isVowel(Character.toLowerCase(productName.charAt(0))) ? "an " : "a "; return article + productName; }
@NotNull public String getDescription(final WizardContext context) { final String productName = ApplicationNamesInfo.getInstance().getFullProductName(); return ProjectBundle.message("project.new.wizard.import.description", productName, context.getPresentationName(), StringUtil.join( Arrays.asList(Extensions.getExtensions(ProjectImportProvider.PROJECT_IMPORT_PROVIDER)), new Function<ProjectImportProvider, String>() { public String fun(final ProjectImportProvider provider) { return provider.getName(); } }, ", ")); }
public RootsDetectionStep(ProjectFromSourcesBuilderImpl builder, WizardContext context, StepSequence sequence, Icon icon, @NonNls String helpId) { super(IdeBundle.message("prompt.stop.searching.for.sources", ApplicationNamesInfo.getInstance().getProductName())); myBuilder = builder; myContext = context; mySequence = sequence; myIcon = icon; myHelpId = helpId; }
@NotNull public static String getActionUnavailableMessage(@NotNull List<String> actionNames) { String message; final String beAvailableUntil = " available while " + ApplicationNamesInfo.getInstance().getProductName() + " is updating indices"; if (actionNames.isEmpty()) { message = "This action is not" + beAvailableUntil; } else if (actionNames.size() == 1) { message = "'" + actionNames.get(0) + "' action is not" + beAvailableUntil; } else { message = "None of the following actions are" + beAvailableUntil + ": " + StringUtil.join(actionNames, ", "); } return message; }
public static void isInstalledAssertion() { final ProxySelector aDefault = ProxySelector.getDefault(); if (ourInstance != aDefault) { // to report only once if (ourWrong != aDefault || itsTime()) { LOG.error("ProxySelector.setDefault() was changed to [" + aDefault.toString() + "] - other than com.intellij.util.proxy.CommonProxy.ourInstance.\n" + "This will make some " + ApplicationNamesInfo.getInstance().getProductName() + " network calls fail.\n" + "Instead, methods of com.intellij.util.proxy.CommonProxy should be used for proxying."); ourWrong = aDefault; } ProxySelector.setDefault(ourInstance); ourInstance.ensureAuthenticator(); } assertSystemPropertiesSet(); }
@Override public void cannotBind(Exception e, int port) { BuiltInServerManagerImpl.NOTIFICATION_GROUP.getValue().createNotification("Cannot start built-in HTTP server on custom port " + port + ". " + "Please ensure that port is free (or check your firewall settings) and restart " + ApplicationNamesInfo.getInstance().getFullProductName(), NotificationType.ERROR).notify(null); }
private Future<?> startServerInPooledThread() { if (!started.compareAndSet(false, true)) { return null; } return ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { try { BuiltInServer mainServer = StartupUtil.getServer(); if (mainServer == null && ApplicationManager.getApplication().isUnitTestMode()) { server = BuiltInServer.start(1, getDefaultPort(), PORTS_COUNT, false, null); } else { LOG.assertTrue(mainServer != null); server = BuiltInServer.start(mainServer.getEventLoopGroup(), false, getDefaultPort(), PORTS_COUNT, true, null); } bindCustomPorts(server); } catch (Throwable e) { LOG.info(e); NOTIFICATION_GROUP.getValue().createNotification("Cannot start internal HTTP server. Git integration, JavaScript debugger and LiveEdit may operate with errors. " + "Please check your firewall settings and restart " + ApplicationNamesInfo.getInstance().getFullProductName(), NotificationType.ERROR).notify(null); return; } LOG.info("built-in server started, port " + server.getPort()); Disposer.register(ApplicationManager.getApplication(), server); } }); }
public WelcomeFrame() { JRootPane rootPane = getRootPane(); final WelcomeScreen screen = createScreen(rootPane); final IdeGlassPaneImpl glassPane = new IdeGlassPaneImpl(rootPane); setGlassPane(glassPane); glassPane.setVisible(false); setContentPane(screen.getWelcomePanel()); setTitle(ApplicationNamesInfo.getInstance().getFullProductName()); AppUIUtil.updateWindowIcon(this); ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() { @Override public void projectOpened(Project project) { dispose(); } }); myBalloonLayout = new BalloonLayoutImpl(rootPane, new Insets(8, 8, 8, 8)); myScreen = screen; setupCloseAction(this); MnemonicHelper.init(this); myScreen.setupFrame(this); Disposer.register(ApplicationManager.getApplication(), new Disposable() { @Override public void dispose() { WelcomeFrame.this.dispose(); } }); }
private static JPanel createFooterPanel() { JLabel versionLabel = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName() + " " + ApplicationInfo.getInstance().getFullVersion() + " Build " + ApplicationInfo.getInstance().getBuild().asStringWithoutProductCode()); makeSmallFont(versionLabel); versionLabel.setForeground(WelcomeScreenColors.FOOTER_FOREGROUND); JPanel footerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); footerPanel.setBackground(WelcomeScreenColors.FOOTER_BACKGROUND); footerPanel.setBorder(new EmptyBorder(2, 5, 2, 5) { @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { g.setColor(WelcomeScreenColors.BORDER_COLOR); g.drawLine(x, y, x + width, y); } }); footerPanel.add(versionLabel); footerPanel.add(makeSmallFont(new JLabel(". "))); footerPanel.add(makeSmallFont(new LinkLabel("Check", null, new LinkListener() { @Override public void linkSelected(LinkLabel aSource, Object aLinkData) { UpdateChecker.updateAndShowResult(null, null); } }))); footerPanel.add(makeSmallFont(new JLabel(" for updates now."))); return footerPanel; }
private static JPanel createHeaderPanel() { JPanel header = new JPanel(new BorderLayout()); JLabel welcome = new JLabel("Welcome to " + ApplicationNamesInfo.getInstance().getFullProductName(), IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getWelcomeScreenLogoUrl()), SwingConstants.LEFT); welcome.setBorder(new EmptyBorder(10, 15, 10, 15)); welcome.setFont(welcome.getFont().deriveFont((float) 32)); welcome.setIconTextGap(20); welcome.setForeground(WelcomeScreenColors.WELCOME_HEADER_FOREGROUND); header.add(welcome); header.setBackground(WelcomeScreenColors.WELCOME_HEADER_BACKGROUND); header.setBorder(new BottomLineBorder()); return header; }
private JComponent createLogo() { NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout()); ApplicationInfoEx app = ApplicationInfoEx.getInstanceEx(); JLabel logo = new JLabel(IconLoader.getIcon(app.getWelcomeScreenLogoUrl())); logo.setBorder(JBUI.Borders.empty(30,0,10,0)); logo.setHorizontalAlignment(SwingConstants.CENTER); panel.add(logo, BorderLayout.NORTH); JLabel appName = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName()); Font font = getProductFont(); appName.setForeground(JBColor.foreground()); appName.setFont(font.deriveFont(JBUI.scale(36f)).deriveFont(Font.PLAIN)); appName.setHorizontalAlignment(SwingConstants.CENTER); String appVersion = "Version " + app.getFullVersion(); if (app.isEAP() && app.getBuild().getBuildNumber() < Integer.MAX_VALUE) { appVersion += " (" + app.getBuild().asString() + ")"; } JLabel version = new JLabel(appVersion); version.setFont(getProductFont().deriveFont(JBUI.scale(16f))); version.setHorizontalAlignment(SwingConstants.CENTER); version.setForeground(Gray._128); panel.add(appName); panel.add(version, BorderLayout.SOUTH); panel.setBorder(JBUI.Borders.emptyBottom(20)); return panel; }
private FileTypeChooser(@NotNull List<String> patterns, @NotNull String fileName) { super(true); myFileName = fileName; myOpenInIdea.setText("Open matching files in " + ApplicationNamesInfo.getInstance().getFullProductName() + ":"); FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes(); Arrays.sort(fileTypes, new Comparator<FileType>() { @Override public int compare(final FileType fileType1, final FileType fileType2) { if (fileType1 == null) { return 1; } if (fileType2 == null) { return -1; } return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription()); } }); final DefaultListModel model = new DefaultListModel(); for (FileType type : fileTypes) { if (!type.isReadOnly() && type != FileTypes.UNKNOWN && !(type instanceof NativeFileType)) { model.addElement(type); } } myList.setModel(model); myPattern.setModel(new CollectionComboBoxModel(ContainerUtil.map(patterns, FunctionUtil.<String>id()), patterns.get(0))); setTitle(FileTypesBundle.message("filetype.chooser.title")); init(); }
@NotNull @Override public JComponent getComponent() { JLabel label = new JLabel( "File " + myFile.getPath() + " is too large for " + ApplicationNamesInfo.getInstance().getFullProductName() + " editor"); label.setHorizontalAlignment(SwingConstants.CENTER); return label; }
@SuppressWarnings("UnusedDeclaration") public boolean callback(ID self, String selector, ID panel, ID url, ID outError) { try { return checkFile(self, url, false); } catch (Exception e) { if (!ID.NIL.equals(outError)) { ID domain = Foundation.nsString(ApplicationNamesInfo.getInstance().getProductName()); ID dict = Foundation.createDict(new String[]{"NSLocalizedDescription"}, new Object[]{e.getMessage()}); ID error = Foundation.invoke("NSError", "errorWithDomain:code:userInfo:", domain, 100, dict); new Pointer(outError.longValue()).setLong(0, error.longValue()); } return false; } }
public static String getFrameClass() { String name = ApplicationNamesInfo.getInstance().getProductName().toLowerCase(Locale.US); String wmClass = VENDOR_PREFIX + StringUtil.replaceChar(name, ' ', '-'); if ("true".equals(System.getProperty("idea.debug.mode"))) { wmClass += "-debug"; } return PlatformUtils.isCommunityEdition() ? wmClass + "-ce" : wmClass; }
public StatisticsConfigurationComponent() { String product = ApplicationNamesInfo.getInstance().getFullProductName(); String company = ApplicationInfo.getInstance().getCompanyName(); myTitle.setText(StatisticsBundle.message("stats.title", product, company)); myLabel.setText(StatisticsBundle.message("stats.config.details", company)); RelativeFont.SMALL.install(myLabel); myAllowToSendUsagesCheckBox.setText(StatisticsBundle.message("stats.config.allow.send.stats.text", company)); myAllowToSendUsagesCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRadioButtonsEnabled(); } }); // Let current statistics service override labels StatisticsService service = StatisticsUploadAssistant.getStatisticsService(); if (service != null) { Map<String, String> overrides = service.getStatisticsConfigurationLabels(); if (overrides != null) { String s = overrides.get(StatisticsService.TITLE); if (s != null) { myTitle.setText(s); } s = overrides.get(StatisticsService.DETAILS); if (s != null) { myLabel.setText(s); } s = overrides.get(StatisticsService.ALLOW_CHECKBOX); if (s != null) { myAllowToSendUsagesCheckBox.setText(s); } } } myTitle.setText(myTitle.getText().replace("%company%", company)); myLabel.setText(myLabel.getText().replace("%company%", company)); myAllowToSendUsagesCheckBox.setText(myAllowToSendUsagesCheckBox.getText().replace("%company%", company)); }
private synchronized static boolean lockSystemFolders(String[] args) { if (ourLock != null) { throw new AssertionError(); } ourLock = new SocketLock(PathManager.getConfigPath(), PathManager.getSystemPath()); SocketLock.ActivateStatus status; try { status = ourLock.lock(args); } catch (Exception e) { Main.showMessage("Cannot Lock System Folders", e); return false; } if (status == SocketLock.ActivateStatus.NO_INSTANCE) { ShutDownTracker.getInstance().registerShutdownTask(new Runnable() { @Override public void run() { ourLock.dispose(); } }); return true; } else if (Main.isHeadless() || status == SocketLock.ActivateStatus.CANNOT_ACTIVATE) { String message = "Only one instance of " + ApplicationNamesInfo.getInstance().getFullProductName() + " can be run at a time."; Main.showMessage("Too Many Instances", message, true); } return false; }