2013-02-06 15:40:17 +01:00
|
|
|
package org.gcube.portlets.user.workspace.client.view;
|
|
|
|
|
|
|
|
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
|
|
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
|
|
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.ViewSwitchType;
|
|
|
|
import org.gcube.portlets.user.workspace.client.event.SwitchViewEvent;
|
|
|
|
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
|
|
|
import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel;
|
|
|
|
|
|
|
|
import com.extjs.gxt.ui.client.event.BaseEvent;
|
|
|
|
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
|
|
import com.extjs.gxt.ui.client.event.Events;
|
|
|
|
import com.extjs.gxt.ui.client.event.Listener;
|
|
|
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
|
|
import com.extjs.gxt.ui.client.widget.button.Button;
|
|
|
|
import com.extjs.gxt.ui.client.widget.form.Radio;
|
|
|
|
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
|
|
|
|
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
|
|
|
|
|
|
|
/**
|
2019-02-22 14:40:20 +01:00
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
2013-02-06 15:40:17 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class ExplorerPanel extends LayoutContainer {
|
|
|
|
|
|
|
|
private Radio radioTree = null;
|
|
|
|
private Radio radioSmartFolder = null;
|
|
|
|
private AsyncTreePanel asycTreePanel = null;
|
|
|
|
private final RadioGroup radioGroup = new RadioGroup();
|
|
|
|
private ContentPanel expPanel = null;
|
|
|
|
private ToolBar toolBar = new ToolBar();
|
|
|
|
private Radio radioMessages;
|
|
|
|
private Button buttBulk = new Button(ConstantsExplorer.LOADER);
|
|
|
|
private boolean isMessagesInstanced;
|
|
|
|
private boolean isSmartFolderInstanced;
|
|
|
|
private boolean isOnlyTreeInstanced;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default instance an async tree to navigate user workspace
|
2019-02-22 12:37:09 +01:00
|
|
|
*
|
2013-02-06 15:40:17 +01:00
|
|
|
* @param instancingSmartFolder
|
2019-02-22 12:37:09 +01:00
|
|
|
* instancing smart folder
|
2013-02-06 15:40:17 +01:00
|
|
|
* @param instancingMessages
|
2019-02-22 12:37:09 +01:00
|
|
|
* instancing messages
|
|
|
|
* @param selectRootItem
|
|
|
|
* select root
|
2013-02-06 15:40:17 +01:00
|
|
|
*/
|
|
|
|
public ExplorerPanel(boolean instancingSmartFolder, boolean instancingMessages, boolean selectRootItem) {
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
this.isMessagesInstanced = instancingMessages;
|
2013-02-06 15:40:17 +01:00
|
|
|
this.isSmartFolderInstanced = instancingSmartFolder;
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
setBorders(false);
|
|
|
|
initRadioButtons();
|
|
|
|
initToolBar();
|
|
|
|
this.asycTreePanel = new AsyncTreePanel();
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
this.expPanel = new ContentPanel();
|
|
|
|
this.expPanel.setHeaderVisible(false);
|
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
// smartFolderPanel.setVisible(false);
|
|
|
|
// messagesPanel.setVisible(false);
|
2013-02-06 15:40:17 +01:00
|
|
|
asycTreePanel.setVisible(true);
|
|
|
|
expPanel.add(asycTreePanel);
|
2019-02-22 12:37:09 +01:00
|
|
|
// expPanel.add(smartFolderPanel);
|
|
|
|
// expPanel.add(messagesPanel);
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
// BULK
|
|
|
|
// REMOVED 2016-09-15 CHECK SVN
|
|
|
|
// buttBulk.setIcon(Resources.getIconBulkUpdate());
|
|
|
|
// buttBulk.setVisible(false);
|
|
|
|
// addListnerOnBulk();
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
add(expPanel);
|
|
|
|
}
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
/**
|
|
|
|
* Instance only tree
|
2019-02-22 12:37:09 +01:00
|
|
|
*
|
2013-02-06 15:40:17 +01:00
|
|
|
* @param instancingOnlyTree
|
2019-02-22 12:37:09 +01:00
|
|
|
* only tree
|
|
|
|
* @param selectRootItem
|
|
|
|
* select root item
|
2013-02-06 15:40:17 +01:00
|
|
|
*/
|
|
|
|
public ExplorerPanel(boolean instancingOnlyTree, boolean selectRootItem) {
|
|
|
|
|
|
|
|
this.isOnlyTreeInstanced = instancingOnlyTree;
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
setBorders(false);
|
|
|
|
initRadioButtons();
|
|
|
|
this.asycTreePanel = new AsyncTreePanel();
|
2019-02-22 12:37:09 +01:00
|
|
|
this.asycTreePanel.loadRootItem(selectRootItem); // load root item
|
2013-02-06 15:40:17 +01:00
|
|
|
this.expPanel = new ContentPanel();
|
|
|
|
this.expPanel.setHeaderVisible(false);
|
2019-02-22 12:37:09 +01:00
|
|
|
// asycTreePanel.setVisible(true);
|
2013-02-06 15:40:17 +01:00
|
|
|
expPanel.add(asycTreePanel);
|
|
|
|
add(expPanel);
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
private void addListnerOnBulk() {
|
|
|
|
buttBulk.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
@Override
|
|
|
|
public void componentSelected(ButtonEvent ce) {
|
2019-02-22 12:37:09 +01:00
|
|
|
// BulkCreatorWindow.getInstance().show();
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
public void setLoadingBulk(boolean bool) {
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
buttBulk.setVisible(true);
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
if (!bool)
|
2013-02-06 15:40:17 +01:00
|
|
|
buttBulk.setIcon(Resources.getIconLoadingOff());
|
|
|
|
else
|
|
|
|
buttBulk.setIcon(Resources.getIconLoading());
|
|
|
|
|
|
|
|
toolBar.layout();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initRadioButtons() {
|
|
|
|
|
|
|
|
this.radioTree = new Radio();
|
|
|
|
this.radioSmartFolder = new Radio();
|
|
|
|
this.radioMessages = new Radio();
|
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
// radioTree.setId(ConstantsExplorer.TREE);
|
2013-02-06 15:40:17 +01:00
|
|
|
radioTree.setBoxLabel(ConstantsExplorer.TREE);
|
|
|
|
radioTree.setValue(true);
|
|
|
|
radioTree.setValueAttribute(ConstantsExplorer.TREE);
|
|
|
|
radioGroup.add(radioTree);
|
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
// radioSmartFolder.setId(ConstantsExplorer.SMARTFOLDER);
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
if (isSmartFolderInstanced) {
|
2013-02-06 15:40:17 +01:00
|
|
|
radioSmartFolder.setBoxLabel(ConstantsExplorer.SMARTFOLDER);
|
|
|
|
radioSmartFolder.setValueAttribute(ConstantsExplorer.SMARTFOLDER);
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
radioGroup.add(radioSmartFolder);
|
|
|
|
}
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
if (isMessagesInstanced) {
|
2013-02-06 15:40:17 +01:00
|
|
|
radioMessages.setBoxLabel(ConstantsExplorer.MESSAGES);
|
|
|
|
radioMessages.setValueAttribute(ConstantsExplorer.MESSAGES);
|
|
|
|
radioGroup.add(radioMessages);
|
|
|
|
}
|
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
// radioGroup.setFieldLabel("Afecto");
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
radioGroup.setStyleAttribute("margin-left", "20px");
|
|
|
|
|
|
|
|
radioGroup.addListener(Events.Change, new Listener<BaseEvent>() {
|
|
|
|
public void handleEvent(BaseEvent be) {
|
|
|
|
|
2016-09-15 16:42:20 +02:00
|
|
|
Radio selectedRadio = radioGroup.getValue();
|
2019-02-22 12:37:09 +01:00
|
|
|
// System.out.println("radio value:"
|
|
|
|
// +selectedRadio.getValueAttribute());
|
|
|
|
// System.out.println("id" + selectedRadio.getId());
|
2013-02-06 15:40:17 +01:00
|
|
|
if (selectedRadio.getValueAttribute().compareTo(ConstantsExplorer.SMARTFOLDER.toString()) == 0)
|
|
|
|
switchView(ViewSwitchType.SmartFolder);
|
2019-02-22 12:37:09 +01:00
|
|
|
else if (selectedRadio.getValueAttribute().compareTo(ConstantsExplorer.TREE.toString()) == 0)
|
|
|
|
switchView(ViewSwitchType.Tree);
|
|
|
|
else
|
|
|
|
switchView(ViewSwitchType.Messages);
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
private void initToolBar() {
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
toolBar.add(radioGroup);
|
|
|
|
// toolBar.add(buttBulk);
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void switchView(ViewSwitchType type) {
|
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
if (type.compareTo(ViewSwitchType.Tree) == 0) {
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
asycTreePanel.setVisible(true);
|
|
|
|
AppControllerExplorer.getEventBus().fireEvent(new SwitchViewEvent(ViewSwitchType.Tree));
|
2019-02-22 12:37:09 +01:00
|
|
|
// asycTreePanel.setSearch(false);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2019-02-22 12:37:09 +01:00
|
|
|
} else if (type.compareTo(ViewSwitchType.SmartFolder) == 0) {
|
2013-02-06 15:40:17 +01:00
|
|
|
asycTreePanel.setVisible(false);
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
AppControllerExplorer.getEventBus().fireEvent(new SwitchViewEvent(ViewSwitchType.SmartFolder));
|
|
|
|
|
|
|
|
// this.expPanel.setVisible(shortuctsPanel.getElement(), false);
|
|
|
|
// this.expPanel.setVisible(asycTreePanel.getElement(), true);
|
2019-02-22 12:37:09 +01:00
|
|
|
} else {
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
asycTreePanel.setVisible(false);
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
2016-09-15 16:42:20 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public AsyncTreePanel getAsycTreePanel() {
|
|
|
|
return asycTreePanel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSmartFolderInstanced() {
|
|
|
|
return isSmartFolderInstanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMessagesInstanced(boolean isMessagesInstanced) {
|
|
|
|
this.isMessagesInstanced = isMessagesInstanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSmartFolderInstanced(boolean isSmartFolderInstanced) {
|
|
|
|
this.isSmartFolderInstanced = isSmartFolderInstanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOnlyTreeInstanced() {
|
|
|
|
return isOnlyTreeInstanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOnlyTreeInstanced(boolean isOnlyTreeInstanced) {
|
|
|
|
this.isOnlyTreeInstanced = isOnlyTreeInstanced;
|
|
|
|
}
|
|
|
|
}
|