mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new sorters
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.plugins.sorters;
|
||||
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginTable;
|
||||
import com.intellij.ide.plugins.PluginTableModel;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public abstract class AbstractSortByAction extends ToggleAction {
|
||||
protected final PluginTable myTable;
|
||||
protected final PluginTableModel myModel;
|
||||
|
||||
public AbstractSortByAction(String name, PluginTable table, PluginTableModel model) {
|
||||
super(name, name, null);
|
||||
myTable = table;
|
||||
myModel = model;
|
||||
}
|
||||
|
||||
public abstract boolean isSelected();
|
||||
|
||||
protected abstract void setSelected(boolean state);
|
||||
|
||||
@Override
|
||||
public final boolean isSelected(AnActionEvent e) {
|
||||
return isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setSelected(AnActionEvent e, boolean state) {
|
||||
IdeaPluginDescriptor[] selected = myTable.getSelectedObjects();
|
||||
setSelected(state);
|
||||
myModel.sort();
|
||||
if (selected != null) {
|
||||
myTable.select(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.plugins.sorters;
|
||||
|
||||
import com.intellij.ide.plugins.PluginTable;
|
||||
import com.intellij.ide.plugins.PluginTableModel;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class SortByDownloadsAction extends AbstractSortByAction {
|
||||
public SortByDownloadsAction(PluginTable table, PluginTableModel model) {
|
||||
super("Downloads", table, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return myModel.isSortByDownloads();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setSelected(boolean state) {
|
||||
myModel.setSortByDownloads(state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.plugins.sorters;
|
||||
|
||||
import com.intellij.ide.plugins.PluginTable;
|
||||
import com.intellij.ide.plugins.PluginTableModel;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class SortByRatingAction extends AbstractSortByAction {
|
||||
public SortByRatingAction(PluginTable table, PluginTableModel model) {
|
||||
super("Rating", table, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return myModel.isSortByRating();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setSelected(boolean state) {
|
||||
myModel.setSortByRating(state);
|
||||
}
|
||||
}
|
||||
+4
-17
@@ -15,37 +15,24 @@
|
||||
*/
|
||||
package com.intellij.ide.plugins.sorters;
|
||||
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginTable;
|
||||
import com.intellij.ide.plugins.PluginTableModel;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class SortByStatusAction extends ToggleAction {
|
||||
private final PluginTable myTable;
|
||||
private final PluginTableModel myModel;
|
||||
|
||||
public class SortByStatusAction extends AbstractSortByAction {
|
||||
public SortByStatusAction(PluginTable pluginTable, PluginTableModel pluginsModel) {
|
||||
super("Status", "Status", null);
|
||||
myTable = pluginTable;
|
||||
myModel = pluginsModel;
|
||||
super("Status", pluginTable, pluginsModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
public boolean isSelected() {
|
||||
return myModel.isSortByStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
IdeaPluginDescriptor[] selected = myTable.getSelectedObjects();
|
||||
public void setSelected(boolean state) {
|
||||
myModel.setSortByStatus(state);
|
||||
myModel.sort();
|
||||
if (selected != null) {
|
||||
myTable.select(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.plugins.sorters;
|
||||
|
||||
import com.intellij.ide.plugins.PluginTable;
|
||||
import com.intellij.ide.plugins.PluginTableModel;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class SortByUpdatedAction extends AbstractSortByAction {
|
||||
public SortByUpdatedAction(PluginTable table, PluginTableModel model) {
|
||||
super("Last Updated", table, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return myModel.isSortByUpdated();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setSelected(boolean state) {
|
||||
myModel.setSortByUpdated(state);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user