Search in sources :

Example 66 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project liferay-ide by liferay.

the class LiferayProjectTypeStep method projectTypeChanged.

public void projectTypeChanged() {
    TemplatesGroup group = _getSelectedGroup();
    if ((group == null) || (group == _lastSelectedGroup)) {
        return;
    }
    _lastSelectedGroup = group;
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    propertiesComponent.setValue(_PROJECT_WIZARD_GROUP, group.getId());
    ModuleBuilder groupModuleBuilder = group.getModuleBuilder();
    _settingsStep = null;
    _headerPanel.removeAll();
    if ((groupModuleBuilder != null) && (groupModuleBuilder.getModuleType() != null)) {
        _settingsStep = groupModuleBuilder.modifyProjectTypeStep(this);
    }
    if ((groupModuleBuilder == null) || groupModuleBuilder.isTemplateBased()) {
        _showTemplates(group);
    } else if (!_showCustomOptions(groupModuleBuilder)) {
        List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(groupModuleBuilder);
        ProjectCategory category = group.getProjectCategory();
        if (category != null) {
            List<FrameworkSupportInModuleProvider> filtered = ContainerUtil.filter(providers, provider -> _matchFramework(category, provider));
            Map<String, FrameworkSupportInModuleProvider> map = ContainerUtil.newMapFromValues(providers.iterator(), PROVIDER_STRING_CONVERTOR);
            Stream<FrameworkSupportInModuleProvider> stream = filtered.stream();
            Set<FrameworkSupportInModuleProvider> set = stream.flatMap(provider -> provider.getDependenciesFrameworkIds().stream()).map(depId -> map.get(depId.getFrameworkId())).filter(dependency -> dependency != null).collect(Collectors.toSet());
            _frameworksPanel.setProviders(new ArrayList<>(set), new HashSet<>(Arrays.asList(category.getAssociatedFrameworkIds())), new HashSet<>(Arrays.asList(category.getPreselectedFrameworkIds())));
        } else {
            _frameworksPanel.setProviders(providers);
        }
        _getSelectedBuilder().addModuleConfigurationUpdater(_configurationUpdater);
        _showCard(_FRAMEWORKS_CARD);
    }
    _headerPanel.setVisible(_headerPanel.getComponentCount() > 0);
    List<JLabel> labels = UIUtil.findComponentsOfType(_headerPanel, JLabel.class);
    int width = 0;
    for (JLabel label : labels) {
        int width1 = label.getPreferredSize().width;
        width = Math.max(width, width1);
    }
    for (JLabel label : labels) {
        label.setPreferredSize(new Dimension(width, label.getPreferredSize().height));
    }
    _headerPanel.revalidate();
    _headerPanel.repaint();
    _updateSelection();
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) CommitStepException(com.intellij.ide.wizard.CommitStepException) Arrays(java.util.Arrays) THashMap(gnu.trove.THashMap) JBLabel(com.intellij.ui.components.JBLabel) WizardDelegate(com.intellij.ide.util.newProjectWizard.WizardDelegate) AddSupportForFrameworksPanel(com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Map(java.util.Map) Disposer(com.intellij.openapi.util.Disposer) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MultiMap(com.intellij.util.containers.MultiMap) TemplatesGroup(com.intellij.ide.util.newProjectWizard.TemplatesGroup) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) LibrariesContainerFactory(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory) Collection(java.util.Collection) BuilderBasedTemplate(com.intellij.platform.templates.BuilderBasedTemplate) FactoryMap(com.intellij.util.containers.FactoryMap) Set(java.util.Set) Icon(javax.swing.Icon) Collectors(java.util.stream.Collectors) WizardContext(com.intellij.ide.util.projectWizard.WizardContext) Nullable(org.jetbrains.annotations.Nullable) Dimension(java.awt.Dimension) List(java.util.List) Stream(java.util.stream.Stream) CoreUtil(com.liferay.ide.idea.util.CoreUtil) Function(com.intellij.util.Function) ModulesProvider(com.intellij.openapi.roots.ui.configuration.ModulesProvider) SettingsStep(com.intellij.ide.util.projectWizard.SettingsStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) CardLayout(java.awt.CardLayout) ProjectCategoryUsagesCollector(com.intellij.ide.projectWizard.ProjectCategoryUsagesCollector) JTextField(javax.swing.JTextField) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) ContainerUtil(com.intellij.util.containers.ContainerUtil) ProjectTemplate(com.intellij.platform.ProjectTemplate) FrameworkSupportModelBase(com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FrameworkSupportNode(com.intellij.ide.util.newProjectWizard.FrameworkSupportNode) LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) TemplateModuleBuilder(com.intellij.platform.templates.TemplateModuleBuilder) ProjectCategory(com.intellij.ide.projectWizard.ProjectCategory) FrameworkSupportUtil(com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil) Project(com.intellij.openapi.project.Project) ModuleType(com.intellij.openapi.module.ModuleType) StepSequence(com.intellij.ide.util.newProjectWizard.StepSequence) FrameworkRole(com.intellij.ide.util.frameworkSupport.FrameworkRole) JComponent(javax.swing.JComponent) JBList(com.intellij.ui.components.JBList) StringUtil(com.intellij.openapi.util.text.StringUtil) ListItemDescriptorAdapter(com.intellij.openapi.ui.popup.ListItemDescriptorAdapter) Convertor(com.intellij.util.containers.Convertor) FrameworkSupportNodeBase(com.intellij.ide.util.newProjectWizard.FrameworkSupportNodeBase) CollectionListModel(com.intellij.ui.CollectionListModel) ProjectTemplatesFactory(com.intellij.platform.ProjectTemplatesFactory) Disposable(com.intellij.openapi.Disposable) SingleSelectionModel(com.intellij.ui.SingleSelectionModel) FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider) AbstractMap(java.util.AbstractMap) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) JLabel(javax.swing.JLabel) GroupedItemsListRenderer(com.intellij.ui.popup.list.GroupedItemsListRenderer) ConcurrentMultiMap(com.intellij.util.containers.ConcurrentMultiMap) ListSelectionListener(javax.swing.event.ListSelectionListener) Collections(java.util.Collections) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) Set(java.util.Set) HashSet(java.util.HashSet) ProjectCategory(com.intellij.ide.projectWizard.ProjectCategory) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) TemplateModuleBuilder(com.intellij.platform.templates.TemplateModuleBuilder) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) TemplatesGroup(com.intellij.ide.util.newProjectWizard.TemplatesGroup) Dimension(java.awt.Dimension) List(java.util.List) ArrayList(java.util.ArrayList) JBList(com.intellij.ui.components.JBList) Stream(java.util.stream.Stream) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) THashMap(gnu.trove.THashMap) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) FactoryMap(com.intellij.util.containers.FactoryMap) AbstractMap(java.util.AbstractMap) ConcurrentMultiMap(com.intellij.util.containers.ConcurrentMultiMap) HashSet(java.util.HashSet)

