Notifications improvements
[fedora-idea.git] / plugins / IntelliLang / src / org / intellij / plugins / intelliLang / InjectionsSettingsUI.java
blob2123d669ce45381cb884d320c5ad01c1538d5fef
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.intellij.plugins.intelliLang;
19 import com.intellij.lang.Language;
20 import com.intellij.openapi.actionSystem.*;
21 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
22 import com.intellij.openapi.fileChooser.FileChooserDialog;
23 import com.intellij.openapi.fileChooser.FileChooserFactory;
24 import com.intellij.openapi.fileTypes.FileType;
25 import com.intellij.openapi.fileTypes.StdFileTypes;
26 import com.intellij.openapi.options.Configurable;
27 import com.intellij.openapi.project.Project;
28 import com.intellij.openapi.ui.Messages;
29 import com.intellij.openapi.ui.SplitterProportionsData;
30 import com.intellij.openapi.ui.popup.JBPopupFactory;
31 import com.intellij.openapi.util.Comparing;
32 import com.intellij.openapi.util.Condition;
33 import com.intellij.openapi.util.Factory;
34 import com.intellij.openapi.util.IconLoader;
35 import com.intellij.openapi.util.text.StringUtil;
36 import com.intellij.openapi.vfs.VirtualFile;
37 import com.intellij.peer.PeerFactory;
38 import com.intellij.ui.*;
39 import com.intellij.ui.table.TableView;
40 import com.intellij.util.Consumer;
41 import com.intellij.util.Function;
42 import com.intellij.util.Icons;
43 import com.intellij.util.Processor;
44 import com.intellij.util.containers.ContainerUtil;
45 import com.intellij.util.containers.Convertor;
46 import com.intellij.util.ui.ColumnInfo;
47 import com.intellij.util.ui.ListTableModel;
48 import com.intellij.openapi.ui.StripeTable;
49 import gnu.trove.THashMap;
50 import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
51 import org.intellij.plugins.intelliLang.inject.InjectorUtils;
52 import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport;
53 import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
54 import org.intellij.plugins.intelliLang.inject.config.InjectionPlace;
55 import org.jetbrains.annotations.Nls;
56 import org.jetbrains.annotations.Nullable;
58 import javax.swing.*;
59 import javax.swing.table.TableCellRenderer;
60 import java.awt.*;
61 import java.awt.event.KeyEvent;
62 import java.util.*;
63 import java.util.List;
65 /**
66 * @author Gregory.Shrago
68 public class InjectionsSettingsUI implements Configurable {
70 private final Project myProject;
71 private final Configuration myConfiguration;
72 private List<BaseInjection> myInjections;
73 private List<BaseInjection> myOriginalInjections;
76 private final JPanel myRoot;
77 private final InjectionsTable myInjectionsTable;
78 private final Map<String, LanguageInjectionSupport> mySupports = new THashMap<String, LanguageInjectionSupport>();
79 private final Map<String, AnAction> myEditActions = new THashMap<String, AnAction>();
80 private final List<AnAction> myAddActions = new ArrayList<AnAction>();
81 private ActionToolbar myToolbar;
82 private JLabel myCountLabel;
84 public InjectionsSettingsUI(final Project project, final Configuration configuration) {
85 myProject = project;
86 myConfiguration = configuration;
88 myOriginalInjections = ContainerUtil
89 .concat(InjectorUtils.getActiveInjectionSupportIds(), new Function<String, Collection<? extends BaseInjection>>() {
90 public Collection<? extends BaseInjection> fun(final String s) {
91 return ContainerUtil.findAll(myConfiguration.getInjections(s), new Condition<BaseInjection>() {
92 public boolean value(final BaseInjection injection) {
93 return InjectedLanguage.findLanguageById(injection.getInjectedLanguageId()) != null;
95 });
97 });
98 sortInjections(myOriginalInjections);
99 myInjections = new ArrayList<BaseInjection>();
100 for (BaseInjection injection : myOriginalInjections) {
101 myInjections.add(injection.copy());
104 myRoot = new JPanel(new BorderLayout());
106 myInjectionsTable = new InjectionsTable(myInjections);
107 final JPanel tablePanel = new JPanel(new BorderLayout());
109 tablePanel.add(StripeTable.createScrollPane(myInjectionsTable), BorderLayout.CENTER);
110 //tablePanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
112 final DefaultActionGroup group = createActions();
114 myToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
115 myToolbar.setTargetComponent(myInjectionsTable);
116 myRoot.add(myToolbar.getComponent(), BorderLayout.NORTH);
117 myRoot.add(tablePanel, BorderLayout.CENTER);
118 myCountLabel = new JLabel();
119 myCountLabel.setHorizontalAlignment(SwingConstants.RIGHT);
120 myCountLabel.setForeground(SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES.getFgColor());
121 myRoot.add(myCountLabel, BorderLayout.SOUTH);
122 updateCountLabel();
125 private DefaultActionGroup createActions() {
126 final Consumer<BaseInjection> consumer = new Consumer<BaseInjection>() {
127 public void consume(final BaseInjection injection) {
128 addInjection(injection);
131 final Factory<BaseInjection> producer = new Factory<BaseInjection>() {
132 public BaseInjection create() {
133 return getSelectedInjection();
136 for (LanguageInjectionSupport support : InjectorUtils.getActiveInjectionSupports()) {
137 myAddActions.addAll(Arrays.asList(support.createAddActions(myProject, consumer)));
138 ContainerUtil.putIfNotNull(support.getId(), support.createEditAction(myProject, producer), myEditActions);
139 mySupports.put(support.getId(), support);
141 Collections.sort(myAddActions, new Comparator<AnAction>() {
142 public int compare(final AnAction o1, final AnAction o2) {
143 return Comparing.compare(o1.getTemplatePresentation().getText(), o2.getTemplatePresentation().getText());
147 final DefaultActionGroup group = new DefaultActionGroup();
148 final AnAction addAction = new AnAction("Add", "Add", Icons.ADD_ICON) {
149 @Override
150 public void update(final AnActionEvent e) {
151 e.getPresentation().setEnabled(!myAddActions.isEmpty());
154 @Override
155 public void actionPerformed(final AnActionEvent e) {
156 performAdd(e);
157 updateCountLabel();
160 final AnAction removeAction = new AnAction("Remove", "Remove", Icons.DELETE_ICON) {
161 @Override
162 public void update(final AnActionEvent e) {
163 e.getPresentation().setEnabled(!getSelectedInjections().isEmpty());
166 @Override
167 public void actionPerformed(final AnActionEvent e) {
168 performRemove();
169 updateCountLabel();
173 final AnAction editAction = new AnAction("Edit", "Edit", Icons.PROPERTIES_ICON) {
174 @Override
175 public void update(final AnActionEvent e) {
176 final AnAction action = getEditAction();
177 e.getPresentation().setEnabled(action != null);
178 if (action != null) action.update(e);
181 @Override
182 public void actionPerformed(final AnActionEvent e) {
183 final int row = myInjectionsTable.getSelectedRow();
184 final AnAction action = getEditAction();
185 action.actionPerformed(e);
186 ((ListTableModel)myInjectionsTable.getModel()).fireTableDataChanged();
187 myInjectionsTable.getSelectionModel().setSelectionInterval(row, row);
188 updateCountLabel();
191 group.add(addAction);
192 group.add(removeAction);
193 group.add(editAction);
195 addAction.registerCustomShortcutSet(CommonShortcuts.INSERT, myInjectionsTable);
196 removeAction.registerCustomShortcutSet(CommonShortcuts.DELETE, myInjectionsTable);
197 editAction.registerCustomShortcutSet(CommonShortcuts.ENTER, myInjectionsTable);
199 group.add(new AnAction("Import", "Import", IconLoader.getIcon("/actions/install.png")) {
200 @Override
201 public void actionPerformed(final AnActionEvent e) {
202 doImportAction(e.getDataContext());
203 updateCountLabel();
206 group.addSeparator();
207 group.add(new AnAction("Enabled Selected Injections", "Enabled Selected Injections", Icons.SELECT_ALL_ICON) {
208 @Override
209 public void actionPerformed(final AnActionEvent e) {
210 performSelectedInjectionsEnabled(true);
213 group.add(new AnAction("Disabled Selected Injections", "Disabled Selected Injections", Icons.UNSELECT_ALL_ICON) {
214 @Override
215 public void actionPerformed(final AnActionEvent e) {
216 performSelectedInjectionsEnabled(false);
217 updateCountLabel();
221 new AnAction("Toggle") {
222 @Override
223 public void actionPerformed(final AnActionEvent e) {
224 performToggleAction();
225 updateCountLabel();
227 }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), myInjectionsTable);
228 return group;
231 private void updateCountLabel() {
232 int placesCount = 0;
233 int enablePlacesCount = 0;
234 for (BaseInjection injection : myInjections) {
235 for (InjectionPlace place : injection.getInjectionPlaces()) {
236 placesCount++;
237 if (place.isEnabled()) enablePlacesCount++;
240 if (!myInjections.isEmpty()) {
241 final StringBuilder sb = new StringBuilder();
242 sb.append(myInjections.size()).append(" injection").append(myInjections.size() > 1 ? "s" : "").append(" (").append(enablePlacesCount)
243 .append(" of ").append(placesCount).append(" place").append(placesCount > 1 ? "s" : "").append(" enabled) ");
244 myCountLabel.setText(sb.toString());
246 else {
247 myCountLabel.setText("no injections configured ");
251 private AnAction getEditAction() {
252 final BaseInjection injection = getSelectedInjection();
253 final String supportId = injection == null? null : injection.getSupportId();
254 return supportId == null? null : myEditActions.get(supportId);
257 private void addInjection(final BaseInjection injection) {
258 injection.initializePlaces(true);
259 myInjections.add(injection);
260 ((ListTableModel<BaseInjection>)myInjectionsTable.getModel()).setItems(myInjections);
261 final int index = myInjections.indexOf(injection);
262 myInjectionsTable.getSelectionModel().setSelectionInterval(index, index);
263 TableUtil.scrollSelectionToVisible(myInjectionsTable);
266 private void sortInjections(final List<BaseInjection> injections) {
267 Collections.sort(injections, new Comparator<BaseInjection>() {
268 public int compare(final BaseInjection o1, final BaseInjection o2) {
269 final int support = Comparing.compare(o1.getSupportId(), o2.getSupportId());
270 if (support != 0) return support;
271 final int lang = Comparing.compare(o1.getInjectedLanguageId(), o2.getInjectedLanguageId());
272 if (lang != 0) return lang;
273 return Comparing.compare(o1.getDisplayName(), o2.getDisplayName());
278 public JComponent createComponent() {
279 return myRoot;
282 public void reset() {
283 myInjections.clear();
284 for (BaseInjection injection : myOriginalInjections) {
285 myInjections.add(injection.copy());
287 ((ListTableModel<BaseInjection>)myInjectionsTable.getModel()).setItems(myInjections);
288 updateCountLabel();
291 public void disposeUIResources() {
294 public void apply() {
295 myConfiguration.replaceInjections(myInjections, myOriginalInjections);
296 myOriginalInjections.clear();
297 myOriginalInjections.addAll(myInjections);
298 sortInjections(myOriginalInjections);
299 reset();
302 public boolean isModified() {
303 final List<BaseInjection> copy = new ArrayList<BaseInjection>(myInjections);
304 sortInjections(copy);
305 return !myOriginalInjections.equals(copy);
308 private void performSelectedInjectionsEnabled(final boolean enabled) {
309 for (BaseInjection injection : getSelectedInjections()) {
310 injection.setPlaceEnabled(null, enabled);
312 myInjectionsTable.updateUI();
315 private void performToggleAction() {
316 final List<BaseInjection> selectedInjections = getSelectedInjections();
317 boolean enabledExists = false;
318 boolean disabledExists = false;
319 for (BaseInjection injection : selectedInjections) {
320 if (injection.isEnabled()) enabledExists = true;
321 else disabledExists = true;
322 if (enabledExists && disabledExists) break;
324 boolean allEnabled = !enabledExists && disabledExists;
325 performSelectedInjectionsEnabled(allEnabled);
328 private void performRemove() {
329 final int selectedRow = myInjectionsTable.getSelectedRow();
330 if (selectedRow < 0) return;
331 myInjections.removeAll(getSelectedInjections());
332 ((ListTableModel)myInjectionsTable.getModel()).fireTableDataChanged();
333 final int index = Math.min(myInjections.size() - 1, selectedRow);
334 myInjectionsTable.getSelectionModel().setSelectionInterval(index, index);
335 TableUtil.scrollSelectionToVisible(myInjectionsTable);
338 private List<BaseInjection> getSelectedInjections() {
339 final ArrayList<BaseInjection> toRemove = new ArrayList<BaseInjection>();
340 for (int row : myInjectionsTable.getSelectedRows()) {
341 toRemove.add((BaseInjection)myInjectionsTable.getItems().get(row));
343 return toRemove;
346 @Nullable
347 private BaseInjection getSelectedInjection() {
348 final int row = myInjectionsTable.getSelectedRow();
349 return row < 0? null : (BaseInjection)myInjectionsTable.getItems().get(row);
352 private void performAdd(final AnActionEvent e) {
353 final DefaultActionGroup group = new DefaultActionGroup();
354 for (AnAction action : myAddActions) {
355 group.add(action);
358 JBPopupFactory.getInstance().createActionGroupPopup(null, group, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, true)
359 .showUnderneathOf(myToolbar.getComponent());
362 @Nls
363 public String getDisplayName() {
364 return "Injections";
367 public Icon getIcon() {
368 return null;
371 public String getHelpTopic() {
372 return null;
375 private class InjectionsTable extends TableView {
376 private InjectionsTable(final List<BaseInjection> injections) {
377 super(new ListTableModel<BaseInjection>(createInjectionColumnInfos(), injections, 1));
378 setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN);
379 getColumnModel().getColumn(2).setCellRenderer(createLanguageCellRenderer());
380 getColumnModel().getColumn(1).setCellRenderer(createDisplayNameCellRenderer());
381 getColumnModel().getColumn(0).setResizable(false);
382 setShowGrid(false);
383 setShowVerticalLines(false);
384 setGridColor(getForeground());
385 setOpaque(false);
386 getColumnModel().getColumn(0).setMaxWidth(new JCheckBox().getPreferredSize().width);
387 final int[] preffered = new int[] {0} ;
388 ContainerUtil.process(myInjections, new Processor<BaseInjection>() {
389 public boolean process(final BaseInjection injection) {
390 final String languageId = injection.getInjectedLanguageId();
391 if (preffered[0] < languageId.length()) preffered[0] = languageId.length();
392 return true;
395 final int[] max = new int[] {0} ;
396 ContainerUtil.process(InjectedLanguage.getAvailableLanguageIDs(), new Processor<String>() {
397 public boolean process(final String languageId) {
398 if (max[0] < languageId.length()) max[0] = languageId.length();
399 return true;
402 getColumnModel().getColumn(2).setResizable(false);
403 final Icon icon = StdFileTypes.PLAIN_TEXT.getIcon();
404 final int preferred = new JLabel(StringUtil.repeatSymbol('m', preffered[0]), icon, SwingConstants.LEFT).getPreferredSize().width;
405 getColumnModel().getColumn(2).setMinWidth(preferred);
406 getColumnModel().getColumn(2).setPreferredWidth(preferred);
407 getColumnModel().getColumn(2).setMaxWidth(new JLabel(StringUtil.repeatSymbol('m', max[0]), icon, SwingConstants.LEFT).getPreferredSize().width);
408 new TableViewSpeedSearch(this) {
410 @Override
411 protected String getElementText(final Object element) {
412 final BaseInjection injection = (BaseInjection)element;
413 return injection.getSupportId() + " " + injection.getInjectedLanguageId() + " " + injection.getDisplayName();
420 private ColumnInfo[] createInjectionColumnInfos() {
421 final TableCellRenderer booleanCellRenderer = createBooleanCellRenderer();
422 final TableCellRenderer displayNameCellRenderer = createDisplayNameCellRenderer();
423 final TableCellRenderer languageCellRenderer = createLanguageCellRenderer();
424 final Comparator<BaseInjection> languageComparator = new Comparator<BaseInjection>() {
425 public int compare(final BaseInjection o1, final BaseInjection o2) {
426 return Comparing.compare(o1.getInjectedLanguageId(), o2.getInjectedLanguageId());
429 final Comparator<BaseInjection> displayNameComparator = new Comparator<BaseInjection>() {
430 public int compare(final BaseInjection o1, final BaseInjection o2) {
431 final int support = Comparing.compare(o1.getSupportId(), o2.getSupportId());
432 if (support != 0) return support;
433 return Comparing.compare(o1.getDisplayName(), o2.getDisplayName());
436 return new ColumnInfo[]{new ColumnInfo<BaseInjection, Boolean>(" ") {
437 @Override
438 public Class getColumnClass() {
439 return Boolean.class;
442 @Override
443 public Boolean valueOf(final BaseInjection o) {
444 return o.isEnabled();
447 @Override
448 public boolean isCellEditable(final BaseInjection injection) {
449 return true;
452 @Override
453 public void setValue(final BaseInjection injection, final Boolean value) {
454 injection.setPlaceEnabled(null, value.booleanValue());
457 @Override
458 public TableCellRenderer getRenderer(final BaseInjection injection) {
459 return booleanCellRenderer;
461 }, new ColumnInfo<BaseInjection, BaseInjection>("Display Name") {
462 @Override
463 public BaseInjection valueOf(final BaseInjection injection) {
464 return injection;
467 @Override
468 public Comparator<BaseInjection> getComparator() {
469 return displayNameComparator;
472 @Override
473 public TableCellRenderer getRenderer(final BaseInjection injection) {
474 return displayNameCellRenderer;
476 }, new ColumnInfo<BaseInjection, BaseInjection>("Language") {
477 @Override
478 public BaseInjection valueOf(final BaseInjection injection) {
479 return injection;
482 @Override
483 public Comparator<BaseInjection> getComparator() {
484 return languageComparator;
487 @Override
488 public TableCellRenderer getRenderer(final BaseInjection injection) {
489 return languageCellRenderer;
494 private static BooleanTableCellRenderer createBooleanCellRenderer() {
495 return new BooleanTableCellRenderer() {
496 @Override
497 public Component getTableCellRendererComponent(final JTable table,
498 final Object value,
499 final boolean isSelected,
500 final boolean hasFocus,
501 final int row,
502 final int column) {
503 return setLabelColors(super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column), table, isSelected, row);
508 private static TableCellRenderer createLanguageCellRenderer() {
509 return new TableCellRenderer() {
510 final JLabel label = new JLabel();
512 public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus,
513 final int row,
514 final int column) {
515 final BaseInjection injection = (BaseInjection)value;
516 final Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
517 final FileType fileType = language == null ? null : language.getAssociatedFileType();
518 label.setIcon(fileType == null ? null : fileType.getIcon());
519 label.setText(language == null ? injection.getInjectedLanguageId() : language.getDisplayName());
520 setLabelColors(label, table, isSelected, row);
521 return label;
526 private TableCellRenderer createDisplayNameCellRenderer() {
527 return new TableCellRenderer() {
528 final SimpleColoredComponent myLabel = new SimpleColoredComponent();
529 final SimpleColoredText myText = new SimpleColoredText();
531 public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus,
532 final int row,
533 final int column) {
534 myLabel.clear();
535 final BaseInjection injection = (BaseInjection)value;
536 final SimpleTextAttributes grayAttrs = isSelected ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES;
537 myText.append(injection.getSupportId() + ": ", grayAttrs);
538 mySupports.get(injection.getSupportId()).setupPresentation(injection, myText, isSelected);
539 myText.appendToComponent(myLabel);
540 myText.clear();
541 setLabelColors(myLabel, table, isSelected, row);
542 return myLabel;
547 private static Component setLabelColors(final Component label, final JTable table, final boolean isSelected, final int row) {
548 if (label instanceof JComponent) {
549 ((JComponent)label).setOpaque(isSelected);
551 label.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
552 label.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
553 return label;
556 private void doImportAction(final DataContext dataContext) {
557 final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, false) {
558 @Override
559 public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
560 return super.isFileVisible(file, showHiddenFiles) &&
561 (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == StdFileTypes.ARCHIVE);
564 @Override
565 public boolean isFileSelectable(VirtualFile file) {
566 return file.getFileType() == StdFileTypes.XML;
569 descriptor.setDescription("Please select the configuration file (usually named IntelliLang.xml) to import.");
570 descriptor.setTitle("Import Configuration");
572 descriptor.putUserData(LangDataKeys.MODULE_CONTEXT, LangDataKeys.MODULE.getData(dataContext));
574 final FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, myProject);
576 final SplitterProportionsData splitterData = PeerFactory.getInstance().getUIHelper().createSplitterProportionsData();
577 splitterData.externalizeFromDimensionService("IntelliLang.ImportSettingsKey.SplitterProportions");
579 final VirtualFile[] files = chooser.choose(null, myProject);
580 if (files.length != 1) return;
581 try {
582 final Configuration cfg = Configuration.load(files[0].getInputStream());
583 if (cfg == null) {
584 Messages.showWarningDialog(myProject, "The selected file does not contain any importable configuration.", "Nothing to Import");
585 return;
587 final Map<String,Set<BaseInjection>> currentMap =
588 ContainerUtil.classify(myInjections.iterator(), new Convertor<BaseInjection, String>() {
589 public String convert(final BaseInjection o) {
590 return o.getSupportId();
593 final List<BaseInjection> originalInjections = new ArrayList<BaseInjection>();
594 final List<BaseInjection> newInjections = new ArrayList<BaseInjection>();
595 //// remove duplicates
596 //for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
597 // final Set<BaseInjection> currentInjections = currentMap.get(supportId);
598 // if (currentInjections == null) continue;
599 // for (BaseInjection injection : currentInjections) {
600 // Configuration.importInjections(newInjections, Collections.singleton(injection), originalInjections, newInjections);
601 // }
603 //myInjections.clear();
604 //myInjections.addAll(newInjections);
606 for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
607 final Set<BaseInjection> currentInjections = currentMap.get(supportId);
608 final List<BaseInjection> importingInjections = cfg.getInjections(supportId);
609 if (currentInjections == null) {
610 newInjections.addAll(importingInjections);
611 continue;
613 else {
614 Configuration.importInjections(currentInjections, importingInjections, originalInjections, newInjections);
617 myInjections.removeAll(originalInjections);
618 myInjections.addAll(newInjections);
619 for (BaseInjection injection : newInjections) {
620 injection.initializePlaces(true);
622 ((ListTableModel<BaseInjection>)myInjectionsTable.getModel()).setItems(myInjections);
623 final int n = newInjections.size();
624 if (n > 1) {
625 Messages.showInfoMessage(myProject, n + " entries have been successfully imported", "Import Successful");
627 else if (n == 1) {
628 Messages.showInfoMessage(myProject, "One entry has been successfully imported", "Import Successful");
630 else {
631 Messages.showInfoMessage(myProject, "No new entries have been imported", "Import");
634 catch (Exception e1) {
635 Configuration.LOG.error("Unable to load Settings", e1);
637 final String msg = e1.getLocalizedMessage();
638 Messages.showErrorDialog(myProject, msg != null && msg.length() > 0 ? msg : e1.toString(), "Could not load Settings");