Skip to content

Commit

Permalink
v1.0.3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pehrs committed May 2, 2024
1 parent d020d4b commit 4a5449c
Show file tree
Hide file tree
Showing 28 changed files with 106 additions and 1,641 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ hs_err*
### MISC ###
src/main/resources/build-info.properties

verifier-all.jar
verification*
42 changes: 12 additions & 30 deletions src/main/java/com/pehrs/vespa/yql/plugin/YQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.wm.RegisterToolWindowTask;
import com.intellij.openapi.wm.RegisterToolWindowTaskBuilder;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindowFactory;
Expand All @@ -29,6 +30,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import kotlin.Unit;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -40,8 +42,7 @@ public class YQL implements StartupActivity {

private static final Logger log = LoggerFactory.getLogger(YQL.class);

public final static String TOOL_WINDOW_ID = "YqlVespaResultsWindow";
public final static String TOOL_WINDOW_TITLE = "Vespa Results";
public final static String TOOL_WINDOW_ID = "Vespa Results";

public YQL() {
}
Expand Down Expand Up @@ -160,42 +161,23 @@ public static String getDefaultBrowserScript() {
}

@NotNull
public static ToolWindow getVespaToolWindow(Project project, ToolWindowFactory intialFactory) {
public static ToolWindow getVespaToolWindow(Project project) {
ToolWindowManager mgr = ToolWindowManager.getInstance(project);
ToolWindow toolWindow = mgr.getToolWindow(TOOL_WINDOW_ID);
if (toolWindow == null) {
// log.warn("No tool window, let's try to create it :-)");
toolWindow = mgr.registerToolWindow(new RegisterToolWindowTask(
TOOL_WINDOW_ID,
ToolWindowAnchor.BOTTOM,
null,
false,
true,
false,
true,
intialFactory,
YqlIcons.FILE,
() -> TOOL_WINDOW_TITLE
)
);
}
return toolWindow;
return mgr.getToolWindow(TOOL_WINDOW_ID);
}

@Override
public void runActivity(@NotNull Project project) {
// Run once at startup :-)
log.debug("vespa-yql-plugin STARTUP!");

// ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
// ToolWindow toolWindow = toolWindowManager.getToolWindow(
// VespaLogContent.TOOL_WINDOW_ID);
// if(toolWindow != null) {
// toolWindow.setAutoHide(true);
// toolWindow.hide();
// toolWindow.remove();
// }

ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOL_WINDOW_ID);
if(toolWindow != null) {
toolWindow.setAutoHide(true);
toolWindow.hide();
// toolWindow.remove();
}

ApplicationManager.getApplication().executeOnPooledThread(() -> {
for (; ; ) { // ever
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/com/pehrs/vespa/yql/plugin/dock/YqlDockFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,17 @@ public class YqlDockFactory implements ToolWindowFactory, DumbAware { // }, YqlA

Project project;
private YqlDockPanel settingsComponent;
// private YqlAppSettingsComponent settingsComponent;

@Override
public boolean isApplicable(@NotNull Project project) {
return project != null;
}

@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {

this.project = project;

// YqlAppSettingsStateListener.addListener(this);

// this.settingsComponent = new YqlAppSettingsComponent(project, false);
this.settingsComponent = new YqlDockPanel(project);
ContentManager contentManager = toolWindow.getContentManager();
Content content = contentManager.getFactory().createContent(settingsComponent, null, false);
contentManager.addContent(content);
}


// @Override
// public void stateChanged(YqlAppSettingsState instance) {
// this.settingsComponent.refresh();
// }
}
134 changes: 15 additions & 119 deletions src/main/java/com/pehrs/vespa/yql/plugin/dock/YqlDockPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,12 @@ public class YqlDockPanel extends JBPanel implements YqlAppSettingsStateListener
private static final Logger log = LoggerFactory.getLogger(YqlDockPanel.class);

private final Project project;
// private DefaultMutableTreeNode configRoot;
// private DefaultTreeModel treeModel;
// private DnDAwareTree configTree;

private JBTable clusterTable;
private VespaClusterStatusTableModel clusterTableModel;
private AnActionButton configActionBtn;
private AnActionButton openLogsConfigBtn;
private AnAction configAction;
private AnAction openLogsConfig;
private boolean openLogsConfigEnabled = true;


public YqlDockPanel(Project project) {
Expand All @@ -72,73 +70,6 @@ private void createComponents() {

JBLabel label = new JBLabel();

// this.configRoot = new DefaultMutableTreeNode();
// this.configRoot.setUserObject("Vespa Clusters");
// this.treeModel = new DefaultTreeModel(configRoot);
// this.configTree = new DnDAwareTree(treeModel);
//
// this.configTree.addMouseListener(new MouseAdapter() {
// @Override
// public void mouseClicked(MouseEvent e) {
// if (e.getClickCount() >= 2) {
// TreePath path = configTree.getLeadSelectionPath();
// if (path == null) {
// super.mouseClicked(e);
// return;
// }
// DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
// Object userObj = node.getUserObject();
// if (userObj instanceof VespaClusterConfig config) {
// // This is a double click :-)
// YqlAppSettingsState settings = YqlAppSettingsState.getInstance();
// settings.currentConnection = config.name;
// YqlAppSettingsStateListener.notifyListeners(settings);
// }
// super.mouseClicked(e);
// }
//// if (e.getClickCount() == 1) {
//// // Selected
//// TreePath path = configTree.getLeadSelectionPath();
//// DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
//// Object userObj = node.getUserObject();
//// if (userObj instanceof VespaClusterConfig config) {
//// nameField.setText(config.name);
//// queryEndpointField.setText(config.queryEndpoint);
//// configEndpointField.setText(config.configEndpoint);
//// }
//// }
// }
// });
//
// //
// // Renderer
// //
// this.configTree.setCellRenderer((tree, value, selected, expanded, leaf, row, hasFocus) -> {
// DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
// if (node == configRoot) {
// label.setText("Vespa Clusters");
// label.setIcon(Nodes.ConfigFolder);
// } else {
// Object uo = node.getUserObject();
// if (uo instanceof VespaClusterConfig config) {
// label.setText(String.format("%s - %s", config.name, config.queryEndpoint));
// YqlAppSettingsState settings = YqlAppSettingsState.getInstance();
// if (config.name.equals(settings.currentConnection)) {
// // label.setIcon(Actions.Checked);
// label.setIcon(Diff.GutterCheckBoxSelected);
// } else {
// // label.setIcon(YqlIcons.FILE);
// // label.setIcon(null);
// label.setIcon(Diff.GutterCheckBox);
// }
// } else {
// label.setText("" + uo);
// label.setIcon(null);
// }
// }
// return label;
// });

this.clusterTableModel = new VespaClusterStatusTableModel();
this.clusterTable = new JBTable(clusterTableModel);
this.clusterTable.addMouseListener(new MouseAdapter() {
Expand Down Expand Up @@ -248,39 +179,8 @@ public void vespaClusterStatusUpdated() {
.disableRemoveAction()
.disableDownAction()
.disableUpAction();
// decorator.addExtraAction(
// AnActionButton.fromAction(new DumbAwareAction("Add Connection", "", General.Add) {
// public void actionPerformed(@NotNull AnActionEvent e) {
// if (e == null) {
// return;
// }
// if (project != null) {
// YqlAddConnectionDialog dialog = new YqlAddConnectionDialog(project);
// dialog.show();
// }
// }
// }));
// decorator.addExtraAction(
// AnActionButton.fromAction(new DumbAwareAction("Delete Connection", "", General.Remove) {
// public void actionPerformed(@NotNull AnActionEvent e) {
// if (e == null) {
// return;
// }
//
// DefaultMutableTreeNode selected =
// (DefaultMutableTreeNode) configTree.getLeadSelectionPath().getLastPathComponent();
// VespaClusterConfig config = (VespaClusterConfig) selected.getUserObject();
//
// YqlAppSettingsState settings = YqlAppSettingsState.getInstance();
// settings.removeClusterConfig(config);
// YqlAppSettingsStateListener.notifyListeners(settings);
//
// System.out.println(
// "Delete connection!!!" + configTree.getLeadSelectionPath().getLastPathComponent());
// }
// }));

this.configActionBtn = new AnActionButton("Config", "Open configuration", General.Settings ) {
this.configAction = new AnAction("Config", "Open configuration", General.Settings ) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
if (e == null) {
Expand All @@ -290,7 +190,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
// "com.pehrs.vespa.yql.plugin.settings.YqlAppSettingsConfigurable");
}
};
decorator.addExtraAction(configActionBtn);
decorator.addExtraAction(configAction);

AnAction reloadAction = new AnAction("Refresh Vespa Cluster Status", "...", Actions.Refresh) {
public void actionPerformed(@NotNull AnActionEvent e) {
Expand All @@ -304,7 +204,13 @@ public void actionPerformed(@NotNull AnActionEvent e) {
}
};
decorator.addExtraAction(reloadAction);
this.openLogsConfigBtn = new AnActionButton("Open Vespa Logs", "...", General.Warning) {
this.openLogsConfig = new AnAction("Open Vespa Logs", "...", General.Warning) {

@Override
public void update(@NotNull AnActionEvent event) {
event.getPresentation().setEnabledAndVisible(openLogsConfigEnabled);
}

public void actionPerformed(@NotNull AnActionEvent e) {
if (e == null) {
return;
Expand All @@ -315,8 +221,8 @@ public void actionPerformed(@NotNull AnActionEvent e) {
}
};
YqlAppSettingsState settings = YqlAppSettingsState.getInstance();
openLogsConfigBtn.setEnabled(settings.doMonitorLogs);
decorator.addExtraAction(openLogsConfigBtn);
this.openLogsConfigEnabled = settings.doMonitorLogs;
decorator.addExtraAction(openLogsConfig);

JPanel treePanel = decorator.createPanel();
treePanel.setBorder(Borders.empty());
Expand Down Expand Up @@ -347,16 +253,6 @@ public void actionPerformed(@NotNull AnActionEvent e) {
super.add(myMainPanel, BorderLayout.NORTH);
}

// public void addClusterConfig(VespaClusterConfig config) {
// this.configRoot.add(new DefaultMutableTreeNode(config, false));
// }

// public void setVespaClusterConfigs(List<VespaClusterConfig> configs) {
// configRoot.removeAllChildren();
// configs.stream().forEach(config -> addClusterConfig(config));
// treeModel.nodeStructureChanged(configRoot);
// }

public void refresh() {
// YqlAppSettingsState settings = YqlAppSettingsState.getInstance();
// setVespaClusterConfigs(settings.clusterConfigs);
Expand All @@ -366,7 +262,7 @@ public void refresh() {
@Override
public void stateChanged(YqlAppSettingsState instance) {
YqlAppSettingsState settings = YqlAppSettingsState.getInstance();
openLogsConfigBtn.setEnabled(settings.doMonitorLogs);
this.openLogsConfigEnabled = settings.doMonitorLogs;
this.refresh();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ public void init(@NotNull ToolWindow toolWindow) {

}

public boolean isApplicable(@NotNull Project project) {
// FIXME: Check if project is a Java or Vespa project!!!
return project != null;
}


@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
// Create an instance of your custom content component
Expand All @@ -48,7 +42,7 @@ public static void openLogs(Project project) {

// FIXME: Check to see if we Should open the log view here!

ToolWindow toolWindow = YQL.getVespaToolWindow(project, factory);
ToolWindow toolWindow = YQL.getVespaToolWindow(project);
if (toolWindow != null) {
final ToolWindow win = toolWindow;
@NotNull ContentManager contentManager = win.getContentManager();
Expand Down
Loading

0 comments on commit 4a5449c

Please sign in to comment.