Skip to content

Commit

Permalink
Merge pull request #7 from picimako/020
Browse files Browse the repository at this point in the history
v0.2.0
  • Loading branch information
picimako authored Jun 9, 2024
2 parents cb03d30 + 3be9ad5 commit efdb0bf
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 63 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

## [Unreleased]

## [0.2.0]
### Changed
- Updated Lucene to 9.11.0.
- Changed the file chooser dialog in the *Open Index*, *Create Index* dialogs and the *Custom Analyzer* panel to an IntelliJ one to provide
a smoother user experience.
- Replaced the previous GIF loading icon to a sharper SVG one.

## [0.1.0]
### Added
- Integrated Lucene's Luke application into this IDE plugin. Code changes from Luke are applied up to version 9.10.0.
- Integrated Lucene's Luke application into this IDE plugin. Code changes from Luke are applied up to version 9.10.0.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Lucas (Apache Lucene's Luke for IntelliJ)

[![Version](https://img.shields.io/jetbrains/plugin/v/24567-lucas.svg)](https://plugins.jetbrains.com/plugin/24567-lucas)

<!-- Plugin description -->
Lucas is a plugin that brings [Apache Lucene's Luke](https://github.com/apache/lucene/tree/main/lucene/luke) standalone desktop application to IntelliJ-based IDEs.
Its goal is to provide a way to use Luke in an integrated way.
Expand All @@ -19,7 +21,6 @@ Main differences between Lucas and Luke:
- Luke's themes are removed. The plugin uses the theme currently set in the IDE.
- Some buttons, icons, and UI element sizes are different, and may be located slightly elsewhere, to provide a smoother integration and user experience.
- The Help menu and About dialog have been removed.

<!-- Plugin description end -->

![Lucas UI Overview tab](lucas_ui.png)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repositories {

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
val luceneVersion = "9.10.0"
val luceneVersion = "9.11.0"

implementation("org.apache.lucene:lucene-core:$luceneVersion")

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.picimako.lucas
pluginName = Lucas
pluginRepositoryUrl = https://github.com/picimako/lucas
# SemVer format -> https://semver.org
pluginVersion = 0.1.0
pluginVersion = 0.2.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 241
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.JBColor;
import com.intellij.ui.TitledSeparator;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBScrollPane;
Expand Down Expand Up @@ -130,7 +131,7 @@ private void initialize() {
infoTA.setLineWrap(true);
infoTA.setEditable(false);
infoTA.setText(MessageUtils.getLocalizedMessage("add_document.info"));
infoTA.setForeground(Color.gray);
infoTA.setForeground(JBColor.GRAY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.AnimatedIcon;
import com.intellij.ui.components.JBScrollPane;
import com.picimako.org.apache.lucene.luke.app.IndexHandler;
import com.picimako.org.apache.lucene.luke.app.desktop.LukeMain;
import org.apache.lucene.index.CheckIndex;
import org.apache.lucene.luke.app.LukeState;
import org.apache.lucene.luke.app.desktop.util.ImageUtils;
import org.apache.lucene.luke.app.desktop.util.MessageUtils;
import org.apache.lucene.luke.app.desktop.util.TextAreaPrintStream;
import org.apache.lucene.luke.models.tools.IndexTools;
Expand Down Expand Up @@ -102,7 +102,7 @@ private void initialize() {
repairBtn.setEnabled(false);
repairBtn.addActionListener(listeners::repairIndex);

indicatorLbl.setIcon(ImageUtils.createImageIcon("indicator.gif", 20, 20));
indicatorLbl.setIcon(AnimatedIcon.Default.INSTANCE);

logArea.setEditable(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
package com.picimako.org.apache.lucene.luke.app.desktop.components.dialog.menubar;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.ui.AnimatedIcon;
import com.intellij.ui.TitledSeparator;
import com.intellij.util.PathUtil;
import com.picimako.org.apache.lucene.luke.app.IndexHandler;
import com.picimako.org.apache.lucene.luke.app.desktop.LukeMain;
import com.picimako.org.apache.lucene.luke.app.desktop.PreferencesImpl;
import org.apache.lucene.luke.app.desktop.util.FontUtils;
import org.apache.lucene.luke.app.desktop.util.ImageUtils;
import org.apache.lucene.luke.app.desktop.util.MessageUtils;
import org.apache.lucene.luke.app.desktop.util.URLLabel;
import org.apache.lucene.luke.models.tools.IndexTools;
Expand All @@ -34,7 +38,6 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.NamedThreadFactory;
import org.apache.lucene.util.SuppressForbidden;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
Expand Down Expand Up @@ -79,11 +82,13 @@ public class CreateIndexDialogFactory extends DialogWrapper {

private final JLabel indicatorLbl = new JLabel();

private final ListenerFunctions listeners = new ListenerFunctions();
private final ListenerFunctions listeners;

public CreateIndexDialogFactory(@Nullable Project project) throws IOException {
super(project, LukeMain.getOwnerFrame(), false, IdeModalityType.IDE);
this.indexHandler = IndexHandler.getInstance();
this.listeners = new ListenerFunctions(project);

setTitle(MessageUtils.getLocalizedMessage("createindex.dialog.title"));
setSize(600, 360);
initialize();
Expand Down Expand Up @@ -119,7 +124,7 @@ private void initialize() {
dataBrowseBtn.setPreferredSize(new Dimension(100, 30));
dataBrowseBtn.addActionListener(listeners::browseDataDirectory);

indicatorLbl.setIcon(ImageUtils.createImageIcon("indicator.gif", 20, 20));
indicatorLbl.setIcon(AnimatedIcon.Default.INSTANCE);
indicatorLbl.setVisible(false);

setOKButtonText(MessageUtils.getLocalizedMessage("button.create"));
Expand Down Expand Up @@ -222,6 +227,11 @@ private JPanel buttons() {
}

private class ListenerFunctions {
private final Project project;

public ListenerFunctions(Project project) {
this.project = project;
}

void browseLocationDirectory(ActionEvent e) {
browseDirectory(locationTF);
Expand All @@ -231,16 +241,15 @@ void browseDataDirectory(ActionEvent e) {
browseDirectory(dataDirTF);
}

@SuppressForbidden(reason = "JFilechooser#getSelectedFile() returns java.io.File")
private void browseDirectory(JTextField tf) {
JFileChooser fc = new JFileChooser(new File(tf.getText()));
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setFileHidingEnabled(false);
int retVal = fc.showOpenDialog(getContentPanel());
if (retVal == JFileChooser.APPROVE_OPTION) {
File dir = fc.getSelectedFile();
tf.setText(dir.getAbsolutePath());
}
FileChooser.chooseFile(
//Selects directories only
new FileChooserDescriptor(false, true, false, false, false, false)
.withShowHiddenFiles(true),
project,
getContentPanel(),
VfsUtil.findFileByIoFile(new File(tf.getText()), true),
selectedDirectory -> tf.setText(PathUtil.toSystemDependentName(selectedDirectory.getPath())));
}

void createIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.AnimatedIcon;
import com.intellij.ui.JBColor;
import com.picimako.org.apache.lucene.luke.app.IndexHandler;
import com.picimako.org.apache.lucene.luke.app.desktop.LukeMain;
import org.apache.lucene.luke.app.LukeState;
import org.apache.lucene.luke.app.desktop.util.ImageUtils;
import org.apache.lucene.luke.app.desktop.util.MessageUtils;
import org.apache.lucene.luke.app.desktop.util.StyleConstants;
import org.apache.lucene.luke.models.LukeException;
Expand Down Expand Up @@ -173,7 +173,7 @@ private JPanel destinationDirPanel() {
private JPanel statusPanel() {
JPanel status = new JPanel(new FlowLayout(FlowLayout.LEADING));
status.setOpaque(false);
indicatorLbl.setIcon(ImageUtils.createImageIcon("indicator.gif", 20, 20));
indicatorLbl.setIcon(AnimatedIcon.Default.INSTANCE);
indicatorLbl.setVisible(false);
status.add(statusLbl);
status.add(indicatorLbl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
package com.picimako.org.apache.lucene.luke.app.desktop.components.dialog.menubar;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.ui.TitledSeparator;
import com.intellij.util.PathUtil;
import com.picimako.org.apache.lucene.luke.app.DirectoryHandler;
import com.picimako.org.apache.lucene.luke.app.IndexHandler;
import com.picimako.org.apache.lucene.luke.app.desktop.LukeMain;
Expand Down Expand Up @@ -82,13 +86,15 @@ public final class OpenIndexDialogFactory extends DialogWrapper {

private final JRadioButton keepAllCommitsRB = new JRadioButton();

private final ListenerFunctions listeners = new ListenerFunctions();
private final ListenerFunctions listeners;

public OpenIndexDialogFactory(@Nullable Project project) throws IOException {
super(project, LukeMain.getOwnerFrame(), false, IdeModalityType.IDE);
this.prefs = PreferencesImpl.getInstance();
this.directoryHandler = DirectoryHandler.getInstance();
this.indexHandler = IndexHandler.getInstance();
this.listeners = new ListenerFunctions(project);

setTitle(MessageUtils.getLocalizedMessage("openindex.dialog.title"));
setSize(600, 420);
initialize();
Expand Down Expand Up @@ -234,19 +240,26 @@ protected void doOKAction() {
}

private class ListenerFunctions {
private final Project project;

public ListenerFunctions(Project project) {
this.project = project;
}

@SuppressForbidden(reason = "FileChooser#getSelectedFile() returns java.io.File")
void browseDirectory(ActionEvent e) {
File currentDir = getLastOpenedDirectory();
JFileChooser fc = currentDir == null ? new JFileChooser() : new JFileChooser(currentDir);
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setFileHidingEnabled(false);
int retVal = fc.showOpenDialog(getContentPanel());
if (retVal == JFileChooser.APPROVE_OPTION) {
File dir = fc.getSelectedFile();
idxPathCombo.insertItemAt(dir.getAbsolutePath(), 0);
idxPathCombo.setSelectedIndex(0);
}

FileChooser.chooseFile(
//Selects directories only
new FileChooserDescriptor(false, true, false, false, false, false)
.withShowHiddenFiles(true),
project,
getContentPanel(),
currentDir != null ? VfsUtil.findFileByIoFile(currentDir, true) : null,
selectedDirectory -> {
idxPathCombo.insertItemAt(PathUtil.toSystemDependentName(selectedDirectory.getPath()), 0);
idxPathCombo.setSelectedIndex(0);
});
}

@SuppressForbidden(reason = "JFileChooser constructor takes java.io.File")
Expand All @@ -255,7 +268,7 @@ private File getLastOpenedDirectory() {
if (!history.isEmpty()) {
Path path = Paths.get(history.get(0));
if (Files.exists(path)) {
return path.getParent().toAbsolutePath().toFile();
return path.toAbsolutePath().toFile();
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.AnimatedIcon;
import com.intellij.ui.JBIntSpinner;
import com.intellij.ui.components.JBScrollPane;
import com.picimako.org.apache.lucene.luke.app.IndexHandler;
import com.picimako.org.apache.lucene.luke.app.desktop.LukeMain;
import org.apache.lucene.luke.app.desktop.util.ImageUtils;
import org.apache.lucene.luke.app.desktop.util.MessageUtils;
import org.apache.lucene.luke.app.desktop.util.TextAreaPrintStream;
import org.apache.lucene.luke.models.tools.IndexTools;
Expand Down Expand Up @@ -89,7 +89,7 @@ private void initialize() {
expungeCB.setText(MessageUtils.getLocalizedMessage("optimize.checkbox.expunge"));
expungeCB.setOpaque(false);

indicatorLbl.setIcon(ImageUtils.createImageIcon("indicator.gif", 20, 20));
indicatorLbl.setIcon(AnimatedIcon.Default.INSTANCE);

logArea.setEditable(false);
logArea.setLineWrap(true); //Enabled line wrap, so the horizontal scrollbar is not displayed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
package com.picimako.org.apache.lucene.luke.app.desktop.components.fragments.analysis;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.util.PathUtil;
import com.intellij.util.ui.JBUI;
import com.picimako.lucas.LucasBundle;
import com.picimako.org.apache.lucene.luke.app.desktop.MessageBroker;
Expand All @@ -38,16 +41,13 @@
import org.apache.lucene.luke.app.desktop.util.lang.Callable;
import org.apache.lucene.luke.models.analysis.Analysis;
import org.apache.lucene.luke.models.analysis.CustomAnalyzerConfig;
import org.apache.lucene.util.SuppressForbidden;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -69,8 +69,6 @@ public final class CustomAnalyzerPanelProvider implements CustomAnalyzerPanelOpe

private final JTextField confDirTF = new JTextField();

private final JFileChooser fileChooser = new JFileChooser();

private final JButton confDirBtn = new JButton(AllIcons.Actions.MenuOpen);

private final JButton buildBtn = new JButton(AllIcons.Toolwindows.ToolWindowBuild);
Expand Down Expand Up @@ -412,31 +410,30 @@ private JPanel initCustomChainConfigPanel() {

// control methods

@SuppressForbidden(reason = "JFilechooser#getSelectedFile() returns java.io.File")
private void chooseConfigDir() {
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

int ret = fileChooser.showOpenDialog(containerPanel);
if (ret == JFileChooser.APPROVE_OPTION) {
File dir = fileChooser.getSelectedFile();
confDirTF.setText(dir.getAbsolutePath());
}
FileChooser.chooseFile(
//Selects directories only
new FileChooserDescriptor(false, true, false, false, false, false),
project,
containerPanel,
null,
selectedDirectory -> confDirTF.setText(PathUtil.toSystemDependentName(selectedDirectory.getPath())));
}

@SuppressForbidden(reason = "JFilechooser#getSelectedFiles() returns java.io.File[]")
private void loadExternalJars() {
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(true);

int ret = fileChooser.showOpenDialog(containerPanel);
if (ret == JFileChooser.APPROVE_OPTION) {
File[] files = fileChooser.getSelectedFiles();
analysisModel.addExternalJars(Arrays.stream(files).map(File::getAbsolutePath).toList());
operatorRegistry
.get(CustomAnalyzerPanelOperator.class)
.ifPresent(CustomAnalyzerPanelOperator::resetAnalysisComponents);
messageBroker.showStatusMessage("External jars were added.");
}
FileChooser.chooseFiles(
//Selects files including .jars, as multi-selection
new FileChooserDescriptor(true, false, true, true, false, true),
project,
containerPanel,
null,
selectedFiles -> {
analysisModel.addExternalJars(selectedFiles.stream().map(file -> PathUtil.toSystemDependentName(file.getPath())).toList());
operatorRegistry
.get(CustomAnalyzerPanelOperator.class)
.ifPresent(CustomAnalyzerPanelOperator::resetAnalysisComponents);
messageBroker.showStatusMessage("External jars were added.");
});
}

private void buildAnalyzer() {
Expand Down
Loading

0 comments on commit efdb0bf

Please sign in to comment.