Example 67 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project ballerina by ballerina-lang.

the class BallerinaModuleLibrariesInitializer method showNotification.

private static void showNotification(@NotNull Project project) {
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    PropertiesComponent projectPropertiesComponent = PropertiesComponent.getInstance(project);
    boolean shownAlready;
    // noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (propertiesComponent) {
        shownAlready = propertiesComponent.getBoolean(BALLERINA_LIBRARIES_NOTIFICATION_HAD_BEEN_SHOWN, false) || projectPropertiesComponent.getBoolean(BALLERINA_LIBRARIES_NOTIFICATION_HAD_BEEN_SHOWN, false);
        if (!shownAlready) {
            propertiesComponent.setValue(BALLERINA_LIBRARIES_NOTIFICATION_HAD_BEEN_SHOWN, String.valueOf(true));
        }
    }
    if (!shownAlready) {
        NotificationListener.Adapter notificationListener = new NotificationListener.Adapter() {

            @Override
            protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && "configure".equals(event.getDescription())) {
                    BallerinaLibrariesConfigurableProvider.showModulesConfigurable(project);
                }
            }
        };
        Notification notification = BallerinaConstants.BALLERINA_NOTIFICATION_GROUP.createNotification("BALLERINA_REPOSITORY was detected", "We've detected some packages from your BALLERINA_REPOSITORY.\n" + "You may want to add extra packages in <a href='configure'>Ballerina Packages " + "configuration</a>.", NotificationType.INFORMATION, notificationListener);
        Notifications.Bus.notify(notification, project);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ModuleRootAdapter(com.intellij.openapi.roots.ModuleRootAdapter) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 68 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project evosuite by EvoSuite.

