Author: seelmann
Date: Mon Jan 1 16:11:25 2007
New Revision: 491716
URL: http://svn.apache.org/viewvc?view=rev&rev=491716
Log:
Added OpenFileAction, added useful actions and key bindings for browser plugin
Added:
directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/OpenFileAction.java
directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/PathEditorInput.java
Modified:
directory/trunks/ldapstudio/ldapstudio-rcp/META-INF/MANIFEST.MF
directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/ApplicationActionBarAdvisor.java
directory/trunks/ldapstudio/ldapstudio-rcp/src/main/resources/org/apache/directory/ldapstudio/messages.properties
Modified: directory/trunks/ldapstudio/ldapstudio-rcp/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-rcp/META-INF/MANIFEST.MF?view=diff&rev=491716&r1=491715&r2=491716
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-rcp/META-INF/MANIFEST.MF (original)
+++ directory/trunks/ldapstudio/ldapstudio-rcp/META-INF/MANIFEST.MF Mon Jan 1 16:11:25 2007
@@ -6,10 +6,10 @@
Bundle-Activator: org.apache.directory.ldapstudio.Activator
Bundle-Vendor: apache.org
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
+Require-Bundle: org.eclipse.core.runtime,
org.eclipse.update.core,
- org.eclipse.update.ui
+ org.eclipse.update.ui,
+ org.eclipse.ui
Eclipse-LazyStart: true
Bundle-ClassPath: .,
lib/nlog4j-1.2.24.jar
Modified: directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/ApplicationActionBarAdvisor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/ApplicationActionBarAdvisor.java?view=diff&rev=491716&r1=491715&r2=491716
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/ApplicationActionBarAdvisor.java
(original)
+++ directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/ApplicationActionBarAdvisor.java
Mon Jan 1 16:11:25 2007
@@ -23,6 +23,7 @@
import org.apache.directory.ldapstudio.actions.AddExtensionAction;
import org.apache.directory.ldapstudio.actions.ManageExtensionsAction;
+import org.apache.directory.ldapstudio.actions.OpenFileAction;
import org.apache.directory.ldapstudio.actions.UpdateAction;
import org.apache.directory.ldapstudio.view.ImageKeys;
import org.eclipse.jface.action.GroupMarker;
@@ -55,10 +56,16 @@
*/
public class ApplicationActionBarAdvisor extends ActionBarAdvisor
{
+ private OpenFileAction openFileAction;
private IWorkbenchAction closeAction;
private IWorkbenchAction closeAllAction;
private IWorkbenchAction saveAction;
+ private IWorkbenchAction saveAsAction;
private IWorkbenchAction saveAllAction;
+ private IWorkbenchAction printAction;
+ private IWorkbenchAction refreshAction;
+ private IWorkbenchAction renameAction;
+ private IWorkbenchAction moveAction;
private IWorkbenchAction exitAction;
private IWorkbenchAction aboutAction;
private IWorkbenchAction preferencesAction;
@@ -79,8 +86,10 @@
private IWorkbenchAction pasteAction;
private IWorkbenchAction deleteAction;
private IWorkbenchAction selectAllAction;
+ private IWorkbenchAction findAction;
private IContributionItem perspectivesList;
private IContributionItem viewsList;
+ private IContributionItem reopenEditorsList;
/**
@@ -114,18 +123,36 @@
register( newAction );
newAction.setText( "New..." );
+ openFileAction = new OpenFileAction( window );
+ register(openFileAction);
+
closeAction = ActionFactory.CLOSE.create( window );
register( closeAction );
-
+
closeAllAction = ActionFactory.CLOSE_ALL.create( window );
register( closeAllAction );
saveAction = ActionFactory.SAVE.create( window );
register( saveAction );
+
+ saveAsAction = ActionFactory.SAVE_AS.create( window );
+ register( saveAsAction );
saveAllAction = ActionFactory.SAVE_ALL.create( window );
register( saveAllAction );
+ printAction = ActionFactory.PRINT.create( window );
+ register( printAction );
+
+ moveAction = ActionFactory.MOVE.create( window );
+ register( moveAction );
+
+ renameAction = ActionFactory.RENAME.create( window );
+ register( renameAction );
+
+ refreshAction = ActionFactory.REFRESH.create( window );
+ register( refreshAction );
+
importAction = ActionFactory.IMPORT.create( window );
register( importAction );
@@ -159,6 +186,9 @@
selectAllAction = ActionFactory.SELECT_ALL.create( window );
register( selectAllAction );
+ findAction = ActionFactory.FIND.create( window );
+ register( findAction );
+
closePerspectiveAction = ActionFactory.CLOSE_PERSPECTIVE.create( window );
register( closePerspectiveAction );
@@ -187,6 +217,7 @@
viewsList = ContributionItemFactory.VIEWS_SHORTLIST.create( window );
perspectivesList = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create( window
);
+ reopenEditorsList = ContributionItemFactory.REOPEN_EDITORS.create( window );
}
@@ -210,17 +241,31 @@
// Populating File Menu
fileMenu.add( newAction );
+ fileMenu.add( new GroupMarker( IWorkbenchActionConstants.NEW_EXT ) );
+ fileMenu.add( openFileAction );
+ fileMenu.add( new GroupMarker( IWorkbenchActionConstants.OPEN_EXT ) );
fileMenu.add( new Separator() );
fileMenu.add( closeAction );
fileMenu.add( closeAllAction );
+ fileMenu.add( new GroupMarker( IWorkbenchActionConstants.CLOSE_EXT ) );
fileMenu.add( new Separator() );
fileMenu.add( saveAction );
+ fileMenu.add( saveAsAction );
fileMenu.add( saveAllAction );
+ fileMenu.add( new GroupMarker( IWorkbenchActionConstants.SAVE_EXT ) );
+ fileMenu.add( new Separator() );
+ fileMenu.add( refreshAction );
+ fileMenu.add( new Separator() );
+ fileMenu.add( printAction );
+ fileMenu.add( new GroupMarker( IWorkbenchActionConstants.PRINT_EXT ) );
fileMenu.add( new Separator() );
fileMenu.add( importAction );
fileMenu.add( exportAction );
+ fileMenu.add( new GroupMarker( IWorkbenchActionConstants.IMPORT_EXT ) );
fileMenu.add( new Separator() );
fileMenu.add( propertiesAction );
+ fileMenu.add( reopenEditorsList );
+ fileMenu.add( new GroupMarker( IWorkbenchActionConstants.MRU ) );
fileMenu.add( new Separator() );
fileMenu.add( exitAction );
@@ -234,6 +279,12 @@
editMenu.add( new Separator() );
editMenu.add( deleteAction );
editMenu.add( selectAllAction );
+ editMenu.add( new Separator() );
+ editMenu.add( moveAction );
+ editMenu.add( renameAction );
+ editMenu.add( new Separator() );
+ editMenu.add( findAction );
+
// Window
MenuManager perspectiveMenu = new MenuManager("Open Perspective", "openPerspective");
@@ -267,6 +318,8 @@
{
IToolBarManager toolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT );
coolBar.add( new ToolBarContributionItem( toolbar, Application.PLUGIN_ID + ".toolbar"
) ); //$NON-NLS-1$
+
+ toolbar.add( newAction );
toolbar.add( preferencesAction );
}
}
Added: directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/OpenFileAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/OpenFileAction.java?view=auto&rev=491716
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/OpenFileAction.java
(added)
+++ directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/OpenFileAction.java
Mon Jan 1 16:11:25 2007
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.directory.ldapstudio.actions;
+
+
+import java.io.File;
+import java.text.MessageFormat;
+
+import org.apache.directory.ldapstudio.Messages;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorRegistry;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PartInitException;
+
+
+/**
+ * The Action is used to open files from file system.
+ * It creates IPathEditorInput inputs.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenFileAction extends Action implements IWorkbenchWindowActionDelegate
+{
+
+ /** The workbench window */
+ private IWorkbenchWindow workbenchWindow;
+
+
+ /**
+ * Creates a new instance of OpenFileAction.
+ */
+ public OpenFileAction()
+ {
+ setId( "org.apache.directory.ldapstudio.openFile" ); //$NON-NLS-1$
+ setText( Messages.getString( "OpenFileAction.Open_File" ) ); //$NON-NLS-1$
+ setToolTipText( Messages.getString( "OpenFileAction.Open_file_from_filesystem" )
); //$NON-NLS-1$
+ setEnabled( true );
+ }
+
+
+ /**
+ * Creates a new instance of OpenFileAction.
+ *
+ * @param window the workbench window
+ */
+ public OpenFileAction( IWorkbenchWindow window )
+ {
+ this();
+ init( window );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose()
+ {
+ workbenchWindow = null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void init( IWorkbenchWindow window )
+ {
+ workbenchWindow = window;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run( IAction action )
+ {
+ run();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run()
+ {
+ // get path
+ FileDialog dialog = new FileDialog( workbenchWindow.getShell(), SWT.OPEN );
+ dialog.setText( Messages.getString( "OpenFileAction.Open_File" ) ); //$NON-NLS-1$
+ String path = dialog.open();
+ if ( path == null || path.length() == 0 )
+ {
+ // canceled
+ return;
+ }
+
+ // check file
+ File file = new File( path );
+ if ( !file.exists() )
+ {
+ String msg = MessageFormat.format(
+ Messages.getString( "OpenFileAction.File_x_does_not_exist" ), new Object[]
//$NON-NLS-1$
+ { file.getName() } );
+ MessageDialog.openWarning( workbenchWindow.getShell(), Messages
+ .getString( "OpenFileAction.Warning_message" ), msg ); //$NON-NLS-1$
+ return;
+ }
+ if ( !file.canRead() )
+ {
+ String msg = MessageFormat.format(
+ Messages.getString( "OpenFileAction.File_x_is_not_readable" ), new Object[]
//$NON-NLS-1$
+ { file.getName() } );
+ MessageDialog.openWarning( workbenchWindow.getShell(), Messages
+ .getString( "OpenFileAction.Warning_message" ), msg ); //$NON-NLS-1$
+ return;
+ }
+
+ // get editor for this file
+ IWorkbench workbench = workbenchWindow.getWorkbench();
+ IEditorRegistry editorRegistry = workbench.getEditorRegistry();
+ IEditorDescriptor descriptor = editorRegistry.getDefaultEditor( file.getName() );
+
+ if ( descriptor == null )
+ {
+ String msg = MessageFormat.format(
+ Messages.getString( "OpenFileAction.No_appropriate_editor_found_for_x" ),
new Object[] //$NON-NLS-1$
+ { file.getName() } );
+ MessageDialog.openWarning( workbenchWindow.getShell(), Messages
+ .getString( "OpenFileAction.Warning_message" ), msg ); //$NON-NLS-1$
+ return;
+ }
+
+ // create IEdiorInput
+ IPath location = new Path( file.getAbsolutePath() );
+ ImageDescriptor imageDescriptor = descriptor.getImageDescriptor();
+ IPathEditorInput input = new PathEditorInput( location, imageDescriptor );
+
+ // activate editor
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ String editorId = descriptor.getId();
+ try
+ {
+ page.openEditor( input, editorId );
+ }
+ catch ( PartInitException e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+}
\ No newline at end of file
Added: directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/PathEditorInput.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/PathEditorInput.java?view=auto&rev=491716
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/PathEditorInput.java
(added)
+++ directory/trunks/ldapstudio/ldapstudio-rcp/src/main/java/org/apache/directory/ldapstudio/actions/PathEditorInput.java
Mon Jan 1 16:11:25 2007
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.directory.ldapstudio.actions;
+
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+/**
+ * This IEditorInput is used to open files that are located in the local file system.
+ *
+ * Inspired from org.eclipse.ui.internal.editors.text.NonExistingFileEditorInput.java
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PathEditorInput implements IPathEditorInput
+{
+
+ /** The absolute path in local file system */
+ private IPath path;
+
+ /** The image for the input file */
+ private ImageDescriptor imageDescriptor;
+
+
+ /**
+ *
+ * Creates a new instance of PathEditorInput.
+ *
+ * @param path the absolute path
+ * @param imageDescriptor the image for the input file
+ */
+ public PathEditorInput( IPath path, ImageDescriptor imageDescriptor )
+ {
+ if ( path == null )
+ {
+ throw new IllegalArgumentException();
+ }
+
+ this.path = path;
+ this.imageDescriptor = imageDescriptor;
+ }
+
+
+ /**
+ * Returns hash code of the path.
+ */
+ public int hashCode()
+ {
+ return path.hashCode();
+ }
+
+
+ /**
+ * This implemention just compares the paths
+ */
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( o instanceof PathEditorInput )
+ {
+ PathEditorInput input = ( PathEditorInput ) o;
+ return path.equals( input.path );
+ }
+
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean exists()
+ {
+ return path.toFile().exists();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ImageDescriptor getImageDescriptor()
+ {
+ return imageDescriptor;
+ }
+
+
+ /**
+ * Returns the file name only.
+ */
+ public String getName()
+ {
+ return path.toFile().getName();
+ //return path.toString();
+ }
+
+
+ /**
+ * Returns the complete path.
+ */
+ public String getToolTipText()
+ {
+ return path.makeRelative().toOSString();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IPath getPath()
+ {
+ return path;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAdapter( Class adapter )
+ {
+ return Platform.getAdapterManager().getAdapter( this, adapter );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IPersistableElement getPersistable()
+ {
+ return null;
+ }
+
+
+ /**
+ * Returns the path.
+ */
+ public IPath getPath( Object element )
+ {
+ if ( element instanceof PathEditorInput )
+ {
+ PathEditorInput input = ( PathEditorInput ) element;
+ return input.getPath();
+ }
+
+ return null;
+ }
+}
Modified: directory/trunks/ldapstudio/ldapstudio-rcp/src/main/resources/org/apache/directory/ldapstudio/messages.properties
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-rcp/src/main/resources/org/apache/directory/ldapstudio/messages.properties?view=diff&rev=491716&r1=491715&r2=491716
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-rcp/src/main/resources/org/apache/directory/ldapstudio/messages.properties
(original)
+++ directory/trunks/ldapstudio/ldapstudio-rcp/src/main/resources/org/apache/directory/ldapstudio/messages.properties
Mon Jan 1 16:11:25 2007
@@ -48,3 +48,11 @@
WelcomeView.Error=Error \!
WelcomeView.LDAP_Studio_was_unable_to_open_www.apache.org=LDAP Studio was unable to open
http://www.apache.org in your default browser.
WelcomeView.Copyright=\u00A9 Copyright 2006 - Apache Software Foundation
+
+# Strings used by OpenFileAction Class
+OpenFileAction.Open_File=Open File...
+OpenFileAction.Warning_message=Problem
+OpenFileAction.Open_file_from_filesystem=Open file from filesystem
+OpenFileAction.File_x_does_not_exist=File {0} doesn't exist.
+OpenFileAction.File_x_is_not_readable=File {0} isn't readable.
+OpenFileAction.No_appropriate_editor_found_for_x=No appropriate editor found for {0}.
|