Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Ctrl+C and Ctrl+P in a simple view
Ctrl+C and Ctrl+P in a simple view [message #127156] Thu, 11 September 2003 01:44 Go to next message
Eclipse UserFriend
Originally posted by: loyaliu.21cn.com

I have a simple view as the following.
This view has only a Text widget, but the Ctrl+C and Ctrl+P can't work. I
don't know why!
Who can help me?


import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.part.ViewPart;


/**
* This sample class demonstrates how to plug-in a new
* workbench view. The view shows data obtained from the
* model. The sample creates a dummy model on the fly,
* but a real implementation would connect to the model
* available either in this or another plug-in (e.g. the workspace).
* The view is connected to the model using a content provider.
* <p>
* The view uses a label provider to define how model
* objects should be presented in the view. Each
* view can present the same model objects using
* different labels and icons, if needed. Alternatively,
* a single label provider can be shared between views
* in order to ensure that objects of the same type are
* presented in the same way everywhere.
* <p>
*/

public class SampleView extends ViewPart {
ConvPanel te=null;
Text my=null;

/**
* The constructor.
*/
public SampleView() {
}

/**
* This is a callback that will allow us
* to create the viewer and initialize it.
*/
public void createPartControl(Composite parent) {
createME4(parent);
//createME3(parent);
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
}

private void createME4(Composite parent) {
parent.setLayout(new FillLayout());
my = new Text(parent,SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
}

private void createME3(Composite parent) {
Shell sh = new Shell(parent.getShell());
sh.setLayout(new FillLayout());
te = new ConvPanel();
te.create(sh,SWT.NONE);
sh.pack();
sh.open();
}

private void createME(Composite parent) {
MultiSessionPanel te = new MultiSessionPanel();
te.create(parent,SWT.NONE);
Session ss = new Session(){

public Account getAccount() {
// TODO Auto-generated method stub
return null;
}

public Connection getConnection() {
// TODO Auto-generated method stub
return null;
}

public String getId() {
// TODO Auto-generated method stub
return "32141234";
}

public String getSessionShowName() {
// TODO Auto-generated method stub
return "asdfasdfasdf";
}

public void addBuddy(Buddy buddy) {
// TODO Auto-generated method stub

}

public void removeBuddy(Buddy buddy) {
// TODO Auto-generated method stub

}

public void sendMessage(MimeMessage msg) {
// TODO Auto-generated method stub

}

public BuddyList getBuddyList() {
// TODO Auto-generated method stub
return null;
}};
te.addSession(ss);
}

private void hookContextMenu() {
// MenuManager menuMgr = new MenuManager("#PopupMenu");
// menuMgr.setRemoveAllWhenShown(true);
// menuMgr.addMenuListener(new IMenuListener() {
// public void menuAboutToShow(IMenuManager manager) {
// SampleView.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) {

}

private void fillContextMenu(IMenuManager manager) {
}

private void fillLocalToolBar(IToolBarManager manager) {
}

private void makeActions() {

}

private void hookDoubleClickAction() {
}
private void showMessage(String message) {
// MessageDialog.openInformation(
// this.getControl().getShell(),
// "Sample View",
// message);
}

/**
* Passing the focus request to the viewer's control.
*/
public void setFocus() {
my.setFocus();
}
}

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Re: Ctrl+C and Ctrl+V in a simple view [message #127169 is a reply to message #127156] Thu, 11 September 2003 02:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: loyaliu.21cn.com

should be Ctrl+C and Ctrl+V
On Thu, 11 Sep 2003 13:44:04 +0800, loya <loyaliu@21cn.com> wrote:

> I have a simple view as the following.
> This view has only a Text widget, but the Ctrl+C and Ctrl+P can't work. I
> don't know why!
> Who can help me?
>
>
> import org.eclipse.jface.action.IMenuManager;
> import org.eclipse.jface.action.IToolBarManager;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Shell;
.........
> }
>



--
loya
Re: Ctrl+C and Ctrl+P in a simple view [message #127470 is a reply to message #127156] Thu, 11 September 2003 10:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

Look at the class org.eclipse.ui.actions.TextActionHandler.

Simon :-)

"loya" <loyaliu@21cn.com> wrote in message
news:oprvbl7q0ojxeiby@news.eclipse.org...
> I have a simple view as the following.
> This view has only a Text widget, but the Ctrl+C and Ctrl+P can't work. I
> don't know why!
> Who can help me?
>
>
> import org.eclipse.jface.action.IMenuManager;
> import org.eclipse.jface.action.IToolBarManager;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Text;
> import org.eclipse.ui.IActionBars;
> import org.eclipse.ui.part.ViewPart;
>
>
> /**
> * This sample class demonstrates how to plug-in a new
> * workbench view. The view shows data obtained from the
> * model. The sample creates a dummy model on the fly,
> * but a real implementation would connect to the model
> * available either in this or another plug-in (e.g. the workspace).
> * The view is connected to the model using a content provider.
> * <p>
> * The view uses a label provider to define how model
> * objects should be presented in the view. Each
> * view can present the same model objects using
> * different labels and icons, if needed. Alternatively,
> * a single label provider can be shared between views
> * in order to ensure that objects of the same type are
> * presented in the same way everywhere.
> * <p>
> */
>
> public class SampleView extends ViewPart {
> ConvPanel te=null;
> Text my=null;
>
> /**
> * The constructor.
> */
> public SampleView() {
> }
>
> /**
> * This is a callback that will allow us
> * to create the viewer and initialize it.
> */
> public void createPartControl(Composite parent) {
> createME4(parent);
> //createME3(parent);
> makeActions();
> hookContextMenu();
> hookDoubleClickAction();
> contributeToActionBars();
> }
>
> private void createME4(Composite parent) {
> parent.setLayout(new FillLayout());
> my = new Text(parent,SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
> }
>
> private void createME3(Composite parent) {
> Shell sh = new Shell(parent.getShell());
> sh.setLayout(new FillLayout());
> te = new ConvPanel();
> te.create(sh,SWT.NONE);
> sh.pack();
> sh.open();
> }
>
> private void createME(Composite parent) {
> MultiSessionPanel te = new MultiSessionPanel();
> te.create(parent,SWT.NONE);
> Session ss = new Session(){
>
> public Account getAccount() {
> // TODO Auto-generated method stub
> return null;
> }
>
> public Connection getConnection() {
> // TODO Auto-generated method stub
> return null;
> }
>
> public String getId() {
> // TODO Auto-generated method stub
> return "32141234";
> }
>
> public String getSessionShowName() {
> // TODO Auto-generated method stub
> return "asdfasdfasdf";
> }
>
> public void addBuddy(Buddy buddy) {
> // TODO Auto-generated method stub
>
> }
>
> public void removeBuddy(Buddy buddy) {
> // TODO Auto-generated method stub
>
> }
>
> public void sendMessage(MimeMessage msg) {
> // TODO Auto-generated method stub
>
> }
>
> public BuddyList getBuddyList() {
> // TODO Auto-generated method stub
> return null;
> }};
> te.addSession(ss);
> }
>
> private void hookContextMenu() {
> // MenuManager menuMgr = new MenuManager("#PopupMenu");
> // menuMgr.setRemoveAllWhenShown(true);
> // menuMgr.addMenuListener(new IMenuListener() {
> // public void menuAboutToShow(IMenuManager manager) {
> // SampleView.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) {
>
> }
>
> private void fillContextMenu(IMenuManager manager) {
> }
>
> private void fillLocalToolBar(IToolBarManager manager) {
> }
>
> private void makeActions() {
>
> }
>
> private void hookDoubleClickAction() {
> }
> private void showMessage(String message) {
> // MessageDialog.openInformation(
> // this.getControl().getShell(),
> // "Sample View",
> // message);
> }
>
> /**
> * Passing the focus request to the viewer's control.
> */
> public void setFocus() {
> my.setFocus();
> }
> }
>
> --
> Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Re: Ctrl+C and Ctrl+P in a simple view [message #127911 is a reply to message #127470] Thu, 11 September 2003 22:26 Go to previous message
Eclipse UserFriend
Originally posted by: loyaliu.21cn.com

Thank you very much!

Now it work!

On Thu, 11 Sep 2003 10:30:00 -0400, Simon Arsenault <simon@ibm.oti.lab>
wrote:

> Look at the class org.eclipse.ui.actions.TextActionHandler.
>
> Simon :-)
>
> "loya" <loyaliu@21cn.com> wrote in message
> news:oprvbl7q0ojxeiby@news.eclipse.org...
>> I have a simple view as the following.
>> This view has only a Text widget, but the Ctrl+C and Ctrl+P can't work.
>> I
>> don't know why!
>> Who can help me?
>>
>>
>> import org.eclipse.jface.action.IMenuManager;
>> import org.eclipse.jface.action.IToolBarManager;
>> import org.eclipse.swt.SWT;
>> import org.eclipse.swt.layout.FillLayout;
>> import org.eclipse.swt.widgets.Composite;
>> import org.eclipse.swt.widgets.Shell;
>> import org.eclipse.swt.widgets.Text;
>> import org.eclipse.ui.IActionBars;
>> import org.eclipse.ui.part.ViewPart;
>>
>>
>> /**
>> * This sample class demonstrates how to plug-in a new
>> * workbench view. The view shows data obtained from the
>> * model. The sample creates a dummy model on the fly,
>> * but a real implementation would connect to the model
>> * available either in this or another plug-in (e.g. the workspace).
>> * The view is connected to the model using a content provider.
>> * <p>
>> * The view uses a label provider to define how model
>> * objects should be presented in the view. Each
>> * view can present the same model objects using
>> * different labels and icons, if needed. Alternatively,
>> * a single label provider can be shared between views
>> * in order to ensure that objects of the same type are
>> * presented in the same way everywhere.
>> * <p>
>> */
>>
>> public class SampleView extends ViewPart {
>> ConvPanel te=null;
>> Text my=null;
>>
>> /**
>> * The constructor.
>> */
>> public SampleView() {
>> }
>>
>> /**
>> * This is a callback that will allow us
>> * to create the viewer and initialize it.
>> */
>> public void createPartControl(Composite parent) {
>> createME4(parent);
>> //createME3(parent);
>> makeActions();
>> hookContextMenu();
>> hookDoubleClickAction();
>> contributeToActionBars();
>> }
>>
>> private void createME4(Composite parent) {
>> parent.setLayout(new FillLayout());
>> my = new Text(parent,SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
>> }
>>
>> private void createME3(Composite parent) {
>> Shell sh = new Shell(parent.getShell());
>> sh.setLayout(new FillLayout());
>> te = new ConvPanel();
>> te.create(sh,SWT.NONE);
>> sh.pack();
>> sh.open();
>> }
>>
>> private void createME(Composite parent) {
>> MultiSessionPanel te = new MultiSessionPanel();
>> te.create(parent,SWT.NONE);
>> Session ss = new Session(){
>>
>> public Account getAccount() {
>> // TODO Auto-generated method stub
>> return null;
>> }
>>
>> public Connection getConnection() {
>> // TODO Auto-generated method stub
>> return null;
>> }
>>
>> public String getId() {
>> // TODO Auto-generated method stub
>> return "32141234";
>> }
>>
>> public String getSessionShowName() {
>> // TODO Auto-generated method stub
>> return "asdfasdfasdf";
>> }
>>
>> public void addBuddy(Buddy buddy) {
>> // TODO Auto-generated method stub
>>
>> }
>>
>> public void removeBuddy(Buddy buddy) {
>> // TODO Auto-generated method stub
>>
>> }
>>
>> public void sendMessage(MimeMessage msg) {
>> // TODO Auto-generated method stub
>>
>> }
>>
>> public BuddyList getBuddyList() {
>> // TODO Auto-generated method stub
>> return null;
>> }};
>> te.addSession(ss);
>> }
>>
>> private void hookContextMenu() {
>> // MenuManager menuMgr = new MenuManager("#PopupMenu");
>> // menuMgr.setRemoveAllWhenShown(true);
>> // menuMgr.addMenuListener(new IMenuListener() {
>> // public void menuAboutToShow(IMenuManager manager) {
>> // SampleView.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) {
>>
>> }
>>
>> private void fillContextMenu(IMenuManager manager) {
>> }
>>
>> private void fillLocalToolBar(IToolBarManager manager) {
>> }
>>
>> private void makeActions() {
>>
>> }
>>
>> private void hookDoubleClickAction() {
>> }
>> private void showMessage(String message) {
>> // MessageDialog.openInformation(
>> // this.getControl().getShell(),
>> // "Sample View",
>> // message);
>> }
>>
>> /**
>> * Passing the focus request to the viewer's control.
>> */
>> public void setFocus() {
>> my.setFocus();
>> }
>> }
>>
>> --
>> Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
>
>
>



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Previous Topic:can eclipse2.1 install in Mandrake8.0
Next Topic:WordRule highlighting substrings when it shouldn't
Goto Forum:
  


Current Time: Sun Jul 27 06:24:58 EDT 2025

Powered by FUDForum. Page generated in 0.52862 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top