Author: dgolovin
Date: 2007-09-19 03:26:17 -0400 (Wed, 19 Sep 2007)
New Revision: 3703
Removed:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamComponentsView.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-848
fix errors under linux.
I found that for some reasons project.localRefresh doesen't works well for Linux, so
after creating projects the natures are not loaded, that's why ejb,ear and test
projects look like General projects.
Now Import operation is used and it works even during workspace is locked by running new
wizard.
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamComponentsView.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamComponentsView.java 2007-09-19
07:26:13 UTC (rev 3702)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamComponentsView.java 2007-09-19
07:26:17 UTC (rev 3703)
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.seam.ui.views;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.DrillDownAdapter;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-
-
-public class SeamComponentsView extends ViewPart {
- private TreeViewer viewer;
- private DrillDownAdapter drillDownAdapter;
- private Action action1;
- private Action action2;
- private Action doubleClickAction;
-
- /*
- * The content provider class is responsible for
- * providing objects to the view. It can wrap
- * existing objects in adapters or simply return
- * objects as-is. These objects may be sensitive
- * to the current input of the view, or ignore
- * it and always show the same content
- * (like Task List, for example).
- */
-
- class TreeObject implements IAdaptable {
- private String name;
- private TreeParent parent;
-
- public TreeObject(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public void setParent(TreeParent parent) {
- this.parent = parent;
- }
- public TreeParent getParent() {
- return parent;
- }
- public String toString() {
- return getName();
- }
- public Object getAdapter(Class key) {
- return null;
- }
- }
-
- class TreeParent extends TreeObject {
- private ArrayList children;
- public TreeParent(String name) {
- super(name);
- children = new ArrayList();
- }
- public void addChild(TreeObject child) {
- children.add(child);
- child.setParent(this);
- }
- public void removeChild(TreeObject child) {
- children.remove(child);
- child.setParent(null);
- }
- public TreeObject [] getChildren() {
- return (TreeObject [])children.toArray(new TreeObject[children.size()]);
- }
- public boolean hasChildren() {
- return children.size()>0;
- }
- }
-
- class ViewContentProvider implements IStructuredContentProvider,
- ITreeContentProvider {
- private TreeParent invisibleRoot;
-
- public void inputChanged(Viewer v, Object oldInput, Object newInput) {
- }
- public void dispose() {
- }
- public Object[] getElements(Object parent) {
- if (parent.equals(getViewSite())) {
- if (invisibleRoot==null) initialize();
- return getChildren(invisibleRoot);
- }
- return getChildren(parent);
- }
- public Object getParent(Object child) {
- if (child instanceof TreeObject) {
- return ((TreeObject)child).getParent();
- }
- return null;
- }
- public Object [] getChildren(Object parent) {
- if (parent instanceof TreeParent) {
- return ((TreeParent)parent).getChildren();
- }
- return new Object[0];
- }
- public boolean hasChildren(Object parent) {
- if (parent instanceof TreeParent)
- return ((TreeParent)parent).hasChildren();
- return false;
- }
-/*
- * We will set up a dummy model to initialize tree heararchy.
- * In a real code, you will connect to a real model and
- * expose its hierarchy.
- */
- private void initialize() {
- TreeParent to1 = new TreeParent("Conetx Variable 1");
- TreeObject class1 = new TreeObject("org.domain.package.Class1");
- TreeObject class2 = new TreeObject("org.domain.package.Class2");
- TreeObject role1 = new TreeObject("role1");
- TreeObject xml1 = new TreeObject("component.xml");
- TreeObject xml2 = new TreeObject("Class3.component.xml");
- to1.addChild(class1);
- to1.addChild(class2);
- to1.addChild(xml1);
- to1.addChild(xml2);
- to1.addChild(role1);
-
- TreeParent to2 = new TreeParent("Conetx Variable 2");
- TreeParent to3 = new TreeParent("Conetx Variable 3");
- TreeParent stateless = new TreeParent("STATELESS");
- stateless.addChild(to1);
- stateless.addChild(to2);
- stateless.addChild(to3);
-
- TreeObject to4 = new TreeParent("Conetx Variable 4");
- TreeParent method = new TreeParent("METHOD");
- method.addChild(to4);
-
- TreeParent event = new TreeParent("EVENT");
-
- TreeParent page = new TreeParent("PAGE");
- TreeParent conversation = new TreeParent("CONVERSATION");
- TreeParent session = new TreeParent("SESSION");
- TreeParent app = new TreeParent("APPLICATION");
- TreeParent bp = new TreeParent("BUSINESS_PROCESS");
- TreeParent unspec = new TreeParent("UNSPECIFIED");
-
- TreeParent root1 = new TreeParent("Seam Project 1");
-
- TreeParent root2 = new TreeParent("Seam Project 2");
-
- root1.addChild(stateless);
- root1.addChild(method);
- root1.addChild(event);
- root1.addChild(page);
- root1.addChild(conversation);
- root1.addChild(session);
- root1.addChild(app);
- root1.addChild(bp);
- root1.addChild(unspec);
-
- invisibleRoot = new TreeParent("");
- invisibleRoot.addChild(root1);
- }
- }
- class ViewLabelProvider extends LabelProvider {
-
- public String getText(Object obj) {
- return obj.toString();
- }
- public Image getImage(Object obj) {
- String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
- if (obj instanceof TreeParent)
- imageKey = ISharedImages.IMG_OBJ_FOLDER;
- return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
- }
- }
- class NameSorter extends ViewerSorter {
- }
-
- /**
- * The constructor.
- */
- public SeamComponentsView() {
- }
-
- /**
- * This is a callback that will allow us
- * to create the viewer and initialize it.
- */
- public void createPartControl(Composite parent) {
- viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- drillDownAdapter = new DrillDownAdapter(viewer);
- viewer.setContentProvider(new ViewContentProvider());
- viewer.setLabelProvider(new ViewLabelProvider());
- viewer.setSorter(new NameSorter());
- viewer.setInput(getViewSite());
- makeActions();
- hookContextMenu();
- hookDoubleClickAction();
- contributeToActionBars();
- }
-
- private void hookContextMenu() {
- MenuManager menuMgr = new MenuManager("#PopupMenu");
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- SeamComponentsView.this.fillContextMenu(manager);
- }
- });
- Menu menu = menuMgr.createContextMenu(viewer.getControl());
- viewer.getControl().setMenu(menu);
- getSite().registerContextMenu(menuMgr, viewer);
- }
-
- private void contributeToActionBars() {
- IActionBars bars = getViewSite().getActionBars();
- fillLocalPullDown(bars.getMenuManager());
- fillLocalToolBar(bars.getToolBarManager());
- }
-
- private void fillLocalPullDown(IMenuManager manager) {
- manager.add(action1);
- manager.add(new Separator());
- manager.add(action2);
- }
-
- private void fillContextMenu(IMenuManager manager) {
- manager.add(action1);
- manager.add(action2);
- manager.add(new Separator());
- drillDownAdapter.addNavigationActions(manager);
- // Other plug-ins can contribute there actions here
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- private void fillLocalToolBar(IToolBarManager manager) {
- manager.add(action1);
- manager.add(action2);
- manager.add(new Separator());
- drillDownAdapter.addNavigationActions(manager);
- }
-
- private void makeActions() {
- action1 = new Action() {
- public void run() {
-
- IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("t9");
- ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(project);
- WebArtifactEdit edit =
- WebArtifactEdit.getWebArtifactEditForRead(project);
- IVirtualComponent com = ComponentCore.createComponent(project);
- IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new
Path("/WEB-INF/classes"));
- IContainer folder = webRootFolder.getUnderlyingFolder();
- webRootFolder.getUnderlyingFolders();
- showMessage(webRootFolder.getUnderlyingFolder().getLocation().toString());
- }
- };
- action1.setText("Action 1");
- action1.setToolTipText("Action 1 tooltip");
- action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
- getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
-
- action2 = new Action() {
- public void run() {
- showMessage("Action 2 executed");
- }
- };
- action2.setText("Action 2");
- action2.setToolTipText("Action 2 tooltip");
- action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
- getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
- doubleClickAction = new Action() {
- public void run() {
- ISelection selection = viewer.getSelection();
- Object obj = ((IStructuredSelection)selection).getFirstElement();
- showMessage("Double-click detected on "+obj.toString());
- }
- };
- }
-
- private void hookDoubleClickAction() {
- viewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- doubleClickAction.run();
- }
- });
- }
- private void showMessage(String message) {
- MessageDialog.openInformation(
- viewer.getControl().getShell(),
- "Seam Components",
- message);
- }
-
- /**
- * Passing the focus request to the viewer's control.
- */
- public void setFocus() {
- viewer.getControl().setFocus();
- }
-}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-09-19
07:26:13 UTC (rev 3702)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-09-19
07:26:17 UTC (rev 3703)
@@ -24,8 +24,11 @@
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
@@ -53,10 +56,12 @@
* @author eskimo
*
*/
-public class SeamRuntimeListFieldEditor extends BaseFieldEditor {
+public class SeamRuntimeListFieldEditor extends BaseFieldEditor implements
ISelectionChangedListener, SelectionListener {
CheckboxTableViewer tableView = null;
Composite root = null;
+ Button rmBtn = null;
+ Button addBtn = null;
/**
* @param name
* @param label
@@ -126,6 +131,7 @@
gd.grabExcessHorizontalSpace = true;
tableView.getControl().setLayoutData(gd);
+ tableView.addSelectionChangedListener(this);
Composite buttons = new Composite(root,SWT.NONE);
buttons.setLayout(new GridLayout(1,false));
@@ -135,7 +141,7 @@
gd.grabExcessVerticalSpace = true;
buttons.setLayoutData(gd);
- final Button addBtn = new Button(buttons,SWT.PUSH);
+ addBtn = new Button(buttons,SWT.PUSH);
addBtn.setText("Add");
gd = new GridData(GridData.FILL_HORIZONTAL,GridData.CENTER,false,false);
gd.horizontalAlignment = GridData.FILL;
@@ -143,30 +149,17 @@
gd.widthHint = 50;
addBtn.setLayoutData(gd);
- addBtn.addSelectionListener(new SelectionListener() {
- /* (non-Javadoc)
- * @see
org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
-
- Wizard wiz = new SeamRuntimeNewWizard((List<SeamRuntime>)getValue(), added);
- WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
- dialog.open();
- tableView.refresh();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
+ addBtn.addSelectionListener(this);
- /*final Button rmBtn = new Button(buttons,SWT.PUSH);
+ rmBtn = new Button(buttons,SWT.PUSH);
rmBtn.setText("Remove");
gd = new GridData(GridData.FILL_HORIZONTAL,GridData.CENTER,false,false);
gd.horizontalAlignment = GridData.FILL;
gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
rmBtn.setLayoutData(gd);
+ rmBtn.addSelectionListener(this);
- final Button editBtn = new Button(buttons,SWT.PUSH);
+ /*final Button editBtn = new Button(buttons,SWT.PUSH);
editBtn.setText("Edit");
gd = new GridData(GridData.FILL_HORIZONTAL,GridData.CENTER,false,false);
gd.horizontalAlignment = GridData.FILL;
@@ -272,32 +265,6 @@
return 1;
}
- public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell(display);
- shell.setLayout(new GridLayout());
- SeamRuntime rt = new SeamRuntime();
- rt.setName("rtName1");
- rt.setDefault(true);
- rt.setHomeDir("/home");
- rt.setVersion(SeamVersion.SEAM_1_2);
- SeamRuntime rt2 = new SeamRuntime();
- rt2.setName("rtName2");
- rt2.setDefault(false);
- rt2.setHomeDir("/home1");
- rt2.setVersion(SeamVersion.SEAM_2_0);
- List<SeamRuntime> rts = Arrays.asList(new SeamRuntime[]{rt,rt2});
-
-
- new
SeamRuntimeListFieldEditor("name","label",rts).doFillIntoGrid(shell);
-
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
- }
-
/**
*
* @param parent
@@ -448,4 +415,40 @@
return true;
}
}
+
+ /**
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection)event.getSelection();
+ selectionChanged((SeamRuntime)selection.getFirstElement());
+ }
+
+ /**
+ * @param firstElement
+ */
+ public void selectionChanged(SeamRuntime selection) {
+ if(selection==null
+ || selection == SeamRuntimeManager.getInstance().getDefaultRuntime()) {
+ } else {
+ }
+ }
+
+ /**
+ * @see
org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
+ /**
+ * @see
org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ if(e.widget==addBtn) {
+ Wizard wiz = new SeamRuntimeNewWizard((List<SeamRuntime>)getValue(), added);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+// } else if(e.widget==rmBtn) {
+ }
+ }
}