the class EvoParameters method load.

public void load(Project project) {
    PropertiesComponent p = PropertiesComponent.getInstance(project);
    cores = p.getInt(CORES_EVOSUITE_PARAM, 1);
    memory = p.getInt(MEMORY_EVOSUITE_PARAM, 2000);
    time = p.getInt(TIME_EVOSUITE_PARAM, 3);
    folder = p.getValue(TARGET_FOLDER_EVOSUITE_PARAM, "src/evo");
    String envJavaHome = System.getenv("JAVA_HOME");
    javaHome = p.getValue(JAVA_HOME, envJavaHome != null ? envJavaHome : "");
    mvnLocation = p.getValue(MVN_LOCATION, "");
    evosuiteJarLocation = p.getValue(EVOSUITE_JAR_LOCATION, "");
    executionMode = p.getValue(EXECUTION_MODE, EXECUTION_MODE_MVN);
    guiWidth = p.getInt(GUI_DIALOG_WIDTH, 570);
    guiHeight = p.getInt(GUI_DIALOG_HEIGHT, 300);
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 69 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project azure-tools-for-java by Microsoft.

the class FunctionCoreToolsCombobox method saveHistory.

private void saveHistory() {
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    final List<String> subList = funcCoreToolsPathList.stream().skip(Math.max(funcCoreToolsPathList.size() - MAX_HISTORY_SIZE, 0)).collect(Collectors.toList());
    propertiesComponent.setValue(AZURE_TOOLKIT_FUNCTION_CORE_TOOLS_HISTORY, StringUtils.join(subList.toArray(), "\n"));
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 70 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project azure-tools-for-java by Microsoft.

the class FunctionCoreToolsCombobox method loadHistory.

private List<String> loadHistory() {
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    final String history = propertiesComponent.getValue(AZURE_TOOLKIT_FUNCTION_CORE_TOOLS_HISTORY);
    if (history != null) {
        final String[] items = history.split("\n");
        List<String> result = new ArrayList<>();
        for (String item : items) {
            if (StringUtils.isNotBlank(item) && new File(item).exists()) {
                try {
                    result.add(Paths.get(item).toRealPath().toString());
                } catch (Exception ignore) {
                // ignore since the history data is not important
                }
            }
        }
        return result;
    }
    return Collections.emptyList();
}
Also used : ArrayList(java.util.ArrayList) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) IOException(java.io.IOException)

Aggregations

PropertiesComponent (com.intellij.ide.util.PropertiesComponent)71 File (java.io.File)9 NotNull (org.jetbrains.annotations.NotNull)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 Project (com.intellij.openapi.project.Project)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 CommitStepException (com.intellij.ide.wizard.CommitStepException)3 Notification (com.intellij.notification.Notification)3 NotificationListener (com.intellij.notification.NotificationListener)3 JDOMException (org.jdom.JDOMException)3 Nullable (org.jetbrains.annotations.Nullable)3 SdkPaths.validateAndroidSdk (com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk)2 Module (com.intellij.openapi.module.Module)2 ProjectTemplate (com.intellij.platform.ProjectTemplate)2 CollectionListModel (com.intellij.ui.CollectionListModel)2 THashMap (gnu.trove.THashMap)2 TIntArrayList (gnu.trove.TIntArrayList)2 Analytics (io.flutter.analytics.Analytics)2