mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
parent
79ed051718
commit
1642abfdd1
6 changed files with 388 additions and 13 deletions
|
@ -12,5 +12,8 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.core.resources,
|
||||
org.eclipse.rse.ui,
|
||||
org.eclipse.rse.core,
|
||||
org.eclipse.rse.services
|
||||
org.eclipse.rse.services,
|
||||
org.eclipse.rse.files.ui,
|
||||
org.eclipse.rse.subsystems.files.core,
|
||||
org.eclipse.rse.subsystems.shells.core
|
||||
Eclipse-LazyStart: true
|
||||
|
|
|
@ -16,9 +16,42 @@ Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE.
|
|||
-->
|
||||
<?eclipse version="3.1"?>
|
||||
<plugin>
|
||||
|
||||
<!-- ======================================= -->
|
||||
<!-- Remote Object Popup Menu Actions -->
|
||||
<!-- ======================================= -->
|
||||
<!-- Tutorial #1: Creating a Remote Resource pop-up Menu Action -->
|
||||
<extension point="org.eclipse.rse.ui.popupMenus">
|
||||
<objectContribution id="actions.jar"
|
||||
typecategoryfilter="files"
|
||||
typefilter="file"
|
||||
namefilter="*.jar">
|
||||
<action id="actions.jar.show"
|
||||
enablesFor="1"
|
||||
label="Show contents"
|
||||
tooltip="List contents of this file"
|
||||
class="samples.ui.actions.ShowJarContents">
|
||||
</action>
|
||||
</objectContribution>
|
||||
</extension>
|
||||
|
||||
<!-- ======================================= -->
|
||||
<!-- Remote Object Property Pages -->
|
||||
<!-- ======================================= -->
|
||||
<!-- Tutorial #2: Creating a Remote Resource Property Page -->
|
||||
<extension point="org.eclipse.rse.ui.propertyPages">
|
||||
<page name="Folder Contents"
|
||||
class="samples.ui.propertypages.FolderInfoPropertyPage"
|
||||
id="samples.ui.PropertyPage1"
|
||||
typefilter="folder"
|
||||
typecategoryfilter="files">
|
||||
</page>
|
||||
</extension>
|
||||
|
||||
<!-- ======================================= -->
|
||||
<!-- SubSystem Configuration -->
|
||||
<!-- ======================================= -->
|
||||
<!-- Tutorial #3: Creating a Subsystem Configuration -->
|
||||
<extension
|
||||
point="org.eclipse.rse.ui.subsystemConfiguration">
|
||||
<configuration
|
||||
|
|
|
@ -2,14 +2,18 @@
|
|||
<!DOCTYPE MessageFile SYSTEM "../com.ibm.etools.systems.core/messageFile.dtd">
|
||||
<!-- This is a message file used by SystemMessage and SystemMessageDialog -->
|
||||
<MessageFile Version="1.0">
|
||||
<Component Name="RSE Samples" Abbr="RSS">
|
||||
<Subcomponent Name="General" Abbr="G">
|
||||
<MessageList>
|
||||
<Message ID="1001" Indicator="E">
|
||||
<LevelOne>Sample message</LevelOne>
|
||||
<LevelTwo>This is a sample with one substution variable: %1</LevelTwo>
|
||||
</Message>
|
||||
</MessageList>
|
||||
</Subcomponent>
|
||||
</Component>
|
||||
<Component Name="RSE Samples" Abbr="RSS">
|
||||
<Subcomponent Name="General" Abbr="G">
|
||||
<MessageList>
|
||||
<Message ID="1001" Indicator="E">
|
||||
<LevelOne>Sample message</LevelOne>
|
||||
<LevelTwo>This is a sample with one substution variable: %1</LevelTwo>
|
||||
</Message>
|
||||
<Message ID="1002" Indicator="I">
|
||||
<LevelOne>Processing...</LevelOne>
|
||||
<LevelTwo></LevelTwo>
|
||||
</Message>
|
||||
</MessageList>
|
||||
</Subcomponent>
|
||||
</Component>
|
||||
</MessageFile>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE.
|
||||
################################################################################
|
||||
|
||||
# Tutorial #2: Creating a Remote Resource Property Page
|
||||
pp.size.label=Size
|
||||
pp.size.tooltip=Cumulative size, in bytes
|
||||
pp.files.label=Files
|
||||
|
@ -23,6 +24,7 @@ pp.folders.tooltip=Cumulative number of folders
|
|||
pp.stopButton.label=Stop
|
||||
pp.stopButton.tooltip=Cancel the thread
|
||||
|
||||
# Tutorial #3: Creating a Subsystem Configuration
|
||||
connectorservice.devr.name=DeveloperConnectorService
|
||||
connectorservice.devr.desc=Manages connections to faked remote developer resources.
|
||||
|
||||
|
@ -31,11 +33,10 @@ property.devr_id.name=Id
|
|||
property.devr_id.desc=ID number
|
||||
property.devr_dept.name=Department
|
||||
property.devr_dept.desc=Department number
|
||||
|
||||
property.team_resource.type=Team resource
|
||||
|
||||
filter.default.name=All Teams
|
||||
|
||||
# Tutorial #3a: Adding a Custom Filter
|
||||
property.type.teamfilter=Team filter
|
||||
property.type.devrfilter=Developer filter
|
||||
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
||||
* This program and the accompanying materials are 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE.
|
||||
********************************************************************************/
|
||||
|
||||
package samples.ui.actions;
|
||||
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.files.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction;
|
||||
import org.eclipse.rse.internal.model.SystemRegistry;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem;
|
||||
|
||||
/**
|
||||
* An action that runs a command to display the contents of a Jar file.
|
||||
* The plugin.xml file restricts this action so it only appears for .jar files.
|
||||
*/
|
||||
public class ShowJarContents extends SystemAbstractRemoteFilePopupMenuExtensionAction {
|
||||
|
||||
/**
|
||||
* Constructor for ShowJarContents.
|
||||
*/
|
||||
public ShowJarContents() {
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.actions.SystemAbstractPopupMenuExtensionAction#run()
|
||||
*/
|
||||
public void run() {
|
||||
IRemoteFile selectedFile = getFirstSelectedRemoteFile();
|
||||
String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath(); //$NON-NLS-1$
|
||||
try {
|
||||
runCommand(cmdToRun);
|
||||
} catch(Exception e) {
|
||||
//TODO: Display exception
|
||||
}
|
||||
}
|
||||
|
||||
public IRemoteCmdSubSystem getRemoteCmdSubSystem() {
|
||||
//get the Command subsystem associated with the current host
|
||||
IHost myHost = getSubSystem().getHost();
|
||||
ISubSystem[] subsys = SystemRegistry.getSystemRegistry().getSubSystems(myHost);
|
||||
for (int i=0; i<subsys.length; i++) {
|
||||
if (subsys[i] instanceof IRemoteCmdSubSystem) {
|
||||
IRemoteCmdSubSystem ss = (IRemoteCmdSubSystem) subsys[i];
|
||||
if (ss.getSubSystemConfiguration().supportsCommands()) {
|
||||
// && ss.isConnected()
|
||||
// TODO: Check, if the remote cmd subsys is capable of connecting on demand
|
||||
return ss;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void runCommand(String command) throws Exception
|
||||
{
|
||||
IRemoteCmdSubSystem cmdss = getRemoteCmdSubSystem();
|
||||
if (cmdss!=null && cmdss.isConnected()) {
|
||||
Object[] result = cmdss.runCommand(command, null, "", false); //$NON-NLS-1$
|
||||
//TODO: Display the result, or is this done in the Shell automatically?
|
||||
} else {
|
||||
//TODO: Display error - no command subsystem available
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
||||
* This program and the accompanying materials are 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE.
|
||||
********************************************************************************/
|
||||
|
||||
package samples.ui.propertypages;
|
||||
|
||||
import org.eclipse.rse.files.ui.propertypages.SystemAbstractRemoteFilePropertyPageExtensionAction;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import samples.RSESamplesPlugin;
|
||||
|
||||
/**
|
||||
* A sample property page for a remote object, which in this case is scoped via the
|
||||
* extension point xml to only apply to folder objects.
|
||||
*/
|
||||
public class FolderInfoPropertyPage
|
||||
extends SystemAbstractRemoteFilePropertyPageExtensionAction
|
||||
implements SelectionListener
|
||||
{
|
||||
// gui widgets...
|
||||
private Label sizeLabel, filesLabel, foldersLabel;
|
||||
private Button stopButton;
|
||||
// state...
|
||||
private int totalSize = 0;
|
||||
private int totalFolders = 0;
|
||||
private int totalFiles = 0;
|
||||
private boolean stopped = false;
|
||||
private Thread workerThread;
|
||||
private Runnable guiUpdater;
|
||||
|
||||
/**
|
||||
* Constructor for FolderInfoPropertyPage.
|
||||
*/
|
||||
public FolderInfoPropertyPage()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
// Parent method overrides...
|
||||
// --------------------------
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.files.ui.propertypages.SystemAbstractRemoteFilePropertyPageExtensionAction#createContentArea(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Control createContentArea(Composite parent)
|
||||
{
|
||||
Composite composite = SystemWidgetHelpers.createComposite(parent, 2);
|
||||
// draw the gui
|
||||
sizeLabel = SystemWidgetHelpers.createLabeledLabel(composite,
|
||||
RSESamplesPlugin.getResourceString("pp.size.label"), //$NON-NLS-1$
|
||||
RSESamplesPlugin.getResourceString("pp.size.tooltip"), //$NON-NLS-1$
|
||||
false);
|
||||
filesLabel = SystemWidgetHelpers.createLabeledLabel(composite,
|
||||
RSESamplesPlugin.getResourceString("pp.files.label"), //$NON-NLS-1$
|
||||
RSESamplesPlugin.getResourceString("pp.files.tooltip"), //$NON-NLS-1$
|
||||
false);
|
||||
foldersLabel = SystemWidgetHelpers.createLabeledLabel(composite,
|
||||
RSESamplesPlugin.getResourceString("pp.folders.label"), //$NON-NLS-1$
|
||||
RSESamplesPlugin.getResourceString("pp.folders.tooltip"), //$NON-NLS-1$
|
||||
false);
|
||||
stopButton = SystemWidgetHelpers.createPushButton(composite, null,
|
||||
RSESamplesPlugin.getResourceString("pp.stopButton.label"), //$NON-NLS-1$
|
||||
RSESamplesPlugin.getResourceString("pp.stopButton.tooltip") //$NON-NLS-1$
|
||||
);
|
||||
stopButton.addSelectionListener(this);
|
||||
|
||||
setValid(false); // Disable OK button until thread is done
|
||||
|
||||
// show "Processing..." message
|
||||
setMessage(RSESamplesPlugin.getPluginMessage("RSSG1002")); //$NON-NLS-1$
|
||||
|
||||
// create instance of Runnable to allow asynchronous GUI updates from background thread
|
||||
guiUpdater = new RunnableGUIClass();
|
||||
// spawn a thread to calculate the information
|
||||
workerThread = new RunnableClass(getRemoteFile());
|
||||
workerThread.start();
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercept from PreferencePage. Called when user presses Cancel button.
|
||||
* We stop the background thread.
|
||||
*/
|
||||
public boolean performCancel()
|
||||
{
|
||||
killThread();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercept from DialogPage. Called when dialog going away.
|
||||
* If the user presses the X to close this dialog, we
|
||||
* need to stop that background thread.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
killThread();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method to kill our background thread.
|
||||
* Control doesn't return until it ends.
|
||||
*/
|
||||
private void killThread()
|
||||
{
|
||||
if (!stopped && workerThread.isAlive())
|
||||
{
|
||||
stopped = true;
|
||||
try {
|
||||
workerThread.join(); // wait for thread to end
|
||||
} catch (InterruptedException exc) {}
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------
|
||||
// Methods from SelectionListener interface...
|
||||
// -------------------------------------------
|
||||
|
||||
/**
|
||||
* From SelectionListener
|
||||
*/
|
||||
public void widgetSelected(SelectionEvent event)
|
||||
{
|
||||
if (event.getSource() == stopButton)
|
||||
{
|
||||
stopped = true;
|
||||
stopButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* From SelectionListener
|
||||
*/
|
||||
public void widgetDefaultSelected(SelectionEvent event) {}
|
||||
|
||||
|
||||
// ----------------
|
||||
// Inner classes...
|
||||
// ----------------
|
||||
/**
|
||||
* Inner class encapsulating the background work to be done, so it may be executed
|
||||
* in background thread.
|
||||
*/
|
||||
private class RunnableClass extends Thread
|
||||
{
|
||||
IRemoteFile inputFolder;
|
||||
|
||||
RunnableClass(IRemoteFile inputFolder)
|
||||
{
|
||||
this.inputFolder = inputFolder;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
if (stopped)
|
||||
return;
|
||||
walkFolder(inputFolder);
|
||||
updateGUI();
|
||||
if (!stopped)
|
||||
{
|
||||
stopped = true;
|
||||
updateGUI();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively walk a folder, updating the running tallies.
|
||||
* Update the GUI after processing each subfolder.
|
||||
*/
|
||||
private void walkFolder(IRemoteFile currFolder)
|
||||
{
|
||||
IRemoteFile[] folders = currFolder.getParentRemoteFileSubSystem().listFoldersAndFiles(currFolder);
|
||||
if ((folders != null) && (folders.length>0))
|
||||
{
|
||||
for (int idx=0; !stopped && (idx<folders.length); idx++)
|
||||
{
|
||||
// is this a folder?
|
||||
if (folders[idx].isDirectory())
|
||||
{
|
||||
++totalFolders;
|
||||
walkFolder(folders[idx]);
|
||||
updateGUI();
|
||||
}
|
||||
// is this a file?
|
||||
else
|
||||
{
|
||||
++totalFiles;
|
||||
totalSize += folders[idx].getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end of walkFolder method
|
||||
|
||||
} // end of inner class
|
||||
|
||||
/**
|
||||
* Inner class encapsulating the GUI work to be done from the
|
||||
* background thread.
|
||||
*/
|
||||
private class RunnableGUIClass implements Runnable
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (stopButton.isDisposed())
|
||||
return;
|
||||
if (!stopped)
|
||||
{
|
||||
sizeLabel.setText(Integer.toString(totalSize));
|
||||
filesLabel.setText(Integer.toString(totalFiles));
|
||||
foldersLabel.setText(Integer.toString(totalFolders));
|
||||
}
|
||||
else if (stopped)
|
||||
{
|
||||
setValid(true); // re-enable OK button
|
||||
stopButton.setEnabled(false); // disable Stop button
|
||||
clearMessage(); // clear "Processing..." message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the GUI with the current status
|
||||
*/
|
||||
private void updateGUI()
|
||||
{
|
||||
Display.getDefault().asyncExec(guiUpdater);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue