From d431996e86d5230bff9aeabd84e088a6c6b3469c Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Sun, 12 Aug 2007 10:08:57 +0000 Subject: *** empty log message *** --- .../server/protocol/CDOServerProtocolFactory.java | 14 +- .../org/eclipse/emf/cdo/server/CDOServerUtil.java | 30 + plugins/org.eclipse.emf.cdo.ui/CDO UI.launch | 786 ++++++++++----------- .../org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF | 6 +- plugins/org.eclipse.emf.cdo.ui/plugin.xml | 10 +- .../internal/ui/actions/EditingDomainAction.java | 2 +- .../emf/cdo/internal/ui/actions/EntryAction.java | 2 +- .../emf/cdo/internal/ui/actions/SessionAction.java | 2 +- .../emf/cdo/internal/ui/actions/ViewAction.java | 2 +- .../org/eclipse/emf/cdo/internal/ui/bundle/OM.java | 2 +- .../internal/ui/dialogs/SelectPackageDialog.java | 2 +- .../emf/cdo/internal/ui/editor/CDOEditor.java | 2 +- .../emf/cdo/internal/ui/views/CDOItemProvider.java | 4 +- .../emf/cdo/internal/ui/views/CDOSessionsView.java | 16 +- .../cdo/internal/ui/wizards/NewSessionWizard.java | 107 --- .../internal/ui/wizards/old/NewEditorWizard.java | 127 ---- .../ui/wizards/old/NewEditorWizardPage.java | 439 ------------ .../internal/ui/wizards/old/NewSessionWizard.java | 108 --- .../ui/wizards/old/NewSessionWizardPage.java | 213 ------ .../internal/ui/wizards/steps/RepoNameStep.java | 23 - .../src/org/eclipse/emf/cdo/util/CDOUtil.java | 7 + .../emf/internal/cdo/CDOSessionFactory.java | 13 +- .../cdo/protocol/CDOClientProtocolFactory.java | 15 +- .../emf/internal/cdo/util/ChannelInjector.java | 2 +- .../org.eclipse.net4j.debug/META-INF/MANIFEST.MF | 3 +- plugins/org.eclipse.net4j.debug/build.properties | 6 +- plugins/org.eclipse.net4j.debug/icons/javabean.gif | Bin 0 -> 310 bytes plugins/org.eclipse.net4j.debug/icons/sample.gif | Bin 983 -> 0 bytes plugins/org.eclipse.net4j.debug/plugin.xml | 12 +- .../eclipse/net4j/internal/debug/bundle/OM.java | 2 +- .../org/eclipse/net4j/jms/admin/JMSAdminUtil.java | 7 + .../admin/protocol/JMSAdminProtocolFactory.java | 14 +- .../server/protocol/JMSServerProtocolFactory.java | 14 +- .../admin/JMSAdminServerProtocolFactory.java | 14 +- .../net4j/internal/jms/ConnectionFactoryImpl.java | 4 +- .../eclipse/net4j/internal/jms/ConnectionImpl.java | 11 +- .../org/eclipse/net4j/internal/jms/bundle/OM.java | 2 +- .../jms/protocol/JMSClientProtocolFactory.java | 14 +- .../org/eclipse/net4j/jms/JMSInitialContext.java | 12 +- .../src/org/eclipse/net4j/jms/JMSUtil.java | 7 +- .../net4j/internal/jvm/JVMAcceptorFactory.java | 11 +- .../eclipse/net4j/internal/jvm/JVMConnector.java | 3 +- .../net4j/internal/jvm/JVMConnectorFactory.java | 11 +- .../src/org/eclipse/net4j/jvm/IJVMConstants.java | 21 - plugins/org.eclipse.net4j.tcp/plugin.xml | 1 + .../net4j/internal/tcp/TCPAcceptorFactory.java | 21 +- .../eclipse/net4j/internal/tcp/TCPConnector.java | 3 +- .../net4j/internal/tcp/TCPConnectorFactory.java | 17 +- .../net4j/internal/tcp/TCPSelectorFactory.java | 13 +- .../net4j/internal/tcp/TCPSelectorInjector.java | 5 +- .../src/org/eclipse/net4j/tcp/ITCPConstants.java | 23 - .../eclipse/net4j/tests/AbstractTransportTest.java | 24 +- .../src/org/eclipse/net4j/tests/SignalTest.java | 11 +- .../org/eclipse/net4j/tests/TCPTransportTest.java | 15 +- .../org/eclipse/net4j/tests/TestBufferPool.java | 8 +- .../net4j/tests/signal/TestSignalProtocol.java | 4 +- .../signal/TestSignalServerProtocolFactory.java | 4 +- plugins/org.eclipse.net4j.ui/.options | 2 +- plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF | 13 +- plugins/org.eclipse.net4j.ui/plugin.properties | 2 +- plugins/org.eclipse.net4j.ui/plugin.xml | 18 +- .../net4j/internal/ui/AcceptorContentProvider.java | 4 +- .../internal/ui/ConnectorContentProvider.java | 4 +- .../internal/ui/FactoryTypeContentProvider.java | 2 +- .../org/eclipse/net4j/internal/ui/bundle/OM.java | 5 +- .../net4j/internal/ui/views/AcceptorsView.java | 19 +- .../net4j/internal/ui/views/ConnectorsView.java | 17 +- .../net4j/internal/ui/views/Net4jItemProvider.java | 8 +- .../internal/ui/wizards/NewAcceptorWizard.java | 77 -- .../internal/ui/wizards/NewConnectorWizard.java | 77 -- .../internal/ui/wizards/steps/NewAcceptorStep.java | 46 -- .../ui/wizards/steps/NewConnectorStep.java | 46 -- .../ui/wizards/steps/ProvideConnectorStep.java | 48 -- .../ui/wizards/steps/SelectAcceptorStep.java | 32 - .../ui/wizards/steps/SelectConnectorStep.java | 33 - .../ui/wizards/steps/sample/AccountStep.java | 18 - .../ui/wizards/steps/sample/AddressStep.java | 28 - .../ui/wizards/steps/sample/CustomerStep.java | 17 - .../org/eclipse/net4j/ui/ComboAutoCompleter.java | 92 --- .../net4j/ui/DelegatingContentProvider.java | 71 -- .../eclipse/net4j/ui/StaticContentProvider.java | 52 -- .../net4j/ui/StructuredContentProvider.java | 165 ----- .../src/org/eclipse/net4j/ui/UIActivator.java | 51 -- .../src/org/eclipse/net4j/ui/UIUtil.java | 44 -- .../net4j/ui/actions/LongRunningAction.java | 191 ----- .../org/eclipse/net4j/ui/actions/SafeAction.java | 60 -- .../net4j/ui/views/ContainerItemProvider.java | 385 ---------- .../net4j/ui/views/ContainerNameSorter.java | 17 - .../org/eclipse/net4j/ui/views/ContainerView.java | 270 ------- .../org/eclipse/net4j/ui/views/IElementFilter.java | 19 - .../org/eclipse/net4j/ui/views/ItemProvider.java | 131 ---- .../ui/views/ManagedContainerItemProvider.java | 173 ----- .../org/eclipse/net4j/ui/widgets/BaseDialog.java | 145 ---- .../org/eclipse/net4j/ui/widgets/HistoryText.java | 257 ------- .../net4j/ui/widgets/HistoryTextDialog.java | 138 ---- .../org/eclipse/net4j/ui/widgets/LogDialog.java | 167 ----- .../eclipse/net4j/ui/widgets/MonitorDialog.java | 126 ---- .../eclipse/net4j/ui/widgets/MonitorLogDialog.java | 109 --- .../eclipse/net4j/ui/widgets/PreferenceButton.java | 117 --- .../org/eclipse/net4j/ui/wizards/CompoundStep.java | 345 --------- .../org/eclipse/net4j/ui/wizards/DecisionStep.java | 75 -- .../net4j/ui/wizards/IDecisionProvider.java | 19 - .../org/eclipse/net4j/ui/wizards/IStepVisitor.java | 19 - .../eclipse/net4j/ui/wizards/PagingStrategy.java | 61 -- .../org/eclipse/net4j/ui/wizards/ParallelStep.java | 49 -- .../eclipse/net4j/ui/wizards/SelectionStep.java | 309 -------- .../eclipse/net4j/ui/wizards/SequentialStep.java | 33 - .../net4j/ui/wizards/StaticSelectionStep.java | 83 --- .../src/org/eclipse/net4j/ui/wizards/Step.java | 152 ---- .../net4j/ui/wizards/SteppingExportWizard.java | 30 - .../net4j/ui/wizards/SteppingImportWizard.java | 30 - .../net4j/ui/wizards/SteppingNewWizard.java | 30 - .../eclipse/net4j/ui/wizards/SteppingWizard.java | 205 ------ .../net4j/ui/wizards/SteppingWizardPage.java | 133 ---- .../net4j/ui/wizards/SteppingWorkbenchWizard.java | 42 -- .../org/eclipse/net4j/ui/wizards/StringStep.java | 73 -- .../org/eclipse/net4j/ui/wizards/ValueStep.java | 109 --- plugins/org.eclipse.net4j.util.ui/.classpath | 7 + plugins/org.eclipse.net4j.util.ui/.cvsignore | 2 + plugins/org.eclipse.net4j.util.ui/.options | 1 + plugins/org.eclipse.net4j.util.ui/.project | 28 + .../org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF | 16 + plugins/org.eclipse.net4j.util.ui/about.html | 42 ++ plugins/org.eclipse.net4j.util.ui/build.properties | 12 + plugins/org.eclipse.net4j.util.ui/copyright.txt | 8 + plugins/org.eclipse.net4j.util.ui/epl-v10.html | 319 +++++++++ plugins/org.eclipse.net4j.util.ui/icons/.cvsignore | 1 + .../icons/full/.cvsignore | 1 + .../icons/full/etool16/.cvsignore | 1 + .../icons/full/etool16/add.gif | Bin 0 -> 318 bytes .../icons/full/etool16/delete.gif | Bin 0 -> 351 bytes .../icons/full/etool16/refresh.gif | Bin 0 -> 330 bytes .../icons/full/obj16/.cvsignore | 1 + .../icons/full/obj16/adapter.gif | Bin 0 -> 196 bytes .../icons/full/obj16/factory.gif | Bin 0 -> 211 bytes .../icons/full/obj16/folder.gif | Bin 0 -> 219 bytes .../icons/full/obj16/javabean.gif | Bin 0 -> 310 bytes .../icons/full/view16/.cvsignore | 1 + .../icons/full/view16/container.gif | Bin 0 -> 202 bytes plugins/org.eclipse.net4j.util.ui/license.html | 319 +++++++++ .../org.eclipse.net4j.util.ui/plugin.properties | 33 + plugins/org.eclipse.net4j.util.ui/plugin.xml | 21 + .../net4j/util/internal/ui/SharedIcons.java | 106 +++ .../eclipse/net4j/util/internal/ui/bundle/OM.java | 48 ++ .../util/internal/ui/views/Net4jContainerView.java | 25 + .../util/internal/ui/views/Net4jItemProvider.java | 75 ++ .../eclipse/net4j/util/ui/ComboAutoCompleter.java | 92 +++ .../net4j/util/ui/DelegatingContentProvider.java | 71 ++ .../net4j/util/ui/StaticContentProvider.java | 52 ++ .../net4j/util/ui/StructuredContentProvider.java | 165 +++++ .../src/org/eclipse/net4j/util/ui/UIActivator.java | 51 ++ .../src/org/eclipse/net4j/util/ui/UIUtil.java | 43 ++ .../net4j/util/ui/actions/LongRunningAction.java | 191 +++++ .../eclipse/net4j/util/ui/actions/SafeAction.java | 60 ++ .../net4j/util/ui/views/ContainerItemProvider.java | 385 ++++++++++ .../net4j/util/ui/views/ContainerNameSorter.java | 17 + .../eclipse/net4j/util/ui/views/ContainerView.java | 270 +++++++ .../net4j/util/ui/views/IElementFilter.java | 19 + .../eclipse/net4j/util/ui/views/ItemProvider.java | 131 ++++ .../ui/views/ManagedContainerItemProvider.java | 173 +++++ .../eclipse/net4j/util/ui/widgets/BaseDialog.java | 145 ++++ .../eclipse/net4j/util/ui/widgets/HistoryText.java | 257 +++++++ .../net4j/util/ui/widgets/HistoryTextDialog.java | 138 ++++ .../eclipse/net4j/util/ui/widgets/LogDialog.java | 167 +++++ .../net4j/util/ui/widgets/MonitorDialog.java | 126 ++++ .../net4j/util/ui/widgets/MonitorLogDialog.java | 109 +++ .../net4j/util/ui/widgets/PreferenceButton.java | 117 +++ plugins/org.eclipse.net4j.util/plugin.properties | 2 +- .../org/eclipse/net4j/internal/util/bundle/OM.java | 6 + .../util/container/PluginTransportContainer.java | 74 ++ .../net4j/internal/util/lifecycle/Lifecycle.java | 5 - .../util/container/IPluginTransportContainer.java | 22 + .../src/org/eclipse/net4j/util/io/NIOUtil.java | 3 +- plugins/org.eclipse.net4j/plugin.xml | 20 + .../eclipse/internal/net4j/AcceptorFactory.java | 4 +- .../internal/net4j/BufferProviderFactory.java | 43 ++ .../src/org/eclipse/internal/net4j/BufferUtil.java | 17 - .../internal/net4j/ClientProtocolFactory.java | 4 +- .../src/org/eclipse/internal/net4j/Connector.java | 4 +- .../eclipse/internal/net4j/ConnectorFactory.java | 4 +- .../internal/net4j/ExecutorServiceFactory.java | 42 ++ .../internal/net4j/Net4jTransportInjector.java | 66 ++ .../src/org/eclipse/internal/net4j/Protocol.java | 7 +- .../internal/net4j/ServerProtocolFactory.java | 4 +- .../eclipse/internal/net4j/TransportContainer.java | 134 ---- .../src/org/eclipse/internal/net4j/bundle/OM.java | 5 - .../net4j/bundle/PluginTransportContainer.java | 76 -- .../src/org/eclipse/net4j/BufferUtil.java | 82 --- .../eclipse/net4j/IPluginTransportContainer.java | 22 - .../src/org/eclipse/net4j/ITransportContainer.java | 38 - .../src/org/eclipse/net4j/Net4jUtil.java | 133 ++++ .../org/eclipse/net4j/signal/SignalProtocol.java | 3 +- 192 files changed, 4979 insertions(+), 7031 deletions(-) create mode 100644 plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewEditorWizard.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewEditorWizardPage.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewSessionWizard.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewSessionWizardPage.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/steps/RepoNameStep.java create mode 100644 plugins/org.eclipse.net4j.debug/icons/javabean.gif delete mode 100644 plugins/org.eclipse.net4j.debug/icons/sample.gif delete mode 100644 plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/jvm/IJVMConstants.java delete mode 100644 plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ITCPConstants.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/NewAcceptorWizard.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/NewConnectorWizard.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/NewAcceptorStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/NewConnectorStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/ProvideConnectorStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/SelectAcceptorStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/SelectConnectorStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/AccountStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/AddressStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/CustomerStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/ComboAutoCompleter.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/DelegatingContentProvider.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StaticContentProvider.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIActivator.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIUtil.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/SafeAction.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerNameSorter.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerView.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/IElementFilter.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ManagedContainerItemProvider.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/BaseDialog.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryTextDialog.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/LogDialog.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorDialog.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorLogDialog.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/PreferenceButton.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/CompoundStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/DecisionStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/IDecisionProvider.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/IStepVisitor.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/PagingStrategy.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/ParallelStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SelectionStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SequentialStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/StaticSelectionStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/Step.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingExportWizard.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingImportWizard.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingNewWizard.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWizard.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWizardPage.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWorkbenchWizard.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/StringStep.java delete mode 100644 plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/ValueStep.java create mode 100644 plugins/org.eclipse.net4j.util.ui/.classpath create mode 100644 plugins/org.eclipse.net4j.util.ui/.cvsignore create mode 100644 plugins/org.eclipse.net4j.util.ui/.options create mode 100644 plugins/org.eclipse.net4j.util.ui/.project create mode 100644 plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF create mode 100644 plugins/org.eclipse.net4j.util.ui/about.html create mode 100644 plugins/org.eclipse.net4j.util.ui/build.properties create mode 100644 plugins/org.eclipse.net4j.util.ui/copyright.txt create mode 100644 plugins/org.eclipse.net4j.util.ui/epl-v10.html create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/.cvsignore create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/.cvsignore create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/etool16/.cvsignore create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/etool16/add.gif create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/etool16/delete.gif create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/etool16/refresh.gif create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/obj16/.cvsignore create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/obj16/adapter.gif create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/obj16/factory.gif create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/obj16/folder.gif create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/obj16/javabean.gif create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/view16/.cvsignore create mode 100644 plugins/org.eclipse.net4j.util.ui/icons/full/view16/container.gif create mode 100644 plugins/org.eclipse.net4j.util.ui/license.html create mode 100644 plugins/org.eclipse.net4j.util.ui/plugin.properties create mode 100644 plugins/org.eclipse.net4j.util.ui/plugin.xml create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/SharedIcons.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerView.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jItemProvider.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/ComboAutoCompleter.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/DelegatingContentProvider.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StaticContentProvider.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/SafeAction.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerNameSorter.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/IElementFilter.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ManagedContainerItemProvider.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/BaseDialog.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/LogDialog.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorDialog.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorLogDialog.java create mode 100644 plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java create mode 100644 plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginTransportContainer.java create mode 100644 plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IPluginTransportContainer.java create mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/BufferProviderFactory.java create mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ExecutorServiceFactory.java create mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java delete mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java delete mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/PluginTransportContainer.java delete mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/net4j/BufferUtil.java delete mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/net4j/IPluginTransportContainer.java delete mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/net4j/ITransportContainer.java create mode 100644 plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java index 4fb3ef4ea3..dbc107fb47 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java @@ -2,21 +2,29 @@ package org.eclipse.emf.cdo.internal.server.protocol; import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; +import org.eclipse.net4j.util.container.IManagedContainer; + import org.eclipse.internal.net4j.ServerProtocolFactory; /** * @author Eike Stepper */ -public final class CDOServerProtocolFactory extends ServerProtocolFactory +public final class CDOServerProtocolFactory extends ServerProtocolFactory { + public static final String TYPE = CDOProtocolConstants.PROTOCOL_NAME; public CDOServerProtocolFactory() { - super(CDOProtocolConstants.PROTOCOL_NAME); + super(TYPE); } - public Object create(String description) + public CDOServerProtocol create(String description) { return new CDOServerProtocol(); } + + public static CDOServerProtocol get(IManagedContainer container, String description) + { + return (CDOServerProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); + } } \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java new file mode 100644 index 0000000000..bbdb3f7653 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java @@ -0,0 +1,30 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server; + +import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocolFactory; + +import org.eclipse.net4j.util.container.IManagedContainer; + +/** + * @author Eike Stepper + */ +public final class CDOServerUtil +{ + private CDOServerUtil() + { + } + + public static void prepareContainer(IManagedContainer container) + { + container.registerFactory(new CDOServerProtocolFactory()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/CDO UI.launch b/plugins/org.eclipse.emf.cdo.ui/CDO UI.launch index 2f2d1cea0d..4b8861d374 100644 --- a/plugins/org.eclipse.emf.cdo.ui/CDO UI.launch +++ b/plugins/org.eclipse.emf.cdo.ui/CDO UI.launch @@ -20,434 +20,434 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - + + - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF index 922cac20d2..9f52d390f5 100644 --- a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF @@ -9,7 +9,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.ui.ide;visibility:=reexport, org.eclipse.net4j;visibility:=reexport, - org.eclipse.net4j.ui;visibility:=reexport, + org.eclipse.net4j.util.ui;visibility:=reexport, org.eclipse.emf.edit.ui;visibility:=reexport, org.eclipse.emf.ecore.edit;visibility:=reexport, org.eclipse.emf.cdo;visibility:=reexport, @@ -19,7 +19,5 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="0.8.0", org.eclipse.emf.cdo.internal.ui.actions;version="0.8.0", org.eclipse.emf.cdo.internal.ui.dialogs;version="0.8.0", org.eclipse.emf.cdo.internal.ui.editor;version="0.8.0", - org.eclipse.emf.cdo.internal.ui.views;version="0.8.0", - org.eclipse.emf.cdo.internal.ui.wizards;version="0.8.0", - org.eclipse.emf.cdo.internal.ui.wizards.steps;version="0.8.0" + org.eclipse.emf.cdo.internal.ui.views;version="0.8.0" Eclipse-LazyStart: true diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.ui/plugin.xml index f409da4365..21d957b50d 100644 --- a/plugins/org.eclipse.emf.cdo.ui/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.ui/plugin.xml @@ -6,14 +6,14 @@ @@ -70,7 +70,7 @@ - - + diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java index 40e235a086..88cb08418f 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java @@ -1,6 +1,6 @@ package org.eclipse.emf.cdo.internal.ui.actions; -import org.eclipse.net4j.ui.actions.LongRunningAction; +import org.eclipse.net4j.util.ui.actions.LongRunningAction; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.emf.edit.domain.IEditingDomainProvider; diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java index a433de790e..8fb8a9f690 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java @@ -2,7 +2,7 @@ package org.eclipse.emf.cdo.internal.ui.actions; import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory; -import org.eclipse.net4j.ui.actions.LongRunningAction; +import org.eclipse.net4j.util.ui.actions.LongRunningAction; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchPage; diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java index f8481b23e2..e62b391fc3 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java @@ -2,7 +2,7 @@ package org.eclipse.emf.cdo.internal.ui.actions; import org.eclipse.emf.cdo.CDOSession; -import org.eclipse.net4j.ui.actions.LongRunningAction; +import org.eclipse.net4j.util.ui.actions.LongRunningAction; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchPage; diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java index 289416ec5d..ddb7c8de0b 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java @@ -3,7 +3,7 @@ package org.eclipse.emf.cdo.internal.ui.actions; import org.eclipse.emf.cdo.CDOTransaction; import org.eclipse.emf.cdo.CDOView; -import org.eclipse.net4j.ui.actions.LongRunningAction; +import org.eclipse.net4j.util.ui.actions.LongRunningAction; import org.eclipse.emf.internal.cdo.CDOViewImpl; diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java index 009dbc197e..08b48325bb 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java @@ -13,13 +13,13 @@ package org.eclipse.emf.cdo.internal.ui.bundle; import org.eclipse.emf.cdo.internal.server.store.NOOPStore; import org.eclipse.emf.cdo.server.IRepositoryManager; -import org.eclipse.net4j.ui.UIActivator; import org.eclipse.net4j.util.om.OMBundle; import org.eclipse.net4j.util.om.OMPlatform; import org.eclipse.net4j.util.om.log.OMLogger; import org.eclipse.net4j.util.om.pref.OMPreference; import org.eclipse.net4j.util.om.pref.OMPreferences; import org.eclipse.net4j.util.om.trace.OMTracer; +import org.eclipse.net4j.util.ui.UIActivator; /** * @author Eike Stepper diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java index af5ca46bdc..b0cd95c5d4 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java @@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.internal.ui.bundle.OM; import org.eclipse.emf.cdo.util.CDOPackageType; import org.eclipse.emf.cdo.util.CDOUtil; -import org.eclipse.net4j.ui.widgets.BaseDialog; +import org.eclipse.net4j.util.ui.widgets.BaseDialog; import org.eclipse.emf.ecore.EcorePackage; diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java index 492071562d..6d9dfd95e5 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java @@ -15,8 +15,8 @@ import org.eclipse.emf.cdo.protocol.model.CDOClass; import org.eclipse.emf.cdo.protocol.model.CDOPackage; import org.eclipse.emf.cdo.util.CDOUtil; -import org.eclipse.net4j.ui.actions.LongRunningAction; import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.ui.actions.LongRunningAction; import org.eclipse.emf.common.command.BasicCommandStack; import org.eclipse.emf.common.command.Command; diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java index 6522178939..9ebf8b2a0e 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java @@ -30,10 +30,10 @@ import org.eclipse.emf.cdo.internal.ui.actions.OpenViewEditorAction; import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory.Entry; import org.eclipse.net4j.IConnector; -import org.eclipse.net4j.ui.views.ContainerItemProvider; -import org.eclipse.net4j.ui.views.IElementFilter; import org.eclipse.net4j.util.event.IEvent; import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.ui.views.ContainerItemProvider; +import org.eclipse.net4j.util.ui.views.IElementFilter; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java index 596932ef92..802eea76a0 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java @@ -5,12 +5,12 @@ import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.ui.actions.SafeAction; -import org.eclipse.net4j.ui.views.ContainerItemProvider; -import org.eclipse.net4j.ui.views.ContainerView; -import org.eclipse.net4j.ui.views.IElementFilter; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IPluginTransportContainer; +import org.eclipse.net4j.util.ui.actions.SafeAction; +import org.eclipse.net4j.util.ui.views.ContainerItemProvider; +import org.eclipse.net4j.util.ui.views.ContainerView; +import org.eclipse.net4j.util.ui.views.IElementFilter; import org.eclipse.emf.internal.cdo.CDOSessionFactory; @@ -28,7 +28,7 @@ public class CDOSessionsView extends ContainerView } @Override - protected ITransportContainer getContainer() + protected IManagedContainer getContainer() { return IPluginTransportContainer.INSTANCE; } @@ -86,7 +86,7 @@ public class CDOSessionsView extends ContainerView @Override protected void doRun() throws Exception { - IPluginTransportContainer.INSTANCE.getElement(CDOSessionFactory.SESSION_GROUP, + IPluginTransportContainer.INSTANCE.getElement(CDOSessionFactory.PRODUCT_GROUP, CDOProtocolConstants.PROTOCOL_NAME, "tcp://127.0.0.1:" + port + "/repo1"); } } diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java deleted file mode 100644 index d481b3a9aa..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.emf.cdo.internal.ui.wizards; - -import org.eclipse.emf.cdo.internal.ui.wizards.steps.RepoNameStep; -import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; - -import org.eclipse.net4j.IConnector; -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.internal.ui.wizards.steps.ProvideConnectorStep; -import org.eclipse.net4j.internal.ui.wizards.steps.SelectConnectorStep; -import org.eclipse.net4j.ui.wizards.ParallelStep; -import org.eclipse.net4j.ui.wizards.Step; -import org.eclipse.net4j.ui.wizards.SteppingNewWizard; - -import org.eclipse.emf.internal.cdo.CDOSessionFactory; - -import org.eclipse.core.runtime.IProgressMonitor; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class NewSessionWizard extends SteppingNewWizard -{ - private ProvideConnectorStep connectorStep; - - private RepoNameStep repoNameStep; - - public NewSessionWizard(Map context) - { - super(context); - } - - public NewSessionWizard(IConnector connector, String repoName) - { - super(createContext(connector, repoName)); - } - - public NewSessionWizard() - { - } - - @Override - protected Step createRootStep() - { - ParallelStep root = new ParallelStep(); - root.add(connectorStep = new ProvideConnectorStep(getTransportContainer())); - root.add(repoNameStep = new RepoNameStep()); - return root; - } - - @Override - protected void doFinish(IProgressMonitor monitor) throws Exception - { - IConnector connector = connectorStep.getConnector(); - if (connector == null) - { - throw new IllegalStateException("connector == null"); - } - - String repoName = repoNameStep.getRepoName(); - if (repoName == null) - { - throw new IllegalStateException("repoName == null"); - } - - ITransportContainer transportContainer = getTransportContainer(); - String[] key = transportContainer.getElementKey(connector); - - String description = key[1] + "://" + key[2] + "/" + repoName; - transportContainer.getElement(CDOSessionFactory.SESSION_GROUP, CDOProtocolConstants.PROTOCOL_NAME, description); - } - - protected ITransportContainer getTransportContainer() - { - return IPluginTransportContainer.INSTANCE; - } - - private static Map createContext(IConnector connector, String repoName) - { - Map context = new HashMap(); - if (connector != null) - { - context.put(SelectConnectorStep.KEY_CONNECTOR, Collections.singleton(connector)); - } - - if (repoName != null) - { - context.put(RepoNameStep.KEY_REPO_NAME, repoName); - } - - return context; - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewEditorWizard.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewEditorWizard.java deleted file mode 100644 index 4aef5ec927..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewEditorWizard.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.eclipse.emf.cdo.internal.ui.wizards.old; - -import org.eclipse.emf.cdo.CDOSession; - -import org.eclipse.net4j.transport.ConnectorException; - -import org.eclipse.core.internal.resources.Container; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -import java.lang.reflect.InvocationTargetException; - -public class NewEditorWizard extends Wizard implements INewWizard -{ - private NewSessionWizardPage sessionPage; - - private NewEditorWizardPage editorPage; - - private ISelection selection; - - public NewEditorWizard() - { - setNeedsProgressMonitor(true); - } - - public void addPages() - { - CDOSession session = null; - if (selection instanceof IStructuredSelection) - { - Object element = ((IStructuredSelection)selection).getFirstElement(); - if (element instanceof CDOSession) - { - session = (CDOSession)element; - } - } - - if (session == null) - { - addPage(sessionPage = new NewSessionWizardPage(selection)); - } - - addPage(editorPage = new NewEditorWizardPage()); - editorPage.setSession(session); - } - - public boolean performFinish() - { - final String connectorDescription = sessionPage.getConnectorDescription(); - final String repositoryName = sessionPage.getRepositoryName(); - IRunnableWithProgress op = new IRunnableWithProgress() - { - public void run(IProgressMonitor monitor) throws InvocationTargetException - { - try - { - doFinish(connectorDescription, repositoryName, monitor); - } - catch (Exception e) - { - throw new InvocationTargetException(e); - } - finally - { - monitor.done(); - } - } - }; - - try - { - getContainer().run(true, false, op); - } - catch (InterruptedException e) - { - return false; - } - catch (InvocationTargetException e) - { - Throwable realException = e.getTargetException(); - MessageDialog.openError(getShell(), "Error", realException.getMessage()); - return false; - } - - return true; - } - - private void doFinish(String connectorDescription, String repositoryName, IProgressMonitor monitor) - throws ConnectorException - { - String description = repositoryName + "@" + connectorDescription; - monitor.beginTask("Opening " + description, 1); - Container container = ContainerManager.INSTANCE.getContainer(); - CDOContainerAdapter adapter = (CDOContainerAdapter)container.getAdapter("cdoclient"); - adapter.getSession(description); - monitor.worked(1); - - // monitor.setTaskName("Opening file for editing..."); - // getShell().getDisplay().asyncExec(new Runnable() - // { - // public void run() - // { - // IWorkbenchPage page = - // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - // try - // { - // IDE.openEditor(page, file, true); - // } - // catch (PartInitException e) - // { - // } - // } - // }); - // monitor.worked(1); - } - - public void init(IWorkbench workbench, IStructuredSelection selection) - { - this.selection = selection; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewEditorWizardPage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewEditorWizardPage.java deleted file mode 100644 index a4d929d219..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewEditorWizardPage.java +++ /dev/null @@ -1,439 +0,0 @@ -package org.eclipse.emf.cdo.internal.ui.wizards.old; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.CDOSession; -import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EPackage.Registry; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Tree; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class NewEditorWizardPage extends WizardPage -{ - private CDOSession session; - - private Label sessionLabel; - - private Button loadResourceButton; - - private LoadResourceComposite loadComposite; - - private Button createResourceButton; - - private CreateResourceComposite createComposite; - - public NewEditorWizardPage() - { - super("wizardPage"); - setTitle("Multi-page Editor File"); - setDescription("This wizard creates a new file with *.mpe extension that can be opened by a multi-page editor."); - } - - public CDOSession getSession() - { - return session; - } - - public void setSession(CDOSession session) - { - this.session = session; - setSessionLabel(); - } - - public void createControl(Composite parent) - { - Composite container = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - container.setLayout(layout); - layout.numColumns = 2; - layout.verticalSpacing = 9; - - Label label = new Label(container, SWT.NULL); - label.setText("Session:"); - - sessionLabel = new Label(container, SWT.NULL); - setSessionLabel(); - - loadResourceButton = createRadioButton(container, "Load resource:"); - loadComposite = new LoadResourceComposite(container); - - createResourceButton = createRadioButton(container, "Create resource:"); - createComposite = new CreateResourceComposite(container); - createComposite.getViewer().setInput(EPackage.Registry.INSTANCE); - - initialize(); - dialogChanged(); - setControl(container); - } - - private Button createRadioButton(Composite container, String text) - { - Button button = new Button(container, SWT.RADIO); - button.setText(text); - button.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); - button.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - dialogChanged(); - } - }); - - return button; - } - - private void setSessionLabel() - { - if (session != null && sessionLabel != null) - { - String repositoryName = session.getRepository().getName(); - String connectorDescription = session.getChannel().getConnector().getDescription(); - sessionLabel.setText(repositoryName + "@" + connectorDescription); - } - } - - public void setVisible(boolean visible) - { - super.setVisible(visible); - if (visible) - { - setFocus(); - } - } - - private void setFocus() - { - if (loadResourceButton.getSelection()) - { - loadComposite.getText().setFocus(); - } - else - { - createComposite.getText().setFocus(); - } - } - - private void initialize() - { - if (false) - { - loadResourceButton.setSelection(true); - // resourceList.setItems(descriptions); - // resourceList.select(0); - } - else - { - createResourceButton.setSelection(true); - } - } - - private void dialogChanged() - { - loadComposite.setEnabled(loadResourceButton.getSelection()); - createComposite.setEnabled(createResourceButton.getSelection()); - - if (loadComposite.isEnabled() && loadComposite.getViewer().getSelection().isEmpty()) - { - updateStatus("Select an existing resource to be loaded from the list."); - return; - } - - if (createComposite.isEnabled()) - { - if (createComposite.getText().getText().isEmpty()) - { - updateStatus("Select an existing resource to be loaded from the list."); - return; - } - - if (createComposite.getViewer().getSelection().isEmpty()) - { - updateStatus("Select an existing resource to be loaded from the list."); - return; - } - } - - // if (connectorText.isEnabled() && connectorText.getText().length() == 0) - // { - // updateStatus("Enter a description to create a new connector."); - // return; - // } - // - // if (repositoryText.getText().length() == 0) - // { - // updateStatus("Enter the name of a remote repository."); - // return; - // } - - updateStatus(null); - } - - private void updateStatus(String message) - { - setErrorMessage(message); - setPageComplete(message == null); - } - - /** - * @author Eike Stepper - */ - public static class TextViewerComposite extends Composite implements ITreeContentProvider - { - private Text text; - - private StructuredViewer viewer; - - private LabelProvider labelProvider = new LabelProvider() - { - public Image getImage(Object element) - { - return TextViewerComposite.this.getImage(element); - } - - public String getText(Object element) - { - return TextViewerComposite.this.getText(element); - } - }; - - public TextViewerComposite(Composite parent) - { - super(parent, SWT.NONE); - setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - GridLayout gridLayout = new GridLayout(1, false); - gridLayout.marginWidth = 0; - gridLayout.marginHeight = 0; - gridLayout.verticalSpacing = 5; - setLayout(gridLayout); - - text = createText(); - viewer = createViewer(); - init(); - } - - public Text getText() - { - return text; - } - - public StructuredViewer getViewer() - { - return viewer; - } - - @Override - public void setEnabled(boolean enabled) - { - super.setEnabled(enabled); - text.setEnabled(enabled); - viewer.getControl().setEnabled(enabled); - } - - protected Text createText() - { - Text text = new Text(this, SWT.BORDER); - text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - return text; - } - - protected StructuredViewer createViewer() - { - Table table = new Table(this, SWT.BORDER | SWT.SINGLE); - table.setSize(300, 100); - table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - return new TableViewer(table); - } - - protected void init() - { - viewer.setContentProvider(this); - viewer.setLabelProvider(labelProvider); - } - - public Object[] getChildren(Object parentElement) - { - return new Object[0]; - } - - public Object getParent(Object element) - { - return null; - } - - public boolean hasChildren(Object element) - { - return false; - } - - public Object[] getElements(Object inputElement) - { - return getChildren(inputElement); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - } - - public Image getImage(Object element) - { - return null; - } - - public String getText(Object element) - { - return element.toString(); - } - } - - public static class LoadResourceComposite extends TextViewerComposite - { - public LoadResourceComposite(Composite parent) - { - super(parent); - } - } - - public static class CreateResourceComposite extends TextViewerComposite - { - private EPackage.Registry registry; - - private Object[] uris; - - public CreateResourceComposite(Composite parent) - { - super(parent); - } - - protected StructuredViewer createViewer() - { - Tree tree = new Tree(this, SWT.BORDER | SWT.SINGLE); - tree.setSize(300, 100); - tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - return new TreeViewer(tree); - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - registry = (Registry)newInput; - Set keySet = registry.keySet(); - Iterator it = keySet.iterator(); - uris = new Object[keySet.size()]; - for (int i = 0; i < uris.length; i++) - { - uris[i] = URI.createURI(it.next()); - } - } - - @Override - public boolean hasChildren(Object element) - { - return element instanceof URI; - } - - @Override - public Object[] getChildren(Object parentElement) - { - if (parentElement == registry) - { - return uris; - } - - if (parentElement instanceof URI) - { - URI uri = (URI)parentElement; - EPackage ePackage = registry.getEPackage(uri.toString()); - List result = new ArrayList(); - EList classifiers = ePackage.getEClassifiers(); - for (EClassifier classifier : classifiers) - { - if (classifier instanceof EClass) - { - EClass eClass = (EClass)classifier; - Class instanceClass = eClass.getInstanceClass(); - if (CDOObject.class.isAssignableFrom(instanceClass)) - { - result.add(eClass); - } - } - } - - return result.toArray(new Object[result.size()]); - } - - return super.getChildren(parentElement); - } - - @Override - public Object getParent(Object element) - { - if (element instanceof EClass) - { - EPackage ePackage = ((EClass)element).getEPackage(); - return URI.createURI(ePackage.getNsURI()); - } - - return registry; - } - - @Override - public String getText(Object element) - { - if (element instanceof URI) - { - return ((URI)element).toString(); - } - - if (element instanceof EClass) - { - return ((EClass)element).getName(); - } - - return super.getText(element); - } - - @Override - public Image getImage(Object element) - { - if (element instanceof URI) - { - return SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE); - } - - if (element instanceof EClass) - { - return SharedIcons.getImage(SharedIcons.OBJ_ECLASS); - } - - return super.getImage(element); - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewSessionWizard.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewSessionWizard.java deleted file mode 100644 index e539d28aea..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewSessionWizard.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.eclipse.emf.cdo.internal.ui.wizards.old; - -import org.eclipse.net4j.transport.ConnectorException; - -import org.eclipse.core.internal.resources.Container; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -import java.lang.reflect.InvocationTargetException; - -public class NewSessionWizard extends Wizard implements INewWizard -{ - private NewSessionWizardPage page; - - private ISelection selection; - - public NewSessionWizard() - { - setNeedsProgressMonitor(true); - } - - public void addPages() - { - page = new NewSessionWizardPage(selection); - addPage(page); - } - - public boolean performFinish() - { - final String connectorDescription = page.getConnectorDescription(); - final String repositoryName = page.getRepositoryName(); - IRunnableWithProgress op = new IRunnableWithProgress() - { - public void run(IProgressMonitor monitor) throws InvocationTargetException - { - try - { - doFinish(connectorDescription, repositoryName, monitor); - } - catch (Exception e) - { - throw new InvocationTargetException(e); - } - finally - { - monitor.done(); - } - } - }; - - try - { - getContainer().run(true, false, op); - } - catch (InterruptedException e) - { - return false; - } - catch (InvocationTargetException e) - { - Throwable realException = e.getTargetException(); - MessageDialog.openError(getShell(), "Error", realException.getMessage()); - return false; - } - - return true; - } - - private void doFinish(String connectorDescription, String repositoryName, IProgressMonitor monitor) - throws ConnectorException - { - String description = repositoryName + "@" + connectorDescription; - monitor.beginTask("Opening " + description, 1); - Container container = ContainerManager.INSTANCE.getContainer(); - CDOContainerAdapter adapter = (CDOContainerAdapter)container.getAdapter("cdoclient"); - adapter.getSession(description); - monitor.worked(1); - - // monitor.setTaskName("Opening file for editing..."); - // getShell().getDisplay().asyncExec(new Runnable() - // { - // public void run() - // { - // IWorkbenchPage page = - // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - // try - // { - // IDE.openEditor(page, file, true); - // } - // catch (PartInitException e) - // { - // } - // } - // }); - // monitor.worked(1); - } - - public void init(IWorkbench workbench, IStructuredSelection selection) - { - this.selection = selection; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewSessionWizardPage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewSessionWizardPage.java deleted file mode 100644 index 5ba70945a8..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/old/NewSessionWizardPage.java +++ /dev/null @@ -1,213 +0,0 @@ -package org.eclipse.emf.cdo.internal.ui.wizards.old; - -import org.eclipse.core.internal.resources.Container; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Text; - -import java.util.Set; - -public class NewSessionWizardPage extends WizardPage -{ - private Button existingConnectorButton; - - private Button newConnectorButton; - - private List connectorList; - - private Text connectorText; - - private Text repositoryText; - - private ISelection selection; - - public NewSessionWizardPage(ISelection selection) - { - super("wizardPage"); - setTitle("Multi-page Editor File"); - setDescription("This wizard creates a new file with *.mpe extension that can be opened by a multi-page editor."); - this.selection = selection; - } - - public void createControl(Composite parent) - { - Composite container = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - container.setLayout(layout); - layout.numColumns = 1; - layout.verticalSpacing = 9; - - Group connectorGroup = new Group(container, SWT.None); - connectorGroup.setText("Connector"); - connectorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - connectorGroup.setLayout(new GridLayout(2, false)); - - existingConnectorButton = new Button(connectorGroup, SWT.RADIO); - existingConnectorButton.setText("Existing connector:"); - existingConnectorButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); - existingConnectorButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - dialogChanged(); - } - }); - - connectorList = new List(connectorGroup, SWT.BORDER | SWT.SINGLE); - connectorList.setSize(300, 100); - connectorList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - connectorList.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - dialogChanged(); - } - }); - - newConnectorButton = new Button(connectorGroup, SWT.RADIO); - newConnectorButton.setText("New connector:"); - newConnectorButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); - newConnectorButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - dialogChanged(); - } - }); - - connectorText = new Text(connectorGroup, SWT.BORDER); - connectorText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - connectorText.addModifyListener(new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - dialogChanged(); - } - }); - - Group repositoryGroup = new Group(container, SWT.None); - repositoryGroup.setText("Repository"); - repositoryGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - repositoryGroup.setLayout(new GridLayout(2, false)); - - Label label = new Label(repositoryGroup, SWT.NULL); - label.setText("&Name:"); - - repositoryText = new Text(repositoryGroup, SWT.BORDER); - repositoryText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - repositoryText.addModifyListener(new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - dialogChanged(); - } - }); - - initialize(); - dialogChanged(); - setControl(container); - } - - public void setVisible(boolean visible) - { - super.setVisible(visible); - if (visible) - { - setFocus(); - } - } - - private void setFocus() - { - if (existingConnectorButton.getSelection()) - { - connectorList.setFocus(); - } - else - { - connectorText.setFocus(); - } - } - - private String[] getConnectorDescriptions() - { - Container container = ContainerManager.INSTANCE.getContainer(); - Set keySet = container.getConnectorRegistry().keySet(); - return keySet.toArray(new String[keySet.size()]); - } - - private void initialize() - { - String[] descriptions = getConnectorDescriptions(); - if (descriptions.length != 0) - { - existingConnectorButton.setSelection(true); - connectorList.setItems(descriptions); - connectorList.select(0); - } - else - { - existingConnectorButton.setEnabled(false); - newConnectorButton.setSelection(true); - } - } - - private void dialogChanged() - { - connectorList.setEnabled(existingConnectorButton.getSelection()); - connectorText.setEnabled(newConnectorButton.getSelection()); - - if (connectorList.isEnabled() && connectorList.getSelectionCount() == 0) - { - updateStatus("Select an existing connector from the list."); - return; - } - - if (connectorText.isEnabled() && connectorText.getText().length() == 0) - { - updateStatus("Enter a description to create a new connector."); - return; - } - - if (repositoryText.getText().length() == 0) - { - updateStatus("Enter the name of a remote repository."); - return; - } - - updateStatus(null); - } - - private void updateStatus(String message) - { - setErrorMessage(message); - setPageComplete(message == null); - } - - public String getRepositoryName() - { - return repositoryText.getText(); - } - - public String getConnectorDescription() - { - if (existingConnectorButton.getSelection()) - { - return connectorList.getSelection()[0]; - } - - return connectorText.getText(); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/steps/RepoNameStep.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/steps/RepoNameStep.java deleted file mode 100644 index e154322b20..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/steps/RepoNameStep.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.eclipse.emf.cdo.internal.ui.wizards.steps; - -import org.eclipse.net4j.ui.wizards.ParallelStep; -import org.eclipse.net4j.ui.wizards.StringStep; - -/** - * @author Eike Stepper - */ -public class RepoNameStep extends ParallelStep -{ - public static final String KEY_REPO_NAME = "Repository name"; - - public RepoNameStep() - { - add(new StringStep(KEY_REPO_NAME)); - } - - public String getRepoName() - { - Object value = getWizard().getSingleContextValue(KEY_REPO_NAME); - return value instanceof String ? (String)value : null; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java index 1f3fc1e965..9a3e479ba8 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java @@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; import org.eclipse.net4j.ConnectorException; import org.eclipse.net4j.IConnector; import org.eclipse.net4j.util.StringUtil; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; import org.eclipse.emf.common.notify.Adapter; @@ -43,6 +44,7 @@ import org.eclipse.emf.internal.cdo.CDOStateMachine; import org.eclipse.emf.internal.cdo.CDOViewImpl; import org.eclipse.emf.internal.cdo.InternalCDOObject; import org.eclipse.emf.internal.cdo.bundle.OM; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocolFactory; import org.eclipse.emf.internal.cdo.util.FSMUtil; import org.eclipse.core.runtime.IConfigurationElement; @@ -155,6 +157,11 @@ public final class CDOUtil map.put(CDOProtocolConstants.PROTOCOL_NAME, factory); } + public static void prepareContainer(IManagedContainer container) + { + container.registerFactory(new CDOClientProtocolFactory()); + } + public static String extractResourcePath(URI uri) { if (!CDOProtocolConstants.PROTOCOL_NAME.equals(uri.scheme())) diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java index 81bbfdc87d..a216d5f717 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java @@ -11,9 +11,9 @@ package org.eclipse.emf.internal.cdo; import org.eclipse.emf.cdo.CDOSession; -import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; import org.eclipse.net4j.internal.util.factory.Factory; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EPackage; @@ -26,11 +26,13 @@ import org.eclipse.core.runtime.Path; */ public class CDOSessionFactory extends Factory { - public static final String SESSION_GROUP = "org.eclipse.emf.cdo.sessions"; + public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.sessions"; + + public static final String TYPE = "cdo"; public CDOSessionFactory() { - super(SESSION_GROUP, CDOProtocolConstants.PROTOCOL_NAME); + super(PRODUCT_GROUP, TYPE); } public CDOSession create(String description) @@ -46,4 +48,9 @@ public class CDOSessionFactory extends Factory IPath path = new Path(uri.path()); return path.segment(0); } + + public static CDOSession get(IManagedContainer container, String description) + { + return (CDOSession)container.getElement(PRODUCT_GROUP, TYPE, description); + } } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java index 131b97ec13..ab0fc430e6 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java @@ -2,20 +2,29 @@ package org.eclipse.emf.internal.cdo.protocol; import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; +import org.eclipse.net4j.util.container.IManagedContainer; + import org.eclipse.internal.net4j.ClientProtocolFactory; /** * @author Eike Stepper */ -public final class CDOClientProtocolFactory extends ClientProtocolFactory +public final class CDOClientProtocolFactory extends ClientProtocolFactory { + public static final String TYPE = CDOProtocolConstants.PROTOCOL_NAME; + public CDOClientProtocolFactory() { - super(CDOProtocolConstants.PROTOCOL_NAME); + super(TYPE); } - public Object create(String description) + public CDOClientProtocol create(String description) { return new CDOClientProtocol(); } + + public static CDOClientProtocol get(IManagedContainer container, String description) + { + return (CDOClientProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); + } } \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java index 63f1785717..8236094387 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java @@ -49,6 +49,6 @@ public class ChannelInjector implements IElementProcessor String factoryType = uri.scheme(); String connectorDescription = uri.authority(); - return (IConnector)container.getElement(ConnectorFactory.CONNECTOR_GROUP, factoryType, connectorDescription); + return (IConnector)container.getElement(ConnectorFactory.PRODUCT_GROUP, factoryType, connectorDescription); } } diff --git a/plugins/org.eclipse.net4j.debug/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.debug/META-INF/MANIFEST.MF index 7360139296..8855ffb7e0 100644 --- a/plugins/org.eclipse.net4j.debug/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.net4j.debug/META-INF/MANIFEST.MF @@ -8,6 +8,5 @@ Bundle-Activator: org.eclipse.net4j.internal.debug.bundle.OM$Activator Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.core.runtime, - org.eclipse.ui, - org.eclipse.net4j.ui + org.eclipse.net4j.util.ui;visibility:=reexport Eclipse-LazyStart: true diff --git a/plugins/org.eclipse.net4j.debug/build.properties b/plugins/org.eclipse.net4j.debug/build.properties index c88359b87e..d0965e53e3 100644 --- a/plugins/org.eclipse.net4j.debug/build.properties +++ b/plugins/org.eclipse.net4j.debug/build.properties @@ -4,4 +4,8 @@ bin.includes = plugin.xml,\ META-INF/,\ .,\ icons/,\ - plugin.properties + plugin.properties,\ + license.html,\ + copyright.txt,\ + epl-v10.html,\ + about.html diff --git a/plugins/org.eclipse.net4j.debug/icons/javabean.gif b/plugins/org.eclipse.net4j.debug/icons/javabean.gif new file mode 100644 index 0000000000..d9bfbd0541 Binary files /dev/null and b/plugins/org.eclipse.net4j.debug/icons/javabean.gif differ diff --git a/plugins/org.eclipse.net4j.debug/icons/sample.gif b/plugins/org.eclipse.net4j.debug/icons/sample.gif deleted file mode 100644 index 34fb3c9d8c..0000000000 Binary files a/plugins/org.eclipse.net4j.debug/icons/sample.gif and /dev/null differ diff --git a/plugins/org.eclipse.net4j.debug/plugin.xml b/plugins/org.eclipse.net4j.debug/plugin.xml index 7d265c962d..9dbef6c1d9 100644 --- a/plugins/org.eclipse.net4j.debug/plugin.xml +++ b/plugins/org.eclipse.net4j.debug/plugin.xml @@ -5,20 +5,20 @@ + id="org.eclipse.debug.ui" + name="Debug"> diff --git a/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/OM.java b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/OM.java index 9080a57d8f..858ac6e327 100644 --- a/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/OM.java +++ b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/OM.java @@ -11,11 +11,11 @@ package org.eclipse.net4j.internal.debug.bundle; import org.eclipse.net4j.internal.debug.RemoteTraceManager; -import org.eclipse.net4j.ui.UIActivator; import org.eclipse.net4j.util.om.OMBundle; import org.eclipse.net4j.util.om.OMPlatform; import org.eclipse.net4j.util.om.log.OMLogger; import org.eclipse.net4j.util.om.trace.OMTracer; +import org.eclipse.net4j.util.ui.UIActivator; /** * @author Eike Stepper diff --git a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/admin/JMSAdminUtil.java b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/admin/JMSAdminUtil.java index ff364b0867..106ccc85ac 100644 --- a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/admin/JMSAdminUtil.java +++ b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/admin/JMSAdminUtil.java @@ -12,6 +12,8 @@ package org.eclipse.net4j.jms.admin; import org.eclipse.net4j.IConnector; import org.eclipse.net4j.jms.internal.admin.JMSAdmin; +import org.eclipse.net4j.jms.internal.admin.protocol.JMSAdminProtocolFactory; +import org.eclipse.net4j.util.container.IManagedContainer; /** * @author Eike Stepper @@ -22,6 +24,11 @@ public final class JMSAdminUtil { } + public static void prepareContainer(IManagedContainer container) + { + container.registerFactory(new JMSAdminProtocolFactory()); + } + public static IJMSAdmin createAdmin(IConnector connector) { return new JMSAdmin(connector); diff --git a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocolFactory.java b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocolFactory.java index a5f2f424c2..bc22131319 100644 --- a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocolFactory.java +++ b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocolFactory.java @@ -11,21 +11,29 @@ package org.eclipse.net4j.jms.internal.admin.protocol; import org.eclipse.net4j.jms.JMSAdminProtocolConstants; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.internal.net4j.ClientProtocolFactory; /** * @author Eike Stepper */ -public final class JMSAdminProtocolFactory extends ClientProtocolFactory +public final class JMSAdminProtocolFactory extends ClientProtocolFactory { + public static final String TYPE = JMSAdminProtocolConstants.PROTOCOL_NAME; + public JMSAdminProtocolFactory() { - super(JMSAdminProtocolConstants.PROTOCOL_NAME); + super(TYPE); } - public Object create(String description) + public JMSAdminProtocol create(String description) { return new JMSAdminProtocol(); } + + public static JMSAdminProtocol get(IManagedContainer container, String description) + { + return (JMSAdminProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); + } } \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java index 7dbd580d06..f8ef5d05fb 100644 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java +++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java @@ -11,21 +11,29 @@ package org.eclipse.net4j.jms.internal.server.protocol; import org.eclipse.net4j.jms.JMSProtocolConstants; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.internal.net4j.ServerProtocolFactory; /** * @author Eike Stepper */ -public final class JMSServerProtocolFactory extends ServerProtocolFactory +public final class JMSServerProtocolFactory extends ServerProtocolFactory { + public static final String TYPE = JMSProtocolConstants.PROTOCOL_NAME; + public JMSServerProtocolFactory() { - super(JMSProtocolConstants.PROTOCOL_NAME); + super(TYPE); } - public Object create(String description) + public JMSServerProtocol create(String description) { return new JMSServerProtocol(); } + + public static JMSServerProtocol get(IManagedContainer container, String description) + { + return (JMSServerProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); + } } \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java index 685228c5a4..2ebb074272 100644 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java +++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java @@ -11,21 +11,29 @@ package org.eclipse.net4j.jms.internal.server.protocol.admin; import org.eclipse.net4j.jms.JMSAdminProtocolConstants; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.internal.net4j.ServerProtocolFactory; /** * @author Eike Stepper */ -public final class JMSAdminServerProtocolFactory extends ServerProtocolFactory +public final class JMSAdminServerProtocolFactory extends ServerProtocolFactory { + public static final String TYPE = JMSAdminProtocolConstants.PROTOCOL_NAME; + public JMSAdminServerProtocolFactory() { - super(JMSAdminProtocolConstants.PROTOCOL_NAME); + super(TYPE); } - public Object create(String description) + public JMSAdminServerProtocol create(String description) { return new JMSAdminServerProtocol(); } + + public static JMSAdminServerProtocol get(IManagedContainer container, String description) + { + return (JMSAdminServerProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); + } } \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionFactoryImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionFactoryImpl.java index 825ec75cb7..ba6382c7c0 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionFactoryImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionFactoryImpl.java @@ -10,7 +10,7 @@ **************************************************************************/ package org.eclipse.net4j.internal.jms; -import org.eclipse.net4j.ITransportContainer; +import org.eclipse.net4j.util.container.IManagedContainer; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -62,7 +62,7 @@ public class ConnectionFactoryImpl implements ConnectionFactory, Remote, Seriali public Connection createConnection(String userName, String password) throws JMSException { - return new ConnectionImpl((ITransportContainer)transportContainer, connectorType, connectorDescription, userName, + return new ConnectionImpl((IManagedContainer)transportContainer, connectorType, connectorDescription, userName, password); } } diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java index 8ce5f00a1e..01fabd8c48 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java @@ -12,7 +12,7 @@ package org.eclipse.net4j.internal.jms; import org.eclipse.net4j.IChannel; import org.eclipse.net4j.IConnector; -import org.eclipse.net4j.ITransportContainer; +import org.eclipse.net4j.Net4jUtil; import org.eclipse.net4j.internal.jms.bundle.OM; import org.eclipse.net4j.internal.jms.protocol.JMSClientProtocol; import org.eclipse.net4j.internal.jms.protocol.JMSLogonRequest; @@ -25,6 +25,7 @@ import org.eclipse.net4j.jms.JMSUtil; import org.eclipse.net4j.util.container.IContainer; import org.eclipse.net4j.util.container.IContainerDelta; import org.eclipse.net4j.util.container.IContainerEvent; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.container.IContainerDelta.Kind; import org.eclipse.net4j.util.event.IListener; import org.eclipse.net4j.util.lifecycle.ILifecycle; @@ -60,7 +61,7 @@ public class ConnectionImpl extends Lifecycle implements Connection, IContainer< private long sendTimeout = 2500; - private ITransportContainer transportContainer; + private IManagedContainer transportContainer; private IChannel channel; @@ -93,7 +94,7 @@ public class ConnectionImpl extends Lifecycle implements Connection, IContainer< private boolean stopped = true; - public ConnectionImpl(ITransportContainer transportContainer, String connectorType, String connectorDescription, + public ConnectionImpl(IManagedContainer transportContainer, String connectorType, String connectorDescription, String userName, String password) throws JMSException { this.transportContainer = transportContainer == null ? JMSUtil.getTransportContainer() : transportContainer; @@ -107,7 +108,7 @@ public class ConnectionImpl extends Lifecycle implements Connection, IContainer< this.userName = userName; this.password = password; - IConnector connector = transportContainer.getConnector(connectorType, connectorDescription); + IConnector connector = Net4jUtil.getConnector(transportContainer, connectorType, connectorDescription); JMSClientProtocol protocol = new JMSClientProtocol(); protocol.setConnection(this); channel = connector.openChannel(protocol); @@ -169,7 +170,7 @@ public class ConnectionImpl extends Lifecycle implements Connection, IContainer< return session; } - public ITransportContainer getTransportContainer() + public IManagedContainer getTransportContainer() { return transportContainer; } diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/bundle/OM.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/bundle/OM.java index 0ada75d830..423e291e9d 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/bundle/OM.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/bundle/OM.java @@ -10,8 +10,8 @@ **************************************************************************/ package org.eclipse.net4j.internal.jms.bundle; -import org.eclipse.net4j.IPluginTransportContainer; import org.eclipse.net4j.jms.JMSUtil; +import org.eclipse.net4j.util.container.IPluginTransportContainer; import org.eclipse.net4j.util.om.OMBundle; import org.eclipse.net4j.util.om.OMPlatform; import org.eclipse.net4j.util.om.OSGiActivator; diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocolFactory.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocolFactory.java index 4565a70a83..29d88cf246 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocolFactory.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocolFactory.java @@ -11,21 +11,29 @@ package org.eclipse.net4j.internal.jms.protocol; import org.eclipse.net4j.jms.JMSProtocolConstants; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.internal.net4j.ClientProtocolFactory; /** * @author Eike Stepper */ -public final class JMSClientProtocolFactory extends ClientProtocolFactory +public final class JMSClientProtocolFactory extends ClientProtocolFactory { + public static final String TYPE = JMSProtocolConstants.PROTOCOL_NAME; + public JMSClientProtocolFactory() { - super(JMSProtocolConstants.PROTOCOL_NAME); + super(TYPE); } - public Object create(String description) + public JMSClientProtocol create(String description) { return new JMSClientProtocol(); } + + public static JMSClientProtocol get(IManagedContainer container, String description) + { + return (JMSClientProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); + } } \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSInitialContext.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSInitialContext.java index 9d1ec85f66..da6e384ca9 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSInitialContext.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSInitialContext.java @@ -10,8 +10,8 @@ **************************************************************************/ package org.eclipse.net4j.jms; -import org.eclipse.net4j.ITransportContainer; import org.eclipse.net4j.internal.jms.ConnectionFactoryImpl; +import org.eclipse.net4j.util.container.IManagedContainer; import javax.naming.InitialContext; import javax.naming.Name; @@ -24,26 +24,26 @@ import java.util.Hashtable; */ public class JMSInitialContext extends InitialContext { - private ITransportContainer transportContainer; + private IManagedContainer transportContainer; - public JMSInitialContext(ITransportContainer transportContainer) throws NamingException + public JMSInitialContext(IManagedContainer transportContainer) throws NamingException { this.transportContainer = transportContainer; } - public JMSInitialContext(boolean lazy, ITransportContainer transportContainer) throws NamingException + public JMSInitialContext(boolean lazy, IManagedContainer transportContainer) throws NamingException { super(lazy); this.transportContainer = transportContainer; } - public JMSInitialContext(Hashtable environment, ITransportContainer transportContainer) throws NamingException + public JMSInitialContext(Hashtable environment, IManagedContainer transportContainer) throws NamingException { super(environment); this.transportContainer = transportContainer; } - public ITransportContainer getTransportContainer() + public IManagedContainer getTransportContainer() { return transportContainer; } diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSUtil.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSUtil.java index 2ba324d3a5..1851d6505c 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSUtil.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSUtil.java @@ -10,7 +10,6 @@ **************************************************************************/ package org.eclipse.net4j.jms; -import org.eclipse.net4j.ITransportContainer; import org.eclipse.net4j.internal.jms.protocol.JMSClientProtocolFactory; import org.eclipse.net4j.util.container.IManagedContainer; @@ -22,7 +21,7 @@ import javax.naming.NamingException; */ public final class JMSUtil { - private static ITransportContainer transportContainer; + private static IManagedContainer transportContainer; private JMSUtil() { @@ -43,12 +42,12 @@ public final class JMSUtil return new JMSInitialContext(transportContainer); } - public static ITransportContainer getTransportContainer() + public static IManagedContainer getTransportContainer() { return transportContainer; } - public static void setTransportContainer(ITransportContainer transportContainer) + public static void setTransportContainer(IManagedContainer transportContainer) { JMSUtil.transportContainer = transportContainer; } diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptorFactory.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptorFactory.java index 567cde2d40..2ec7d85e99 100644 --- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptorFactory.java +++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptorFactory.java @@ -10,7 +10,7 @@ **************************************************************************/ package org.eclipse.net4j.internal.jvm; -import org.eclipse.net4j.jvm.IJVMConstants; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.factory.ProductCreationException; import org.eclipse.internal.net4j.AcceptorFactory; @@ -20,9 +20,11 @@ import org.eclipse.internal.net4j.AcceptorFactory; */ public class JVMAcceptorFactory extends AcceptorFactory { + public static final String TYPE = "jvm"; + public JVMAcceptorFactory() { - super(IJVMConstants.TYPE); + super(TYPE); } public JVMAcceptor create(String description) throws ProductCreationException @@ -37,4 +39,9 @@ public class JVMAcceptorFactory extends AcceptorFactory { return acceptor.getName(); } + + public static JVMAcceptor get(IManagedContainer container, String description) + { + return (JVMAcceptor)container.getElement(PRODUCT_GROUP, TYPE, description); + } } diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java index ab494177c2..cd010034cc 100644 --- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java +++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java @@ -14,7 +14,6 @@ import org.eclipse.net4j.ConnectorException; import org.eclipse.net4j.IBuffer; import org.eclipse.net4j.IChannel; import org.eclipse.net4j.IProtocol; -import org.eclipse.net4j.jvm.IJVMConstants; import org.eclipse.internal.net4j.Channel; import org.eclipse.internal.net4j.Connector; @@ -58,7 +57,7 @@ public abstract class JVMConnector extends Connector public String getURL() { - return IJVMConstants.TYPE + "://" + name; + return "jvm://" + name; } @Override diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnectorFactory.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnectorFactory.java index c2b8cb7456..4905bc2fd5 100644 --- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnectorFactory.java +++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnectorFactory.java @@ -10,7 +10,7 @@ **************************************************************************/ package org.eclipse.net4j.internal.jvm; -import org.eclipse.net4j.jvm.IJVMConstants; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.factory.ProductCreationException; import org.eclipse.internal.net4j.ConnectorFactory; @@ -20,9 +20,11 @@ import org.eclipse.internal.net4j.ConnectorFactory; */ public class JVMConnectorFactory extends ConnectorFactory { + public static final String TYPE = "jvm"; + public JVMConnectorFactory(String type) { - super(IJVMConstants.TYPE); + super(TYPE); } public JVMClientConnector create(String description) throws ProductCreationException @@ -37,4 +39,9 @@ public class JVMConnectorFactory extends ConnectorFactory { return connector.getName(); } + + public static JVMClientConnector get(IManagedContainer container, String description) + { + return (JVMClientConnector)container.getElement(PRODUCT_GROUP, TYPE, description); + } } diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/jvm/IJVMConstants.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/jvm/IJVMConstants.java deleted file mode 100644 index 647aea20cf..0000000000 --- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/jvm/IJVMConstants.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jvm; - -/** - * @author Eike Stepper - */ -public interface IJVMConstants -{ - public static final String TYPE = "jvm"; - - public static final String DEFAULT_NAME = "default"; -} diff --git a/plugins/org.eclipse.net4j.tcp/plugin.xml b/plugins/org.eclipse.net4j.tcp/plugin.xml index 3f73332a1a..6fa885d8f6 100644 --- a/plugins/org.eclipse.net4j.tcp/plugin.xml +++ b/plugins/org.eclipse.net4j.tcp/plugin.xml @@ -18,6 +18,7 @@ productGroup="org.eclipse.net4j.selectors" type="tcp"/> + { - public static final String SEPARATOR = ":"; //$NON-NLS-1$ + public static final String TYPE = "tcp"; + + public static final String DEFAULT_ADDRESS = "0.0.0.0"; //$NON-NLS-1$ + + public static final int DEFAULT_PORT = 2036; + + private static final String SEPARATOR = ":"; //$NON-NLS-1$ public TCPAcceptorFactory() { - super(ITCPConstants.TYPE); + super(TYPE); } public TCPAcceptor create(String description) { - String address = ITCPConstants.DEFAULT_ADDRESS; - int port = ITCPConstants.DEFAULT_PORT; + String address = DEFAULT_ADDRESS; + int port = DEFAULT_PORT; if (!StringUtil.isEmpty(description)) { @@ -57,4 +63,9 @@ public class TCPAcceptorFactory extends AcceptorFactory { return acceptor.getAddress() + SEPARATOR + acceptor.getPort(); } + + public static TCPAcceptor get(IManagedContainer container, String description) + { + return (TCPAcceptor)container.getElement(PRODUCT_GROUP, TYPE, description); + } } diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java index 6b6459521e..141f657004 100644 --- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java +++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java @@ -18,7 +18,6 @@ import org.eclipse.net4j.IProtocol; import org.eclipse.net4j.internal.tcp.bundle.OM; import org.eclipse.net4j.internal.util.om.trace.ContextTracer; import org.eclipse.net4j.tcp.ITCPConnector; -import org.eclipse.net4j.tcp.ITCPConstants; import org.eclipse.net4j.tcp.ITCPSelector; import org.eclipse.net4j.tcp.ITCPSelectorListener; import org.eclipse.net4j.util.io.IOUtil; @@ -104,7 +103,7 @@ public abstract class TCPConnector extends Connector implements ITCPConnector, I public String getURL() { - return ITCPConstants.TYPE + "://" + host + ":" + port; + return "tcp://" + host + ":" + port; } /** diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java index 82deca328e..8c00c15012 100644 --- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java +++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java @@ -10,8 +10,8 @@ **************************************************************************/ package org.eclipse.net4j.internal.tcp; -import org.eclipse.net4j.tcp.ITCPConstants; import org.eclipse.net4j.util.StringUtil; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.factory.ProductCreationException; import org.eclipse.internal.net4j.ConnectorFactory; @@ -24,11 +24,15 @@ import java.net.URL; */ public class TCPConnectorFactory extends ConnectorFactory { + public static final String TYPE = "tcp"; + + public static final int DEFAULT_PORT = 2036; + private static final String URL_SCHEME = "http://"; public TCPConnectorFactory() { - super(ITCPConstants.TYPE); + super(TYPE); } public TCPClientConnector create(String description) @@ -42,7 +46,7 @@ public class TCPConnectorFactory extends ConnectorFactory int port = url.getPort(); if (port == -1) { - port = ITCPConstants.DEFAULT_PORT; + port = DEFAULT_PORT; } TCPClientConnector connector = new TCPClientConnector(); @@ -68,11 +72,16 @@ public class TCPConnectorFactory extends ConnectorFactory } int port = connector.getPort(); - if (port != ITCPConstants.DEFAULT_PORT) + if (port != DEFAULT_PORT) { description = description + ":" + port; } return description; } + + public static TCPClientConnector get(IManagedContainer container, String description) + { + return (TCPClientConnector)container.getElement(PRODUCT_GROUP, TYPE, description); + } } diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorFactory.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorFactory.java index 859e3bdd4e..a9e2ac6f90 100644 --- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorFactory.java +++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorFactory.java @@ -11,22 +11,29 @@ package org.eclipse.net4j.internal.tcp; import org.eclipse.net4j.internal.util.factory.Factory; -import org.eclipse.net4j.tcp.ITCPConstants; +import org.eclipse.net4j.util.container.IManagedContainer; /** * @author Eike Stepper */ public class TCPSelectorFactory extends Factory { - public static final String SELECTOR_GROUP = "org.eclipse.net4j.selectors"; + public static final String PRODUCT_GROUP = "org.eclipse.net4j.selectors"; + + public static final String TYPE = "tcp"; public TCPSelectorFactory() { - super(SELECTOR_GROUP, ITCPConstants.TYPE); + super(PRODUCT_GROUP, TYPE); } public TCPSelector create(String description) { return new TCPSelector(); } + + public static TCPSelector get(IManagedContainer container, String description) + { + return (TCPSelector)container.getElement(PRODUCT_GROUP, TYPE, description); + } } diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java index 99f861f0c4..81181adf82 100644 --- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java +++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java @@ -10,7 +10,6 @@ **************************************************************************/ package org.eclipse.net4j.internal.tcp; -import org.eclipse.net4j.tcp.ITCPConstants; import org.eclipse.net4j.util.container.IElementProcessor; import org.eclipse.net4j.util.container.IManagedContainer; @@ -19,6 +18,8 @@ import org.eclipse.net4j.util.container.IManagedContainer; */ public class TCPSelectorInjector implements IElementProcessor { + public static final String TYPE = null; + public TCPSelectorInjector() { } @@ -48,6 +49,6 @@ public class TCPSelectorInjector implements IElementProcessor protected TCPSelector getSelector(IManagedContainer container) { - return (TCPSelector)container.getElement(TCPSelectorFactory.SELECTOR_GROUP, ITCPConstants.TYPE, null); + return TCPSelectorFactory.get(container, null); } } diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ITCPConstants.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ITCPConstants.java deleted file mode 100644 index e132c1971d..0000000000 --- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/tcp/ITCPConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.tcp; - -/** - * @author Eike Stepper - */ -public interface ITCPConstants -{ - public static final String TYPE = "tcp"; - - public static final String DEFAULT_ADDRESS = "0.0.0.0"; //$NON-NLS-1$ - - public static final int DEFAULT_PORT = 2036; -} diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java index 4a6512ea40..c8c7ee2572 100644 --- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java @@ -10,17 +10,17 @@ **************************************************************************/ package org.eclipse.net4j.tests; +import org.eclipse.net4j.Net4jUtil; import org.eclipse.net4j.internal.tcp.TCPAcceptorFactory; import org.eclipse.net4j.internal.tcp.TCPConnectorFactory; -import org.eclipse.net4j.internal.tcp.TCPSelectorFactory; -import org.eclipse.net4j.internal.tcp.TCPSelectorInjector; -import org.eclipse.net4j.tcp.ITCPConstants; +import org.eclipse.net4j.internal.util.container.ManagedContainer; +import org.eclipse.net4j.tcp.TCPUtil; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; import org.eclipse.net4j.util.tests.AbstractOMTest; import org.eclipse.internal.net4j.Acceptor; import org.eclipse.internal.net4j.Connector; -import org.eclipse.internal.net4j.TransportContainer; /** * @author Eike Stepper @@ -29,7 +29,7 @@ public abstract class AbstractTransportTest extends AbstractOMTest { protected static final String HOST = "localhost"; - protected TransportContainer container; + protected IManagedContainer container; private Acceptor acceptor; @@ -60,13 +60,11 @@ public abstract class AbstractTransportTest extends AbstractOMTest } } - protected TransportContainer createContainer() + protected IManagedContainer createContainer() { - TransportContainer container = new TransportContainer(); - container.registerFactory(new TCPSelectorFactory()); - container.registerFactory(new TCPAcceptorFactory()); - container.registerFactory(new TCPConnectorFactory()); - container.addPostProcessor(new TCPSelectorInjector()); + IManagedContainer container = new ManagedContainer(); + Net4jUtil.prepareContainer(container); + TCPUtil.prepareContainer(container); return container; } @@ -74,7 +72,7 @@ public abstract class AbstractTransportTest extends AbstractOMTest { if (acceptor == null) { - acceptor = container.getAcceptor(ITCPConstants.TYPE, null); + acceptor = TCPAcceptorFactory.get(container, null); } return acceptor; @@ -84,7 +82,7 @@ public abstract class AbstractTransportTest extends AbstractOMTest { if (connector == null) { - connector = container.getConnector(ITCPConstants.TYPE, HOST); + connector = TCPConnectorFactory.get(container, HOST); } return connector; diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java index 8d29c501ca..ddc0840a64 100644 --- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java @@ -15,8 +15,7 @@ import org.eclipse.net4j.tests.signal.Request1; import org.eclipse.net4j.tests.signal.Request2; import org.eclipse.net4j.tests.signal.TestSignalProtocol; import org.eclipse.net4j.tests.signal.TestSignalServerProtocolFactory; - -import org.eclipse.internal.net4j.TransportContainer; +import org.eclipse.net4j.util.container.IManagedContainer; import java.util.Arrays; @@ -26,9 +25,9 @@ import java.util.Arrays; public class SignalTest extends AbstractTransportTest { @Override - protected TransportContainer createContainer() + protected IManagedContainer createContainer() { - TransportContainer container = super.createContainer(); + IManagedContainer container = super.createContainer(); container.registerFactory(new TestSignalServerProtocolFactory()); return container; } @@ -36,7 +35,7 @@ public class SignalTest extends AbstractTransportTest public void testInteger() throws Exception { startTransport(); - IChannel channel = getConnector().openChannel(TestSignalProtocol.TYPE); + IChannel channel = getConnector().openChannel(TestSignalProtocol.PROTOCOL_NAME); int data = 0x0a; int result = new Request1(channel, data).send(); assertEquals(data, result); @@ -45,7 +44,7 @@ public class SignalTest extends AbstractTransportTest public void testArray() throws Exception { startTransport(); - IChannel channel = getConnector().openChannel(TestSignalProtocol.TYPE); + IChannel channel = getConnector().openChannel(TestSignalProtocol.PROTOCOL_NAME); byte[] data = TinyData.getBytes(); byte[] result = new Request2(channel, data).send(); assertTrue(Arrays.equals(data, result)); diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java index 9ddc0524ac..2ee0eb5c4c 100644 --- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java @@ -12,17 +12,18 @@ package org.eclipse.net4j.tests; import org.eclipse.net4j.IAcceptorEvent; import org.eclipse.net4j.IBuffer; +import org.eclipse.net4j.IBufferProvider; import org.eclipse.net4j.IChannel; import org.eclipse.net4j.IConnectorChannelsEvent; +import org.eclipse.net4j.Net4jUtil; import org.eclipse.net4j.stream.ChannelInputStream; import org.eclipse.net4j.stream.ChannelOutputStream; import org.eclipse.net4j.tests.signal.TestSignalServerProtocolFactory; import org.eclipse.net4j.util.container.IContainerDelta; +import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.event.IEvent; import org.eclipse.net4j.util.event.IListener; -import org.eclipse.internal.net4j.TransportContainer; - import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -40,16 +41,17 @@ import java.util.concurrent.TimeUnit; public class TCPTransportTest extends AbstractTransportTest { @Override - protected TransportContainer createContainer() + protected IManagedContainer createContainer() { - TransportContainer container = super.createContainer(); + IManagedContainer container = super.createContainer(); container.registerFactory(new TestSignalServerProtocolFactory()); return container; } protected IBuffer provideBuffer() { - return container.getBufferProvider().provideBuffer(); + IBufferProvider bufferProvider = Net4jUtil.getBufferProvider(container); + return bufferProvider.provideBuffer(); } public void testConnect() throws Exception @@ -319,7 +321,8 @@ public class TCPTransportTest extends AbstractTransportTest { try { - ChannelOutputStream outputStream = new ChannelOutputStream(channel, container.getBufferProvider()); + IBufferProvider bufferProvider = Net4jUtil.getBufferProvider(container); + ChannelOutputStream outputStream = new ChannelOutputStream(channel, bufferProvider); PrintStream printer = new PrintStream(outputStream); StringTokenizer tokenizer = HugeData.getTokenizer(); while (tokenizer.hasMoreTokens()) diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestBufferPool.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestBufferPool.java index c54f13525e..8d8d201fa8 100644 --- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestBufferPool.java +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestBufferPool.java @@ -12,7 +12,7 @@ package org.eclipse.net4j.tests; import org.eclipse.net4j.IBuffer; import org.eclipse.net4j.IBufferPool; -import org.eclipse.net4j.BufferUtil; +import org.eclipse.net4j.Net4jUtil; import org.eclipse.net4j.internal.util.om.trace.PrintTraceHandler; import org.eclipse.net4j.util.ReflectUtil; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; @@ -26,7 +26,7 @@ import java.util.Collection; */ public class TestBufferPool { - private static IBufferPool bufferPool = BufferUtil.createBufferPool(); + private static IBufferPool bufferPool = Net4jUtil.createBufferPool(); private static Collection memory = new ArrayList(); @@ -48,7 +48,7 @@ public class TestBufferPool buffers[i] = null; } - while (BufferUtil.getPooledBuffers(bufferPool) > 0 && allocate()) + while (Net4jUtil.getPooledBuffers(bufferPool) > 0 && allocate()) { Thread.sleep(200); ReflectUtil.dump(bufferPool); @@ -59,7 +59,7 @@ public class TestBufferPool private static void msg() { - System.out.println("pooledBuffers = " + BufferUtil.getPooledBuffers(bufferPool)); + System.out.println("pooledBuffers = " + Net4jUtil.getPooledBuffers(bufferPool)); } private static boolean allocate() diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java index 88d1e56298..4d53889136 100644 --- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java @@ -18,7 +18,7 @@ import org.eclipse.net4j.signal.SignalReactor; */ public class TestSignalProtocol extends SignalProtocol { - public static final String TYPE = "signal.protocol"; + public static final String PROTOCOL_NAME = "signal.protocol"; public static final short SIGNAL1 = 1; @@ -30,7 +30,7 @@ public class TestSignalProtocol extends SignalProtocol public String getType() { - return TYPE; + return PROTOCOL_NAME; } @Override diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalServerProtocolFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalServerProtocolFactory.java index a710ac624a..9e048a7df7 100644 --- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalServerProtocolFactory.java +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalServerProtocolFactory.java @@ -9,9 +9,11 @@ import org.eclipse.internal.net4j.ServerProtocolFactory; */ public class TestSignalServerProtocolFactory extends ServerProtocolFactory { + public static final String TYPE = TestSignalProtocol.PROTOCOL_NAME; + public TestSignalServerProtocolFactory() { - super(TestSignalProtocol.TYPE); + super(TYPE); } public TestSignalProtocol create(String description) throws ProductCreationException diff --git a/plugins/org.eclipse.net4j.ui/.options b/plugins/org.eclipse.net4j.ui/.options index c141fcfdf6..d7963222c2 100644 --- a/plugins/org.eclipse.net4j.ui/.options +++ b/plugins/org.eclipse.net4j.ui/.options @@ -1 +1 @@ -org.eclipse.net4j.container.ui/debug = true +org.eclipse.net4j.ui/debug = true diff --git a/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF index 80a85cba51..ceec3f2d0e 100644 --- a/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF @@ -6,17 +6,8 @@ Bundle-Version: 0.8.0.qualifier Bundle-Activator: org.eclipse.net4j.internal.ui.bundle.OM$Activator Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.runtime, - org.eclipse.ui;visibility:=reexport, org.eclipse.net4j;visibility:=reexport, - org.eclipse.core.resources, - org.eclipse.ui.ide + org.eclipse.net4j.util.ui;visibility:=reexport Eclipse-LazyStart: true Export-Package: org.eclipse.net4j.internal.ui;version="0.8.0", - org.eclipse.net4j.internal.ui.views;version="0.8.0", - org.eclipse.net4j.internal.ui.wizards;version="0.8.0", - org.eclipse.net4j.internal.ui.wizards.steps;version="0.8.0", - org.eclipse.net4j.ui;version="0.8.0", - org.eclipse.net4j.ui.actions;version="0.8.0", - org.eclipse.net4j.ui.views;version="0.8.0", - org.eclipse.net4j.ui.widgets;version="0.8.0", - org.eclipse.net4j.ui.wizards;version="0.8.0" + org.eclipse.net4j.internal.ui.views;version="0.8.0" diff --git a/plugins/org.eclipse.net4j.ui/plugin.properties b/plugins/org.eclipse.net4j.ui/plugin.properties index 29355cd12f..56e1c0c093 100644 --- a/plugins/org.eclipse.net4j.ui/plugin.properties +++ b/plugins/org.eclipse.net4j.ui/plugin.properties @@ -24,7 +24,7 @@ # append it to the end of the file, and change the code to use the new name. # ============================================================================== -pluginName=Net4j Container UI +pluginName=Net4j UI providerName=Eclipse.org # ============================================================================== diff --git a/plugins/org.eclipse.net4j.ui/plugin.xml b/plugins/org.eclipse.net4j.ui/plugin.xml index 845447e429..8b66fef242 100644 --- a/plugins/org.eclipse.net4j.ui/plugin.xml +++ b/plugins/org.eclipse.net4j.ui/plugin.xml @@ -6,26 +6,26 @@ + id="org.eclipse.net4j.AcceptorsView" + name="Net4j Acceptors"> + id="org.eclipse.net4j.ConnectorsView" + name="Net4j Connectors"> - - + diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/AcceptorContentProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/AcceptorContentProvider.java index b8ed10e0e4..a6a78ac6f3 100644 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/AcceptorContentProvider.java +++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/AcceptorContentProvider.java @@ -10,8 +10,8 @@ **************************************************************************/ package org.eclipse.net4j.internal.ui; -import org.eclipse.net4j.ui.StructuredContentProvider; import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.ui.StructuredContentProvider; import org.eclipse.internal.net4j.AcceptorFactory; @@ -20,7 +20,7 @@ import org.eclipse.internal.net4j.AcceptorFactory; */ public class AcceptorContentProvider extends StructuredContentProvider { - public static final String PRODUCT_GROUP = AcceptorFactory.ACCEPTOR_GROUP; + public static final String PRODUCT_GROUP = AcceptorFactory.PRODUCT_GROUP; public AcceptorContentProvider() { diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ConnectorContentProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ConnectorContentProvider.java index 7ad129113c..1b3ba8e244 100644 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ConnectorContentProvider.java +++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ConnectorContentProvider.java @@ -10,8 +10,8 @@ **************************************************************************/ package org.eclipse.net4j.internal.ui; -import org.eclipse.net4j.ui.StructuredContentProvider; import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.ui.StructuredContentProvider; import org.eclipse.internal.net4j.ConnectorFactory; @@ -20,7 +20,7 @@ import org.eclipse.internal.net4j.ConnectorFactory; */ public class ConnectorContentProvider extends StructuredContentProvider { - public static final String PRODUCT_GROUP = ConnectorFactory.CONNECTOR_GROUP; + public static final String PRODUCT_GROUP = ConnectorFactory.PRODUCT_GROUP; public ConnectorContentProvider() { diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/FactoryTypeContentProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/FactoryTypeContentProvider.java index 15f0104042..a2045a3596 100644 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/FactoryTypeContentProvider.java +++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/FactoryTypeContentProvider.java @@ -10,8 +10,8 @@ **************************************************************************/ package org.eclipse.net4j.internal.ui; -import org.eclipse.net4j.ui.StructuredContentProvider; import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.ui.StructuredContentProvider; /** * @author Eike Stepper diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java index 35354812c1..a61e0c4523 100644 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java +++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java @@ -10,13 +10,12 @@ **************************************************************************/ package org.eclipse.net4j.internal.ui.bundle; -import org.eclipse.net4j.ui.UIActivator; import org.eclipse.net4j.util.om.OMBundle; import org.eclipse.net4j.util.om.OMPlatform; import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.pref.OMPreference; import org.eclipse.net4j.util.om.pref.OMPreferences; import org.eclipse.net4j.util.om.trace.OMTracer; +import org.eclipse.net4j.util.ui.UIActivator; /** * @author Eike Stepper @@ -33,8 +32,6 @@ public abstract class OM public static final OMPreferences PREFS = BUNDLE.preferences(); - public static final OMPreference PREF_HISTORY = PREFS.initArray("history"); - /** * @author Eike Stepper */ diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java index da965926c1..b0f24a7bd3 100644 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java +++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java @@ -1,12 +1,13 @@ package org.eclipse.net4j.internal.ui.views; import org.eclipse.net4j.IAcceptor; -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.ui.actions.SafeAction; -import org.eclipse.net4j.ui.views.ContainerItemProvider; -import org.eclipse.net4j.ui.views.ContainerView; -import org.eclipse.net4j.ui.views.IElementFilter; +import org.eclipse.net4j.Net4jUtil; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IPluginTransportContainer; +import org.eclipse.net4j.util.ui.actions.SafeAction; +import org.eclipse.net4j.util.ui.views.ContainerItemProvider; +import org.eclipse.net4j.util.ui.views.ContainerView; +import org.eclipse.net4j.util.ui.views.IElementFilter; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; @@ -19,7 +20,7 @@ public class AcceptorsView extends ContainerView @Override protected void doRun() throws Exception { - IPluginTransportContainer.INSTANCE.getAcceptor("tcp", "0.0.0.0:2036"); + Net4jUtil.getAcceptor(IPluginTransportContainer.INSTANCE, "tcp", "0.0.0.0:2036"); } }; @@ -29,7 +30,7 @@ public class AcceptorsView extends ContainerView @Override protected void doRun() throws Exception { - IPluginTransportContainer.INSTANCE.getAcceptor("tcp", "0.0.0.0:2037"); + Net4jUtil.getAcceptor(IPluginTransportContainer.INSTANCE, "tcp", "0.0.0.0:2037"); } }; @@ -38,7 +39,7 @@ public class AcceptorsView extends ContainerView } @Override - protected ITransportContainer getContainer() + protected IManagedContainer getContainer() { return IPluginTransportContainer.INSTANCE; } diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java index 138bc77b5b..86edc0e5fb 100644 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java +++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java @@ -1,12 +1,13 @@ package org.eclipse.net4j.internal.ui.views; import org.eclipse.net4j.IConnector; -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.ui.actions.SafeAction; -import org.eclipse.net4j.ui.views.ContainerItemProvider; -import org.eclipse.net4j.ui.views.ContainerView; -import org.eclipse.net4j.ui.views.IElementFilter; +import org.eclipse.net4j.Net4jUtil; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IPluginTransportContainer; +import org.eclipse.net4j.util.ui.actions.SafeAction; +import org.eclipse.net4j.util.ui.views.ContainerItemProvider; +import org.eclipse.net4j.util.ui.views.ContainerView; +import org.eclipse.net4j.util.ui.views.IElementFilter; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; @@ -18,7 +19,7 @@ public class ConnectorsView extends ContainerView @Override protected void doRun() throws Exception { - IPluginTransportContainer.INSTANCE.getConnector("tcp", "127.0.0.1:2036"); + Net4jUtil.getConnector(IPluginTransportContainer.INSTANCE, "tcp", "127.0.0.1:2036"); } }; @@ -27,7 +28,7 @@ public class ConnectorsView extends ContainerView } @Override - protected ITransportContainer getContainer() + protected IManagedContainer getContainer() { return IPluginTransportContainer.INSTANCE; } diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java index 7bbca94068..20aa00e792 100644 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java +++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java @@ -14,11 +14,11 @@ import org.eclipse.net4j.IAcceptor; import org.eclipse.net4j.IChannel; import org.eclipse.net4j.IConnector; import org.eclipse.net4j.internal.ui.SharedIcons; -import org.eclipse.net4j.ui.actions.SafeAction; -import org.eclipse.net4j.ui.views.ContainerItemProvider; -import org.eclipse.net4j.ui.views.ContainerView; -import org.eclipse.net4j.ui.views.IElementFilter; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; +import org.eclipse.net4j.util.ui.actions.SafeAction; +import org.eclipse.net4j.util.ui.views.ContainerItemProvider; +import org.eclipse.net4j.util.ui.views.ContainerView; +import org.eclipse.net4j.util.ui.views.IElementFilter; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.viewers.ITreeSelection; diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/NewAcceptorWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/NewAcceptorWizard.java deleted file mode 100644 index d466ec70c4..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/NewAcceptorWizard.java +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.ui.wizards; - -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.internal.ui.wizards.steps.NewAcceptorStep; -import org.eclipse.net4j.ui.wizards.Step; -import org.eclipse.net4j.ui.wizards.SteppingNewWizard; - -import org.eclipse.core.runtime.IProgressMonitor; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class NewAcceptorWizard extends SteppingNewWizard -{ - public NewAcceptorWizard(Map context) - { - super(context); - } - - public NewAcceptorWizard(String type, String description) - { - super(createContext(type, description)); - } - - public NewAcceptorWizard() - { - } - - @Override - protected Step createRootStep() - { - return new NewAcceptorStep(getTransportContainer()); - } - - @Override - protected void doFinish(IProgressMonitor monitor) throws Exception - { - NewAcceptorStep step = (NewAcceptorStep)getRootStep(); - ITransportContainer transportContainer = getTransportContainer(); - transportContainer.getAcceptor(step.getAcceptorType(), step.getAcceptorDescription()); - } - - protected ITransportContainer getTransportContainer() - { - return IPluginTransportContainer.INSTANCE; - } - - private static Map createContext(String type, String description) - { - Map context = new HashMap(); - if (type != null) - { - context.put(NewAcceptorStep.KEY_TYPE, type); - } - - if (description != null) - { - context.put(NewAcceptorStep.KEY_DESCRIPTION, description); - } - - return context; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/NewConnectorWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/NewConnectorWizard.java deleted file mode 100644 index d30a72c4be..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/NewConnectorWizard.java +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.ui.wizards; - -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.internal.ui.wizards.steps.NewConnectorStep; -import org.eclipse.net4j.ui.wizards.Step; -import org.eclipse.net4j.ui.wizards.SteppingNewWizard; - -import org.eclipse.core.runtime.IProgressMonitor; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class NewConnectorWizard extends SteppingNewWizard -{ - public NewConnectorWizard(Map context) - { - super(context); - } - - public NewConnectorWizard(String connectorType, String description) - { - super(createContext(connectorType, description)); - } - - public NewConnectorWizard() - { - } - - @Override - protected Step createRootStep() - { - return new NewConnectorStep(getTransportContainer()); - } - - @Override - protected void doFinish(IProgressMonitor monitor) throws Exception - { - NewConnectorStep step = (NewConnectorStep)getRootStep(); - ITransportContainer transportContainer = getTransportContainer(); - transportContainer.getConnector(step.getConnectorType(), step.getConnectorDescription()); - } - - protected ITransportContainer getTransportContainer() - { - return IPluginTransportContainer.INSTANCE; - } - - private static Map createContext(String connectorType, String description) - { - Map context = new HashMap(); - if (connectorType != null) - { - context.put(NewConnectorStep.KEY_TYPE, connectorType); - } - - if (description != null) - { - context.put(NewConnectorStep.KEY_DESCRIPTION, description); - } - - return context; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/NewAcceptorStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/NewAcceptorStep.java deleted file mode 100644 index 8a94d9cf5f..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/NewAcceptorStep.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.eclipse.net4j.internal.ui.wizards.steps; - -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.internal.ui.FactoryTypeContentProvider; -import org.eclipse.net4j.ui.wizards.ParallelStep; -import org.eclipse.net4j.ui.wizards.SelectionStep; -import org.eclipse.net4j.ui.wizards.StringStep; - -import org.eclipse.internal.net4j.AcceptorFactory; - -/** - * @author Eike Stepper - */ -public class NewAcceptorStep extends ParallelStep -{ - public static final String PRODUCT_GROUP = AcceptorFactory.ACCEPTOR_GROUP; - - public static final String KEY_TYPE = "Acceptor type"; - - public static final String KEY_DESCRIPTION = "Acceptor description"; - - public NewAcceptorStep(ITransportContainer container) - { - add(new SelectionStep(KEY_TYPE, String.class, container, new FactoryTypeContentProvider(PRODUCT_GROUP), - null, 1, 1)); - add(new StringStep("Description", KEY_DESCRIPTION)); - } - - public NewAcceptorStep() - { - this(IPluginTransportContainer.INSTANCE); - } - - public String getAcceptorType() - { - Object value = getWizard().getSingleContextValue(KEY_TYPE); - return value instanceof String ? (String)value : null; - } - - public String getAcceptorDescription() - { - Object value = getWizard().getSingleContextValue(KEY_DESCRIPTION); - return value instanceof String ? (String)value : null; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/NewConnectorStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/NewConnectorStep.java deleted file mode 100644 index 067537d6d8..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/NewConnectorStep.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.eclipse.net4j.internal.ui.wizards.steps; - -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.internal.ui.FactoryTypeContentProvider; -import org.eclipse.net4j.ui.wizards.ParallelStep; -import org.eclipse.net4j.ui.wizards.SelectionStep; -import org.eclipse.net4j.ui.wizards.StringStep; - -import org.eclipse.internal.net4j.ConnectorFactory; - -/** - * @author Eike Stepper - */ -public class NewConnectorStep extends ParallelStep -{ - public static final String PRODUCT_GROUP = ConnectorFactory.CONNECTOR_GROUP; - - public static final String KEY_TYPE = "Connector type"; - - public static final String KEY_DESCRIPTION = "Connector description"; - - public NewConnectorStep(ITransportContainer container) - { - add(new SelectionStep(KEY_TYPE, String.class, container, new FactoryTypeContentProvider(PRODUCT_GROUP), - null, 1, 1)); - add(new StringStep("Description", KEY_DESCRIPTION)); - } - - public NewConnectorStep() - { - this(IPluginTransportContainer.INSTANCE); - } - - public String getConnectorType() - { - Object value = getWizard().getSingleContextValue(KEY_TYPE); - return value instanceof String ? (String)value : null; - } - - public String getConnectorDescription() - { - Object value = getWizard().getSingleContextValue(KEY_DESCRIPTION); - return value instanceof String ? (String)value : null; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/ProvideConnectorStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/ProvideConnectorStep.java deleted file mode 100644 index f619996149..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/ProvideConnectorStep.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.eclipse.net4j.internal.ui.wizards.steps; - -import org.eclipse.net4j.IConnector; -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.ui.wizards.DecisionStep; - -/** - * @author Eike Stepper - */ -public class ProvideConnectorStep extends DecisionStep -{ - private ITransportContainer container; - - private SelectConnectorStep selectConnectorStep; - - private NewConnectorStep newConnectorStep; - - public ProvideConnectorStep(ITransportContainer container) - { - this.container = container; - add(selectConnectorStep = new SelectConnectorStep(container)); - add(newConnectorStep = new NewConnectorStep(container)); - } - - public ProvideConnectorStep() - { - this(IPluginTransportContainer.INSTANCE); - } - - public IConnector getConnector() - { - int decision = getDecisionIndex(); - switch (decision) - { - case 0: - return selectConnectorStep.getConnector(); - - case 1: - String type = newConnectorStep.getConnectorType(); - String description = newConnectorStep.getConnectorDescription(); - return container.getConnector(type, description); - - default: - throw new IllegalStateException("decision: " + decision); - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/SelectAcceptorStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/SelectAcceptorStep.java deleted file mode 100644 index ed01982077..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/SelectAcceptorStep.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.eclipse.net4j.internal.ui.wizards.steps; - -import org.eclipse.net4j.IAcceptor; -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.internal.ui.AcceptorContentProvider; -import org.eclipse.net4j.ui.wizards.ParallelStep; -import org.eclipse.net4j.ui.wizards.SelectionStep; - -/** - * @author Eike Stepper - */ -public class SelectAcceptorStep extends ParallelStep -{ - public static final String KEY_ACCEPTOR = "Acceptor"; - - public SelectAcceptorStep(ITransportContainer container) - { - add(new SelectionStep(KEY_ACCEPTOR, IAcceptor.class, container, new AcceptorContentProvider(), null, 1, 1)); - } - - public SelectAcceptorStep() - { - this(IPluginTransportContainer.INSTANCE); - } - - public IAcceptor getAcceptor() - { - Object value = getWizard().getSingleContextValue(KEY_ACCEPTOR); - return value instanceof IAcceptor ? (IAcceptor)value : null; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/SelectConnectorStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/SelectConnectorStep.java deleted file mode 100644 index 83945c3a9f..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/SelectConnectorStep.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.eclipse.net4j.internal.ui.wizards.steps; - -import org.eclipse.net4j.IConnector; -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.internal.ui.ConnectorContentProvider; -import org.eclipse.net4j.ui.wizards.ParallelStep; -import org.eclipse.net4j.ui.wizards.SelectionStep; - -/** - * @author Eike Stepper - */ -public class SelectConnectorStep extends ParallelStep -{ - public static final String KEY_CONNECTOR = "Connector"; - - public SelectConnectorStep(ITransportContainer container) - { - add(new SelectionStep(KEY_CONNECTOR, IConnector.class, container, new ConnectorContentProvider(), null, 1, - 1)); - } - - public SelectConnectorStep() - { - this(IPluginTransportContainer.INSTANCE); - } - - public IConnector getConnector() - { - Object value = getWizard().getSingleContextValue(KEY_CONNECTOR); - return value instanceof IConnector ? (IConnector)value : null; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/AccountStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/AccountStep.java deleted file mode 100644 index f31a8826e2..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/AccountStep.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.eclipse.net4j.internal.ui.wizards.steps.sample; - -import org.eclipse.net4j.ui.wizards.ParallelStep; -import org.eclipse.net4j.ui.wizards.StringStep; - -/** - * @author Eike Stepper - */ -public class AccountStep extends ParallelStep -{ - public AccountStep() - { - add(new StringStep("Account-ID")); - add(new StringStep("Account-Owner")); - add(new StringStep("Bank-Code")); - add(new StringStep("Bank-Name")); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/AddressStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/AddressStep.java deleted file mode 100644 index 8b5d238e29..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/AddressStep.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.eclipse.net4j.internal.ui.wizards.steps.sample; - -import org.eclipse.net4j.ui.wizards.ParallelStep; -import org.eclipse.net4j.ui.wizards.StaticSelectionStep; -import org.eclipse.net4j.ui.wizards.StringStep; - -/** - * @author Eike Stepper - */ -public class AddressStep extends ParallelStep -{ - private static final String[] PETS = { "Elvis", "Tim", "Teufel", "Robbie", "Else", "Nino" }; - - public AddressStep() - { - add(new StaticSelectionStep("Sex", Sex.class, 1, 1)); - add(new StringStep("Name")); - add(new StringStep("Street")); - add(new StringStep("Zip-Code")); - add(new StringStep("City")); - add(new StaticSelectionStep("Pets", PETS, 0, 1)); - } - - public static enum Sex - { - MALE, FEMALE - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/CustomerStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/CustomerStep.java deleted file mode 100644 index 48ac0b2222..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/wizards/steps/sample/CustomerStep.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.eclipse.net4j.internal.ui.wizards.steps.sample; - -import org.eclipse.net4j.internal.ui.wizards.steps.NewAcceptorStep; -import org.eclipse.net4j.ui.wizards.SequentialStep; - -/** - * @author Eike Stepper - */ -public class CustomerStep extends SequentialStep -{ - public CustomerStep() - { - add(new AddressStep()); - add(new NewAcceptorStep()); - add(new AccountStep()); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/ComboAutoCompleter.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/ComboAutoCompleter.java deleted file mode 100644 index 05260c6dcf..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/ComboAutoCompleter.java +++ /dev/null @@ -1,92 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui; - -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; - -/** - * @author Eike Stepper - */ -public class ComboAutoCompleter implements ModifyListener -{ - private ComboViewer viewer; - - public ComboAutoCompleter(ComboViewer viewer) - { - this.viewer = viewer; - } - - public final ComboViewer getViewer() - { - return viewer; - } - - public final void modifyText(ModifyEvent e) - { - String text = getText(); - Object foundElement = findShortestLabel(text); - if (foundElement != null) - { - setSelection(new StructuredSelection(foundElement)); - } - else - { - // setSelection(StructuredSelection.EMPTY); - } - } - - protected void setSelection(StructuredSelection selection) - { - viewer.setSelection(selection); - } - - private Object findShortestLabel(String prefix) - { - Object foundElement = null; - String shortestLabel = null; - ILabelProvider labelProvider = (ILabelProvider)viewer.getLabelProvider(); - IStructuredContentProvider contentProvider = (IStructuredContentProvider)viewer.getContentProvider(); - for (Object element : contentProvider.getElements(viewer.getInput())) - { - String label = labelProvider.getText(element); - if (label.startsWith(prefix)) - { - if (shortestLabel == null || label.length() < shortestLabel.length()) - { - shortestLabel = label; - foundElement = element; - } - } - } - - return foundElement; - } - - private String getText() - { - return viewer.getCombo().getText(); - } - - public static void attach(ComboViewer viewer, ComboAutoCompleter completer) - { - viewer.getCombo().addModifyListener(completer); - } - - public static void attach(ComboViewer viewer) - { - viewer.getCombo().addModifyListener(new ComboAutoCompleter(viewer)); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/DelegatingContentProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/DelegatingContentProvider.java deleted file mode 100644 index b32a7fa639..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/DelegatingContentProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -/** - * @author Eike Stepper - */ -public class DelegatingContentProvider implements IStructuredContentProvider -{ - public static final String NONE = ""; - - private IStructuredContentProvider delegate; - - private boolean optional; - - public DelegatingContentProvider(IStructuredContentProvider delegate, boolean optional) - { - this.delegate = delegate; - this.optional = optional; - } - - public DelegatingContentProvider(IStructuredContentProvider delegate) - { - this(delegate, false); - } - - public IStructuredContentProvider getDelegate() - { - return delegate; - } - - public boolean isOptional() - { - return optional; - } - - public void dispose() - { - delegate.dispose(); - } - - public Object[] getElements(Object inputElement) - { - Object[] elements = delegate.getElements(inputElement); - if (optional) - { - Object[] newElements = new Object[elements.length + 1]; - newElements[0] = NONE; - System.arraycopy(elements, 0, newElements, 1, elements.length); - elements = newElements; - } - - return elements; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - delegate.inputChanged(viewer, oldInput, newInput); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StaticContentProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StaticContentProvider.java deleted file mode 100644 index ad6e1f400b..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StaticContentProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui; - -import java.util.Collection; - -/** - * @author Eike Stepper - */ -public class StaticContentProvider extends StructuredContentProvider -{ - private Object[] elements; - - public StaticContentProvider(Object[] elements) - { - this.elements = elements; - } - - public StaticContentProvider(Collection elements) - { - this(elements.toArray()); - } - - public StaticContentProvider(Class enumClass) - { - this(createElements(enumClass)); - } - - public Object[] getElements(Object inputElement) - { - return elements; - } - - private static Object[] createElements(Class enumClass) - { - Object[] enumConstants = enumClass.getEnumConstants(); - if (enumConstants == null) - { - throw new IllegalArgumentException("Illegal enum: " + enumClass); - } - - return enumConstants; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java deleted file mode 100644 index c1945b0381..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java +++ /dev/null @@ -1,165 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui; - -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Display; - -/** - * @author Eike Stepper - */ -public abstract class StructuredContentProvider implements IStructuredContentProvider, IListener -{ - private StructuredViewer viewer; - - private INPUT input; - - public StructuredContentProvider() - { - } - - public void dispose() - { - if (input != null) - { - disconnectInput(input); - input = null; - } - } - - public INPUT getInput() - { - return input; - } - - public StructuredViewer getViewer() - { - return viewer; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - this.viewer = (StructuredViewer)viewer; - if (newInput != input) - { - if (input != null) - { - disconnectInput(input); - } - try - { - input = (INPUT)newInput; - connectInput(input); - } - catch (Exception ex) - { - input = null; - } - } - } - - protected void connectInput(INPUT input) - { - } - - protected void disconnectInput(INPUT input) - { - } - - public void notifyEvent(IEvent event) - { - refreshViewer(true); - } - - protected void refreshViewer(boolean updateLabels) - { - refreshElement(null, updateLabels); - } - - protected void refreshElement(final Object element, final boolean updateLabels) - { - try - { - getDisplay().asyncExec(new Runnable() - { - public void run() - { - try - { - if (element != null) - { - viewer.refresh(element, updateLabels); - } - else - { - viewer.refresh(updateLabels); - } - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - - protected void revealElement(final Object element) - { - try - { - getDisplay().asyncExec(new Runnable() - { - public void run() - { - try - { - viewer.reveal(element); - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - - protected Display getDisplay() - { - Display display = viewer.getControl().getDisplay(); - if (display == null) - { - display = Display.getCurrent(); - } - - if (display == null) - { - display = Display.getDefault(); - } - - if (display == null) - { - throw new IllegalStateException("display == null"); - } - - return display; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIActivator.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIActivator.java deleted file mode 100644 index 1bf81d21ad..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIActivator.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui; - -import org.eclipse.net4j.internal.util.om.OSGiBundle; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OSGiActivator; - -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import org.osgi.framework.BundleContext; - -/** - * @author Eike Stepper - */ -public class UIActivator extends AbstractUIPlugin -{ - private OMBundle omBundle; - - public UIActivator(OMBundle omBundle) - { - this.omBundle = omBundle; - } - - public final OMBundle getOMBundle() - { - return omBundle; - } - - @Override - public void start(BundleContext context) throws Exception - { - OSGiActivator.startBundle(context, (OSGiBundle)getOMBundle()); - super.start(context); - } - - @Override - public void stop(BundleContext context) throws Exception - { - super.stop(context); - OSGiActivator.stopBundle(context, (OSGiBundle)getOMBundle()); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIUtil.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIUtil.java deleted file mode 100644 index 8358290b33..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/UIUtil.java +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; - -/** - * @author Eike Stepper - */ -public final class UIUtil -{ - private UIUtil() - { - } - - public static Composite createGridComposite(Composite parent, int columns) - { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(createGridLayout(columns)); - return composite; - } - - public static GridLayout createGridLayout(int columns) - { - GridLayout layout = new GridLayout(); - layout.numColumns = columns; - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = 0; - layout.horizontalSpacing = 0; - return layout; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java deleted file mode 100644 index 02f85c09a9..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java +++ /dev/null @@ -1,191 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.actions; - -import org.eclipse.net4j.internal.ui.bundle.OM; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; - -/** - * @author Eike Stepper - */ -public abstract class LongRunningAction extends SafeAction -{ - private IWorkbenchPage page; - - private IStatus status; - - private int totalWork; - - public LongRunningAction(IWorkbenchPage page) - { - this.page = page; - } - - public LongRunningAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image) - { - super(text, toolTipText, image); - this.page = page; - } - - public LongRunningAction(IWorkbenchPage page, String text, ImageDescriptor image) - { - super(text, image); - this.page = page; - } - - public LongRunningAction(IWorkbenchPage page, String text, String toolTipText) - { - super(text, toolTipText); - this.page = page; - } - - public LongRunningAction(IWorkbenchPage page, String text, int style) - { - super(text, style); - this.page = page; - } - - public LongRunningAction(IWorkbenchPage page, String text) - { - super(text); - this.page = page; - } - - public LongRunningAction() - { - } - - public LongRunningAction(String text, ImageDescriptor image) - { - super(text, image); - } - - public LongRunningAction(String text, int style) - { - super(text, style); - } - - public LongRunningAction(String text, String toolTipText, ImageDescriptor image) - { - super(text, toolTipText, image); - } - - public LongRunningAction(String text, String toolTipText) - { - super(text, toolTipText); - } - - public LongRunningAction(String text) - { - super(text); - } - - public void setPage(IWorkbenchPage page) - { - this.page = page; - } - - public IWorkbenchPage getPage() - { - return page; - } - - public IWorkbenchWindow getWorkbenchWindow() - { - return page.getWorkbenchWindow(); - } - - public Shell getShell() - { - return getWorkbenchWindow().getShell(); - } - - protected final int getTotalWork() - { - return totalWork; - } - - protected final void setTotalWork(int totalWork) - { - this.totalWork = totalWork; - } - - protected final void cancel() - { - totalWork = 0; - } - - protected final void setStatus(IStatus status) - { - this.status = status; - } - - @Override - protected final void doRun() throws Exception - { - totalWork = IProgressMonitor.UNKNOWN; - preRun(); - if (totalWork != 0) - { - new Job(getText()) - { - @Override - protected IStatus run(IProgressMonitor monitor) - { - monitor.beginTask("", totalWork); - try - { - setStatus(Status.OK_STATUS); - doRun(monitor); - return status; - } - catch (Exception ex) - { - return handleException(ex); - } - finally - { - monitor.done(); - } - } - }.schedule(); - } - } - - protected void preRun() throws Exception - { - } - - protected abstract void doRun(IProgressMonitor monitor) throws Exception; - - protected IStatus handleException(Exception ex) - { - ex.printStackTrace(); - return new Status(IStatus.ERROR, OM.BUNDLE_ID, "An error has occured.", ex); - } - - protected final void checkCancelation(IProgressMonitor monitor) - { - if (monitor.isCanceled()) - { - throw new OperationCanceledException(); - } - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/SafeAction.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/SafeAction.java deleted file mode 100644 index a1347353ca..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/SafeAction.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.eclipse.net4j.ui.actions; - -import org.eclipse.net4j.internal.ui.bundle.OM; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * @author Eike Stepper - */ -public abstract class SafeAction extends Action -{ - public SafeAction() - { - } - - public SafeAction(String text, String toolTipText, ImageDescriptor image) - { - super(text, image); - setToolTipText(toolTipText); - } - - public SafeAction(String text, String toolTipText) - { - super(text, null); - setToolTipText(toolTipText); - } - - public SafeAction(String text, ImageDescriptor image) - { - super(text, image); - } - - public SafeAction(String text, int style) - { - super(text, style); - } - - public SafeAction(String text) - { - super(text); - } - - @Override - public final void run() - { - try - { - doRun(); - } - catch (Exception ex) - { - OM.LOG.error(ex); - MessageDialog.openError(null, getText(), ex.getMessage() + "\nSee the Error log for details."); - } - } - - protected abstract void doRun() throws Exception; -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java deleted file mode 100644 index 35bc1ead94..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java +++ /dev/null @@ -1,385 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.views; - -import org.eclipse.net4j.internal.util.container.ContainerEventAdapter; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.lifecycle.LifecycleUtil; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class ContainerItemProvider extends ItemProvider -{ - private Map nodes = new HashMap(); - - private ContainerNode root; - - private IElementFilter rootElementFilter; - - public ContainerItemProvider() - { - } - - public ContainerItemProvider(IElementFilter rootElementFilter) - { - this.rootElementFilter = rootElementFilter; - } - - public IElementFilter getRootElementFilter() - { - return rootElementFilter; - } - - @Override - public boolean hasChildren(Object element) - { - try - { - Node node = getNode(element); - return !node.getChildren().isEmpty(); - } - catch (Exception ex) - { - return false; - } - } - - public Object[] getChildren(Object element) - { - try - { - Node node = getNode(element); - List children = node.getChildren(); - for (Iterator it = children.iterator(); it.hasNext();) - { - Object child = it.next(); - if (!LifecycleUtil.isActive(child)) - { - it.remove(); - } - } - - Object[] result = new Object[children.size()]; - for (int i = 0; i < result.length; i++) - { - result[i] = children.get(i).getElement(); - } - - return result; - } - catch (RuntimeException ex) - { - return NO_CHILDREN; - } - } - - public Object getParent(Object element) - { - try - { - Node node = getNode(element); - Node parentNode = node.getParent(); - return parentNode == null ? null : parentNode.getElement(); - } - catch (RuntimeException ex) - { - return null; - } - } - - @Override - protected void connectInput(CONTAINER input) - { - root = (ContainerNode)createNode(null, input); - nodes.put(input, root); - } - - @Override - protected void disconnectInput(CONTAINER input) - { - root.dispose(); - root = null; - nodes.clear(); - } - - protected void elementAdded(Object element, Object parent) - { - } - - protected void elementRemoved(Object element, Object parent) - { - } - - protected ContainerNode getRoot() - { - return root; - } - - protected Map getNodes() - { - return nodes; - } - - protected Node getNode(Object element) - { - Node node = root; - if (element != getInput()) - { - node = nodes.get(element); - } - - if (node == null) - { - throw new IllegalStateException("No node for " + element); - } - - return node; - } - - protected Node createNode(Node parent, Object element) - { - if (element instanceof IContainer) - { - return new ContainerNode(parent, (IContainer)element); - } - - return new LeafNode(parent, element); - } - - protected boolean filterRootElement(Object element) - { - if (rootElementFilter != null) - { - return rootElementFilter.filter(element); - } - - return true; - } - - /** - * @author Eike Stepper - */ - public interface Node - { - public void dispose(); - - public Object getElement(); - - public Node getParent(); - - public List getChildren(); - } - - /** - * @author Eike Stepper - */ - public abstract class AbstractNode implements Node - { - private Node parent; - - private List children; - - public AbstractNode(Node parent) - { - this.parent = parent; - } - - public void dispose() - { - parent = null; - if (children != null) - { - for (Node child : children) - { - child.dispose(); - } - - children.clear(); - children = null; - } - } - - @Override - public String toString() - { - return getElement().toString(); - } - - public final Node getParent() - { - return parent; - } - - public final List getChildren() - { - if (children == null) - { - children = createChildren(); - } - - return children; - } - - protected abstract List createChildren(); - } - - /** - * @author Eike Stepper - */ - public class ContainerNode extends AbstractNode - { - private IContainer container; - - private IListener containerListener = new ContainerEventAdapter() - { - @Override - protected void onAdded(IContainer container, Object element) - { - if (container == ContainerNode.this.container) - { - Node node = addChild(getChildren(), element); - if (node != null) - { - refreshElement(container, false); - revealElement(element); - elementAdded(element, container); - } - } - } - - @Override - protected void onRemoved(IContainer container, Object element) - { - if (container == ContainerNode.this.container) - { - Node node = nodes.remove(element); - if (node != null) - { - getChildren().remove(node); - node.dispose(); - refreshElement(container, false); - elementRemoved(element, container); - } - } - } - }; - - public ContainerNode(Node parent, IContainer container) - { - super(parent); - this.container = container; - } - - @Override - public void dispose() - { - container.removeListener(containerListener); - container = null; - super.dispose(); - } - - public IContainer getContainer() - { - return container; - } - - public Object getElement() - { - return container; - } - - @Override - public String toString() - { - return container == null ? super.toString() : container.toString(); - } - - @Override - protected List createChildren() - { - Object[] elements = container.getElements(); - List children = new ArrayList(elements.length); - for (int i = 0; i < elements.length; i++) - { - Object element = elements[i]; - addChild(children, element); - } - - container.addListener(containerListener); - return children; - } - - protected Node addChild(List children, Object element) - { - if (this != root || filterRootElement(element)) - { - Node node = createNode(this, element); - nodes.put(element, node); - children.add(node); - return node; - } - - return null; - } - } - - /** - * @author Eike Stepper - */ - public class LeafNode implements Node - { - private Node parent; - - private Object element; - - public LeafNode(Node parent, Object element) - { - this.parent = parent; - this.element = element; - } - - public void dispose() - { - parent = null; - element = null; - } - - public Node getParent() - { - return parent; - } - - public Object getElement() - { - return element; - } - - public List getChildren() - { - return Collections.EMPTY_LIST; - } - - @Override - public String toString() - { - return element == null ? super.toString() : element.toString(); - } - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerNameSorter.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerNameSorter.java deleted file mode 100644 index 771216129d..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerNameSorter.java +++ /dev/null @@ -1,17 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.views; - -import org.eclipse.jface.viewers.ViewerSorter; - -public class ContainerNameSorter extends ViewerSorter -{ -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerView.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerView.java deleted file mode 100644 index 1f56168599..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerView.java +++ /dev/null @@ -1,270 +0,0 @@ -package org.eclipse.net4j.ui.views; - -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.internal.ui.SharedIcons; -import org.eclipse.net4j.ui.actions.SafeAction; - -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.resource.ImageDescriptor; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TreeViewer; -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.IWorkbenchActionConstants; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.ui.part.ViewPart; - -public abstract class ContainerView extends ViewPart implements ISetSelectionTarget -{ - private ContainerItemProvider itemProvider; - - private TreeViewer viewer; - - private ISelectionChangedListener selectionListener = new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - ITreeSelection selection = (ITreeSelection)event.getSelection(); - IActionBars bars = getViewSite().getActionBars(); - ContainerView.this.selectionChanged(bars, selection); - } - }; - - private Action refreshAction = new RefreshAction(); - - public ContainerView() - { - } - - @Override - public void setFocus() - { - viewer.getControl().setFocus(); - } - - public void selectReveal(ISelection selection) - { - viewer.setSelection(selection, true); - } - - @Override - public void createPartControl(Composite parent) - { - itemProvider = createContainerItemProvider(); - viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - viewer.setContentProvider(itemProvider); - viewer.setLabelProvider(itemProvider); - viewer.setSorter(new ContainerNameSorter()); - viewer.setInput(getContainer()); - viewer.addSelectionChangedListener(selectionListener); - getSite().setSelectionProvider(viewer); - - hookContextMenu(); - hookDoubleClick(); - contributeToActionBars(); - } - - protected ContainerItemProvider createContainerItemProvider() - { - return new ContainerItemProvider(getRootElementFilter()) - { - @Override - public Image getImage(Object obj) - { - Image image = getElementImage(obj); - if (image == null) - { - image = super.getImage(obj); - } - - return image; - } - - @Override - public String getText(Object obj) - { - String text = getElementText(obj); - if (text == null) - { - text = super.getText(obj); - } - - return text; - } - }; - } - - protected String getElementText(Object element) - { - return null; - } - - protected Image getElementImage(Object element) - { - return null; - } - - protected IElementFilter getRootElementFilter() - { - return null; - } - - protected abstract ITransportContainer getContainer(); - - protected void hookDoubleClick() - { - viewer.addDoubleClickListener(new IDoubleClickListener() - { - public void doubleClick(DoubleClickEvent event) - { - ITreeSelection selection = (ITreeSelection)viewer.getSelection(); - Object object = selection.getFirstElement(); - doubleClicked(object); - } - }); - } - - protected void hookContextMenu() - { - MenuManager menuMgr = new MenuManager("#PopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() - { - public void menuAboutToShow(IMenuManager manager) - { - ITreeSelection selection = (ITreeSelection)viewer.getSelection(); - fillContextMenu(manager, selection); - } - }); - - Menu menu = menuMgr.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuMgr, viewer); - } - - protected void contributeToActionBars() - { - IActionBars bars = getViewSite().getActionBars(); - fillLocalPullDown(bars.getMenuManager()); - fillLocalToolBar(bars.getToolBarManager()); - } - - protected void fillLocalPullDown(IMenuManager manager) - { - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - manager.add(refreshAction); - } - - protected void fillLocalToolBar(IToolBarManager manager) - { - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - protected void fillContextMenu(IMenuManager manager, ITreeSelection selection) - { - itemProvider.fillContextMenu(manager, selection); - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - protected void selectionChanged(IActionBars bars, ITreeSelection selection) - { - } - - protected void doubleClicked(Object object) - { - if (object != null && viewer.isExpandable(object)) - { - if (viewer.getExpandedState(object)) - { - viewer.collapseToLevel(object, TreeViewer.ALL_LEVELS); - } - else - { - viewer.expandToLevel(object, 1); - } - } - } - - protected void showMessage(String message) - { - showMessage(MessageType.INFORMATION, message); - } - - protected boolean showMessage(MessageType type, String message) - { - switch (type) - { - case INFORMATION: - MessageDialog.openInformation(viewer.getControl().getShell(), getTitle(), message); - return true; - - case ERROR: - MessageDialog.openError(viewer.getControl().getShell(), getTitle(), message); - return true; - - case WARNING: - MessageDialog.openWarning(viewer.getControl().getShell(), getTitle(), message); - return true; - - case CONFIRM: - return MessageDialog.openConfirm(viewer.getControl().getShell(), getTitle(), message); - - case QUESTION: - return MessageDialog.openQuestion(viewer.getControl().getShell(), getTitle(), message); - - default: - return true; - } - } - - public static ImageDescriptor getAddImageDescriptor() - { - return SharedIcons.getDescriptor(SharedIcons.ETOOL_ADD); - } - - public static ImageDescriptor getDeleteImageDescriptor() - { - return SharedIcons.getDescriptor(SharedIcons.ETOOL_DELETE); - } - - public static ImageDescriptor getRefreshImageDescriptor() - { - return SharedIcons.getDescriptor(SharedIcons.ETOOL_REFRESH); - } - - protected static enum MessageType - { - INFORMATION, ERROR, WARNING, CONFIRM, QUESTION - } - - /** - * @author Eike Stepper - */ - private final class RefreshAction extends SafeAction - { - private RefreshAction() - { - super("Refresh", "Refresh view", getRefreshImageDescriptor()); - } - - @Override - protected void doRun() throws Exception - { - viewer.refresh(false); - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/IElementFilter.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/IElementFilter.java deleted file mode 100644 index 12fa9b4955..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/IElementFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.views; - -/** - * @author Eike Stepper - */ -public interface IElementFilter -{ - public boolean filter(Object element); -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java deleted file mode 100644 index dd0d88ced5..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java +++ /dev/null @@ -1,131 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.views; - -import org.eclipse.net4j.internal.ui.bundle.OM; -import org.eclipse.net4j.ui.StructuredContentProvider; - -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.jface.viewers.LabelProviderChangedEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -import java.util.ArrayList; -import java.util.List; - -public abstract class ItemProvider extends StructuredContentProvider implements ITreeContentProvider, - ILabelProvider -{ - protected static final Object[] NO_CHILDREN = new Object[0]; - - private List listeners = new ArrayList(0); - - public ItemProvider() - { - } - - public final Object[] getElements(Object parent) - { - return getChildren(parent); - } - - public boolean hasChildren(Object parent) - { - return getChildren(parent).length != 0; - } - - public String getText(Object obj) - { - return obj.toString(); - } - - public Image getImage(Object obj) - { - String imageKey = ISharedImages.IMG_OBJ_ELEMENT; - return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); - } - - public boolean isLabelProperty(Object element, String property) - { - return true; - } - - public ILabelProviderListener[] getListeners() - { - synchronized (listeners) - { - return listeners.toArray(new ILabelProviderListener[listeners.size()]); - } - } - - public void addListener(ILabelProviderListener listener) - { - synchronized (listeners) - { - listeners.add(listener); - } - } - - public void removeListener(ILabelProviderListener listener) - { - synchronized (listeners) - { - listeners.remove(listener); - } - } - - protected void fillContextMenu(IMenuManager manager, ITreeSelection selection) - { - } - - protected void fireLabelProviderChanged() - { - fireLabelProviderChanged(new LabelProviderChangedEvent(this)); - } - - protected void fireLabelProviderChanged(Object element) - { - fireLabelProviderChanged(new LabelProviderChangedEvent(this, element)); - } - - protected void fireLabelProviderChanged(Object[] elements) - { - fireLabelProviderChanged(new LabelProviderChangedEvent(this, elements)); - } - - /** - * Fires a label provider changed event to all registered listeners Only - * listeners registered at the time this method is called are notified. - * - * @param event - * a label provider changed event - * @see ILabelProviderListener#labelProviderChanged - */ - private void fireLabelProviderChanged(LabelProviderChangedEvent event) - { - for (ILabelProviderListener listener : getListeners()) - { - try - { - listener.labelProviderChanged(event); - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ManagedContainerItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ManagedContainerItemProvider.java deleted file mode 100644 index 03e82f3451..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ManagedContainerItemProvider.java +++ /dev/null @@ -1,173 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.views; - -import org.eclipse.net4j.util.container.IManagedContainer; - -import java.util.List; - -/** - * @author Eike Stepper - */ -@Deprecated -public class ManagedContainerItemProvider extends ContainerItemProvider -{ - private boolean showProductGroups = true; - - private boolean showFactoryTypes = false; - - public ManagedContainerItemProvider() - { - } - - public boolean isShowProductGroups() - { - return showProductGroups; - } - - public void setShowProductGroups(boolean showProductGroups) - { - this.showProductGroups = showProductGroups; - } - - public boolean isShowFactoryTypes() - { - return showFactoryTypes; - } - - public void setShowFactoryTypes(boolean showFactoryTypes) - { - this.showFactoryTypes = showFactoryTypes; - } - - @Override - protected Node createNode(Node parent, Object element) - { - if (element instanceof IManagedContainer) - { - return new ManagedContainerNode(parent, (IManagedContainer)element); - } - - return super.createNode(parent, element); - } - - /** - * @author Eike Stepper - */ - public class ManagedContainerNode extends ContainerNode - { - public ManagedContainerNode(Node parent, IManagedContainer container) - { - super(parent, container); - } - } - - /** - * @author Eike Stepper - */ - public class ProductGroupNode extends AbstractNode - { - private String productGroup; - - public ProductGroupNode(ContainerNode parent, String productGroup) - { - super(parent); - this.productGroup = productGroup; - } - - public String getProductGroup() - { - return productGroup; - } - - public IManagedContainer getContainer() - { - ContainerNode parent = (ContainerNode)getParent(); - return (IManagedContainer)parent.getContainer(); - } - - public Object getElement() - { - return this; - } - - @Override - protected List createChildren() - { - return null; - } - } - - /** - * @author Eike Stepper - */ - public class FactoryTypeNode extends AbstractNode - { - private String factoryType; - - public FactoryTypeNode(ProductGroupNode parent, String factoryType) - { - super(parent); - this.factoryType = factoryType; - } - - public ProductGroupNode getProductGroupNode() - { - return (ProductGroupNode)getParent(); - } - - public String getFactoryType() - { - return factoryType; - } - - public IManagedContainer getContainer() - { - return getProductGroupNode().getContainer(); - } - - public Object getElement() - { - return this; - } - - @Override - protected List createChildren() - { - return null; - } - } - - /** - * @author Eike Stepper - */ - public class ProductGroupFactoryTypeNode extends ProductGroupNode - { - private String factoryType; - - public ProductGroupFactoryTypeNode(ContainerNode parent, String productGroup, String factoryType) - { - super(parent, productGroup); - this.factoryType = factoryType; - } - - public String getFactoryType() - { - return factoryType; - } - - @Override - protected List createChildren() - { - return null; - } - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/BaseDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/BaseDialog.java deleted file mode 100644 index 61bf5c54bf..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/BaseDialog.java +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.widgets; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; - -/** - * @author Eike Stepper - */ -public abstract class BaseDialog extends TitleAreaDialog -{ - public static final int DEFAULT_SHELL_STYLE = SWT.SHELL_TRIM; - - private String title; - - private String message; - - private IDialogSettings settings; - - private VIEWER currentViewer; - - private MenuManager contextMenu; - - public BaseDialog(Shell parentShell, int shellStyle, String title, String message, IDialogSettings settings) - { - super(parentShell); - setShellStyle(shellStyle); - this.title = title; - this.message = message; - this.settings = settings; - } - - public BaseDialog(Shell parentShell, String title, String message, IDialogSettings settings) - { - this(parentShell, DEFAULT_SHELL_STYLE, title, message, settings); - } - - @Override - protected void configureShell(Shell newShell) - { - super.configureShell(newShell); - newShell.setText(title); - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite composite = (Composite)super.createDialogArea(parent); - setTitle(title); - setMessage(message); - - contextMenu = new MenuManager("#PopupMenu"); - contextMenu.setRemoveAllWhenShown(true); - contextMenu.addMenuListener(new IMenuListener() - { - public void menuAboutToShow(IMenuManager manager) - { - VIEWER viewer = getCurrentViewer(); - if (viewer != null) - { - fillContextMenu(manager, viewer); - } - } - }); - - createUI(composite); - return composite; - } - - protected abstract void createUI(Composite parent); - - public VIEWER getCurrentViewer() - { - return currentViewer; - } - - public void setCurrentViewer(VIEWER currentViewer) - { - if (this.currentViewer != null) - { - Control control = this.currentViewer.getControl(); - control.setMenu(null); - } - - this.currentViewer = currentViewer; - if (this.currentViewer != null) - { - Control control = this.currentViewer.getControl(); - Menu menu = contextMenu.createContextMenu(control); - control.setMenu(menu); - } - } - - protected void hookContextMenu() - { - contextMenu = new MenuManager("#PopupMenu"); - contextMenu.setRemoveAllWhenShown(true); - contextMenu.addMenuListener(new IMenuListener() - { - public void menuAboutToShow(IMenuManager manager) - { - fillContextMenu(manager, getCurrentViewer()); - } - }); - } - - protected void fillContextMenu(IMenuManager manager, VIEWER viewer) - { - } - - @Override - protected IDialogSettings getDialogBoundsSettings() - { - if (settings == null) - { - return null; - } - - IDialogSettings section = settings.getSection(title); - if (section == null) - { - section = settings.addNewSection(title); - } - - return section; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java deleted file mode 100644 index bc30f73833..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java +++ /dev/null @@ -1,257 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.widgets; - -import org.eclipse.net4j.internal.ui.bundle.OM; -import org.eclipse.net4j.ui.UIUtil; -import org.eclipse.net4j.util.ReflectUtil; -import org.eclipse.net4j.util.StringUtil; -import org.eclipse.net4j.util.collection.IHistory; -import org.eclipse.net4j.util.collection.IHistoryChangeEvent; -import org.eclipse.net4j.util.collection.IHistoryElement; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; - -import java.lang.reflect.Method; - -/** - * @author Eike Stepper - */ -public class HistoryText extends Composite -{ - private IHistory history; - - private CCombo combo; - - private Method droppedMethod; - - private IListener historyListener = new IListener() - { - public void notifyEvent(IEvent event) - { - if (event instanceof IHistoryChangeEvent) - { - historyChanged(); - } - } - }; - - public HistoryText(Composite parent, int comboStyle, IHistory history) - { - super(parent, SWT.NONE); - setLayout(UIUtil.createGridLayout(1)); - - combo = createCombo(comboStyle); - combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - try - { - droppedMethod = combo.getClass().getDeclaredMethod("isDropped", ReflectUtil.NO_PARAMETERS); - droppedMethod.setAccessible(true); - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - - this.history = history; - historyChanged(); - history.addListener(historyListener); - } - - public IHistory getHistory() - { - return history; - } - - public CCombo getCombo() - { - return combo; - } - - @Override - public void dispose() - { - history.removeListener(historyListener); - super.dispose(); - } - - public void addModifyListener(ModifyListener listener) - { - combo.addModifyListener(listener); - } - - public void addSelectionListener(SelectionListener listener) - { - combo.addSelectionListener(listener); - } - - public void addVerifyListener(VerifyListener listener) - { - combo.addVerifyListener(listener); - } - - public void append(String string) - { - combo.setText(combo.getText() + string); - } - - public void clearSelection() - { - combo.clearSelection(); - } - - public void copy() - { - combo.copy(); - } - - public void cut() - { - combo.cut(); - } - - public int getCharCount() - { - return combo.getText().length(); - } - - public int getLineCount() - { - return StringUtil.occurrences(combo.getText(), getLineDelimiter()) + 1; - } - - public String getLineDelimiter() - { - return Text.DELIMITER; - } - - public int getLineHeight() - { - return combo.getTextHeight(); - } - - public String getText() - { - return combo.getText(); - } - - public int getTextLimit() - { - return combo.getTextLimit(); - } - - public void paste() - { - combo.paste(); - } - - public void removeModifyListener(ModifyListener listener) - { - combo.removeModifyListener(listener); - } - - public void removeSelectionListener(SelectionListener listener) - { - combo.removeSelectionListener(listener); - } - - public void removeVerifyListener(VerifyListener listener) - { - combo.removeVerifyListener(listener); - } - - public void setText(String string) - { - combo.setText(string); - } - - public void setTextLimit(int limit) - { - combo.setTextLimit(limit); - } - - @Override - public boolean setFocus() - { - return combo.setFocus(); - } - - public boolean isDropped() - { - if (droppedMethod != null) - { - try - { - return (Boolean)droppedMethod.invoke(combo, ReflectUtil.NO_ARGUMENTS); - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - } - - return false; - } - - protected void historyChanged() - { - if (isDisposed()) - { - return; - } - - combo.removeAll(); - for (IHistoryElement element : history) - { - combo.add(element.getData()); - } - - String mostRecent = history.getMostRecent(); - if (mostRecent != null) - { - setText(mostRecent); - } - } - - protected CCombo createCombo(int style) - { - final CCombo combo = new CCombo(this, style); - combo.addKeyListener(new KeyAdapter() - { - @Override - public void keyPressed(KeyEvent event) - { - if (event.character == SWT.DEL && event.stateMask == 0 && isDropped()) - { - int index = combo.getSelectionIndex(); - if (index != -1) - { - history.remove(index); - } - } - } - }); - - return combo; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryTextDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryTextDialog.java deleted file mode 100644 index 41ddf35544..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryTextDialog.java +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.widgets; - -import org.eclipse.net4j.util.collection.IHistory; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * TODO extend BaseDialog - * - * @author Eike Stepper - */ -public class HistoryTextDialog extends InputDialog -{ - private static final String EMPTY = ""; - - private IHistory history; - - private String value = EMPTY; - - private HistoryText historyText; - - public HistoryTextDialog(Shell parentShell, String dialogTitle, String dialogMessage, IHistory history, - IInputValidator validator) - { - super(parentShell, dialogTitle, dialogMessage, history.getMostRecent(), validator); - this.history = history; - value = super.getValue(); - } - - public IHistory getHistory() - { - return history; - } - - public HistoryText getHistoryText() - { - return historyText; - } - - @Override - public String getValue() - { - return value; - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite composite = (Composite)super.createDialogArea(parent); - Text text = getText(); - text.setVisible(false); - text.setEnabled(false); - - historyText = new HistoryText(composite, SWT.BORDER, history); - historyText.moveAbove(text); - historyText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); - historyText.addModifyListener(new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - validateInput(); - } - }); - - text.addFocusListener(new FocusAdapter() - { - @Override - public void focusGained(FocusEvent e) - { - historyText.setFocus(); - } - }); - - composite.getShell().layout(true); - return composite; - } - - @Override - protected void buttonPressed(int buttonId) - { - if (IDialogConstants.OK_ID == buttonId) - { - value = historyText.getText(); - okPressed(); - } - else if (IDialogConstants.CANCEL_ID == buttonId) - { - value = null; - cancelPressed(); - } - } - - @Override - protected void createButtonsForButtonBar(Composite parent) - { - super.createButtonsForButtonBar(parent); - historyText.setFocus(); - if (value != null) - { - historyText.setText(value); - } - } - - @Override - protected void validateInput() - { - String errorMessage = null; - if (getValidator() != null) - { - errorMessage = getValidator().isValid(historyText.getText()); - } - // Bug 16256: important not to treat "" (blank error) the same as null - // (no error) - setErrorMessage(errorMessage); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/LogDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/LogDialog.java deleted file mode 100644 index 8ef43bf665..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/LogDialog.java +++ /dev/null @@ -1,167 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.widgets; - -import org.eclipse.net4j.util.io.IORuntimeException; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.TextStyle; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class LogDialog extends BaseDialog -{ - private StringBuilder log = new StringBuilder(); - - private StyledText text; - - private TextStyle textStyle; - - private List styleRanges = new ArrayList(); - - private StyleRange currentStyleRange = new StyleRange(); - - private StyleRange lastStyleRange; - - private Font font; - - public LogDialog(Shell parentShell, int shellStyle, String title, String message, IDialogSettings settings) - { - super(parentShell, shellStyle, title, message, settings); - } - - public LogDialog(Shell parentShell, String title, String message, IDialogSettings settings) - { - this(parentShell, DEFAULT_SHELL_STYLE, title, message, settings); - } - - public TextStyle getTextStyle() - { - return textStyle; - } - - public void setTextStyle(TextStyle textStyle) - { - if (textStyle == null) - { - throw new IllegalArgumentException("textStyle == null"); - } - - if (textStyle.equals(this.textStyle)) - { - return; - } - - lastStyleRange = currentStyleRange; - this.textStyle = textStyle; - - currentStyleRange = new StyleRange(); - currentStyleRange.start = log.length(); - currentStyleRange.rise = textStyle.rise; - currentStyleRange.background = textStyle.background; - currentStyleRange.font = textStyle.font; - currentStyleRange.foreground = textStyle.foreground; - currentStyleRange.metrics = textStyle.metrics; - currentStyleRange.strikeout = textStyle.strikeout; - currentStyleRange.underline = textStyle.underline; - } - - public void append(String text) - { - checkStyleRange(); - log.append(text); - currentStyleRange.length += text.length(); - } - - public void append(Throwable t) - { - try - { - checkStyleRange(); - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - String message = t.getMessage() + "\n"; - bytes.write(message.getBytes()); - t.printStackTrace(new PrintStream(bytes)); - - String text = bytes.toString(); - log.append(text); - currentStyleRange.length += text.length(); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - @Override - public boolean close() - { - font.dispose(); - return super.close(); - } - - @Override - protected void createUI(Composite parent) - { - GridLayout grid = new GridLayout(); - grid.marginTop = 6; - grid.marginLeft = 6; - grid.marginRight = 6; - grid.marginBottom = 6; - - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(grid); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - font = new Font(getShell().getDisplay(), "Courier New", 9, SWT.NORMAL); - checkStyleRange(); - lastStyleRange = currentStyleRange; - checkStyleRange(); - - text = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - text.setText(log.toString()); - text.setStyleRanges(styleRanges.toArray(new StyleRange[styleRanges.size()])); - text.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); - text.setFont(font); - } - - @Override - protected void createButtonsForButtonBar(Composite parent) - { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true); - } - - private void checkStyleRange() - { - if (lastStyleRange != null) - { - styleRanges.add(lastStyleRange); - lastStyleRange = null; - } - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorDialog.java deleted file mode 100644 index 96731b1b53..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorDialog.java +++ /dev/null @@ -1,126 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.widgets; - -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.om.monitor.MonitorUtil; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; - -import java.lang.reflect.InvocationTargetException; - -/** - * @author Eike Stepper - */ -public class MonitorDialog extends ProgressMonitorDialog -{ - public static final int DEFAULT_SHELL_STYLE = SWT.SHELL_TRIM; - - private String title; - - private IDialogSettings settings; - - private MonitorLogDialog log; - - public MonitorDialog(Shell parentShell, int shellStyle, String title, IDialogSettings settings) - { - super(parentShell); - setShellStyle(shellStyle); - this.title = title; - this.settings = settings; - } - - public MonitorDialog(Shell parentShell, String title, IDialogSettings settings) - { - this(parentShell, DEFAULT_SHELL_STYLE, title, settings); - } - - public void run(boolean fork, boolean cancelable, final Runnable runnable) - { - try - { - log = new MonitorLogDialog(getShell(), getShellStyle(), "Log of " + title, "See the log for details.", settings); - log.setEmphasizePrefix("Woven class ", "Mixed in ", "Reversioned "); - - super.run(fork, cancelable, new IRunnableWithProgress() - { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException - { - MonitorUtil.Eclipse.startMonitoring(monitor, log); - try - { - runnable.run(); - } - catch (RuntimeException ex) - { - log.append(ex); - throw ex; - } - finally - { - MonitorUtil.Eclipse.stopMonitoring(); - } - } - }); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - @Override - protected void finishedRun() - { - super.finishedRun(); - if (log != null) - { - log.open(); - } - } - - @Override - @Deprecated - public final void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) - throws InvocationTargetException, InterruptedException - { - throw new UnsupportedOperationException(); - } - - @Override - protected void configureShell(Shell newShell) - { - super.configureShell(newShell); - newShell.setText(title); - } - - @Override - protected IDialogSettings getDialogBoundsSettings() - { - if (settings == null) - { - return null; - } - - IDialogSettings section = settings.getSection(title); - if (section == null) - { - section = settings.addNewSection(title); - } - - return section; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorLogDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorLogDialog.java deleted file mode 100644 index fc1abd9acd..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/MonitorLogDialog.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.eclipse.net4j.ui.widgets; - -import org.eclipse.net4j.util.om.monitor.OMMonitorHandler; - -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.TextStyle; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * @author Eike Stepper - */ -public class MonitorLogDialog extends LogDialog implements OMMonitorHandler -{ - private String[] emphasizePrefix; - - private TextStyle taskStyle; - - private TextStyle normalStyle; - - private TextStyle emphasizedStyle; - - private TextStyle problemStyle; - - public MonitorLogDialog(Shell parentShell, int shellStyle, String title, String message, IDialogSettings settings) - { - super(parentShell, shellStyle, title, message, settings); - Display display = Display.getCurrent(); - taskStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_BLACK), null); - normalStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_DARK_GRAY), null); - emphasizedStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_BLUE), null); - problemStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_RED), null); - } - - public MonitorLogDialog(Shell parentShell, String title, String message, IDialogSettings settings) - { - this(parentShell, DEFAULT_SHELL_STYLE, title, message, settings); - } - - public String[] getEmphasizePrefix() - { - return emphasizePrefix; - } - - public void setEmphasizePrefix(String... emphasizePrefix) - { - this.emphasizePrefix = emphasizePrefix; - } - - public TextStyle getNormalStyle() - { - return normalStyle; - } - - public TextStyle getTaskStyle() - { - return taskStyle; - } - - public TextStyle getProblemStyle() - { - return problemStyle; - } - - public TextStyle getEmphasizedStyle() - { - return emphasizedStyle; - } - - public void handleTask(String task, int level) - { - setTextStyle(taskStyle); - append(task); - append("\n"); - } - - public void handleMessage(String msg, int level) - { - boolean emphasized = false; - if (emphasizePrefix != null) - { - for (String prefix : emphasizePrefix) - { - if (msg.startsWith(prefix)) - { - setTextStyle(emphasizedStyle); - emphasized = true; - break; - } - } - } - - if (!emphasized) - { - setTextStyle(normalStyle); - } - - append(msg); - append("\n"); - } - - @Override - public void append(Throwable t) - { - setTextStyle(problemStyle); - super.append(t); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/PreferenceButton.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/PreferenceButton.java deleted file mode 100644 index 2885c034df..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/PreferenceButton.java +++ /dev/null @@ -1,117 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.widgets; - -import org.eclipse.net4j.ui.UIUtil; -import org.eclipse.net4j.util.om.pref.OMPreference; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -/** - * @author Eike Stepper - */ -public class PreferenceButton extends Composite -{ - private OMPreference preference; - - private Button button; - - public PreferenceButton(Composite parent, int buttonStyle, final OMPreference preference) - { - super(parent, SWT.NONE); - setLayout(UIUtil.createGridLayout(1)); - this.preference = preference; - - button = createButton(buttonStyle); - button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - button.setSelection(preference.getValue()); - button.addSelectionListener(new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - preference.setValue(button.getSelection()); - } - }); - } - - public OMPreference getPreference() - { - return preference; - } - - public Button getButton() - { - return button; - } - - protected Button createButton(int buttonStyle) - { - return new Button(this, buttonStyle); - } - - public void addSelectionListener(SelectionListener listener) - { - button.addSelectionListener(listener); - } - - public int getAlignment() - { - return button.getAlignment(); - } - - public Image getImage() - { - return button.getImage(); - } - - public boolean getSelection() - { - return button.getSelection(); - } - - public String getText() - { - return button.getText(); - } - - public void removeSelectionListener(SelectionListener listener) - { - button.removeSelectionListener(listener); - } - - public void setAlignment(int alignment) - { - button.setAlignment(alignment); - } - - public void setImage(Image image) - { - button.setImage(image); - } - - public void setSelection(boolean selected) - { - button.setSelection(selected); - } - - public void setText(String string) - { - button.setText(string); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/CompoundStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/CompoundStep.java deleted file mode 100644 index efc99c9c47..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/CompoundStep.java +++ /dev/null @@ -1,345 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -/** - * @author Eike Stepper - */ -public abstract class CompoundStep extends Step implements List -{ - private List children = new ArrayList(0); - - public CompoundStep() - { - } - - public void add(int index, Step child) - { - child.setParent(this); - children.add(index, child); - } - - public boolean add(Step child) - { - child.setParent(this); - return children.add(child); - } - - public boolean addAll(Collection c) - { - for (Step step : c) - { - step.setParent(this); - } - - return children.addAll(c); - } - - public boolean addAll(int index, Collection c) - { - for (Step step : c) - { - step.setParent(this); - } - - return children.addAll(index, c); - } - - public void clear() - { - for (Step step : this) - { - step.setParent(null); - } - - children.clear(); - } - - public boolean contains(Object o) - { - return children.contains(o); - } - - public boolean containsAll(Collection c) - { - return children.containsAll(c); - } - - public boolean equals(Object o) - { - return children.equals(o); - } - - public Step get(int index) - { - return children.get(index); - } - - public Step getFirst() - { - return children.isEmpty() ? null : children.get(0); - } - - public Step getLast() - { - return children.isEmpty() ? null : children.get(children.size() - 1); - } - - public int hashCode() - { - return children.hashCode(); - } - - public int indexOf(Object o) - { - return children.indexOf(o); - } - - public boolean isEmpty() - { - return children.isEmpty(); - } - - public Iterator iterator() - { - return new Itr(children.iterator()); - } - - public int lastIndexOf(Object o) - { - return children.lastIndexOf(o); - } - - public ListIterator listIterator() - { - return new ListItr(children.listIterator()); - } - - public ListIterator listIterator(int index) - { - return new ListItr(children.listIterator(index)); - } - - public Step remove(int index) - { - return children.remove(index); - } - - public boolean remove(Object o) - { - boolean removed = children.remove(o); - if (removed) - { - ((Step)o).setParent(null); - } - - return removed; - } - - public boolean removeAll(Collection c) - { - for (Object o : c) - { - if (c instanceof Step) - { - ((Step)o).setParent(null); - } - } - - return children.removeAll(c); - } - - public boolean retainAll(Collection c) - { - for (Step step : this) - { - if (!c.contains(step)) - { - step.setParent(null); - } - } - - return children.retainAll(c); - } - - public Step set(int index, Step element) - { - Step old = children.set(index, element); - if (old != null) - { - old.setParent(null); - } - - return old; - } - - public int size() - { - return children.size(); - } - - public List subList(int fromIndex, int toIndex) - { - return children.subList(fromIndex, toIndex); - } - - public T[] toArray(T[] a) - { - return children.toArray(a); - } - - public Object[] toArray() - { - return children.toArray(); - } - - @Override - public void accept(IStepVisitor visitor) - { - super.accept(visitor); - for (Step step : this) - { - step.accept(visitor); - } - } - - @Override - public boolean isFinished() - { - return false; - } - - @Override - public boolean isReady() - { - return false; - } - - @Override - void setWizard(SteppingWizard wizard) - { - if (isEmpty()) - { - throw new IllegalStateException("isEmpty()"); - } - - super.setWizard(wizard); - for (Step child : children) - { - child.setWizard(wizard); - } - } - - /** - * @author Eike Stepper - */ - private static final class Itr implements Iterator - { - private Iterator delegate; - - private Step last; - - private Itr(Iterator delegate) - { - this.delegate = delegate; - } - - public boolean hasNext() - { - return delegate.hasNext(); - } - - public Step next() - { - return last = delegate.next(); - } - - public void remove() - { - delegate.remove(); - last.setParent(null); - } - } - - /** - * @author Eike Stepper - */ - private final class ListItr implements ListIterator - { - private final ListIterator delegate; - - private Step last; - - private ListItr(ListIterator delegate) - { - this.delegate = delegate; - } - - public boolean hasNext() - { - return delegate.hasNext(); - } - - public Step next() - { - return last = delegate.next(); - } - - public void remove() - { - delegate.remove(); - last.setParent(null); - } - - public void add(Step child) - { - child.setParent(CompoundStep.this); - delegate.add(child); - } - - public boolean hasPrevious() - { - return delegate.hasPrevious(); - } - - public int nextIndex() - { - return delegate.nextIndex(); - } - - public Step previous() - { - return last = delegate.previous(); - } - - public int previousIndex() - { - return delegate.previousIndex(); - } - - public void set(Step child) - { - if (last != null) - { - last.setParent(null); - } - - last = child; - last.setParent(CompoundStep.this); - } - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/DecisionStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/DecisionStep.java deleted file mode 100644 index 6abba16496..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/DecisionStep.java +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class DecisionStep extends CompoundStep implements IDecisionProvider -{ - private int decisionIndex; - - private Map labels = new HashMap(); - - public DecisionStep() - { - } - - public int getDecisionIndex() - { - return decisionIndex; - } - - public Step getDecision() - { - return 0 <= decisionIndex && decisionIndex < size() ? get(decisionIndex) : null; - } - - @Override - public boolean isReady() - { - Step step = getDecision(); - return step == null ? false : step.isReady(); - } - - @Override - public boolean isFinished() - { - Step step = getDecision(); - return step == null ? false : step.isFinished(); - } - - public Step addDecision(String label, Step step) - { - add(step); - labels.put(step, label); - return step; - } - - void setDecisionIndex(int decisionIndex) - { - this.decisionIndex = decisionIndex; - } - - @Override - void setWizard(SteppingWizard wizard) - { - if (size() < 2) - { - throw new IllegalStateException("size() < 2"); - } - - super.setWizard(wizard); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/IDecisionProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/IDecisionProvider.java deleted file mode 100644 index ca8d62784a..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/IDecisionProvider.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -/** - * @author Eike Stepper - */ -public interface IDecisionProvider -{ - public Step addDecision(String label, Step step); -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/IStepVisitor.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/IStepVisitor.java deleted file mode 100644 index 2b27490496..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/IStepVisitor.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -/** - * @author Eike Stepper - */ -public interface IStepVisitor -{ - public void visit(Step step); -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/PagingStrategy.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/PagingStrategy.java deleted file mode 100644 index 47ca22acb9..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/PagingStrategy.java +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class PagingStrategy implements IStepVisitor -{ - private List pages = new ArrayList(0); - - private SteppingWizardPage currentPage; - - public PagingStrategy() - { - } - - public final List getPages() - { - return pages; - } - - public final void visit(Step step) - { - if (currentPage == null || !currentPage.isEmpty() && isNewPage(step)) - { - currentPage = createNewPage(); - pages.add(currentPage); - } - - currentPage.addWizardStep(step); - step.setWizardPage(currentPage); - } - - protected boolean isNewPage(Step step) - { - CompoundStep parent = step.getParent(); - if (parent instanceof SequentialStep) - { - return true; - } - - return false; - } - - protected SteppingWizardPage createNewPage() - { - return new SteppingWizardPage(pages.size()); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/ParallelStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/ParallelStep.java deleted file mode 100644 index acae351e1a..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/ParallelStep.java +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -/** - * @author Eike Stepper - */ -public class ParallelStep extends CompoundStep -{ - public ParallelStep() - { - } - - @Override - public boolean isReady() - { - for (Step child : this) - { - if (child.isReady()) - { - return true; - } - } - - return false; - } - - @Override - public boolean isFinished() - { - for (Step child : this) - { - if (!child.isFinished()) - { - return false; - } - } - - return true; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SelectionStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SelectionStep.java deleted file mode 100644 index 7cc6ee3dfb..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SelectionStep.java +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.net4j.ui.DelegatingContentProvider; - -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.CheckboxTreeViewer; -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -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.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class SelectionStep extends ValueStep> -{ - private Class elementClass; - - private Object input; - - private IStructuredContentProvider contentProvider; - - private ILabelProvider labelProvider; - - private int min; - - private int max; - - public SelectionStep(String label, String key, Class elementClass, Object input, - IStructuredContentProvider contentProvider, ILabelProvider labelProvider, int min, int max) - { - super(label, key, List.class); - this.elementClass = elementClass; - this.input = input; - this.contentProvider = contentProvider; - this.labelProvider = labelProvider == null ? new LabelProvider() : labelProvider; - this.min = min; - this.max = max; - - if (min < 0) - { - throw new IllegalArgumentException("min < 0"); - } - - if (max < min) - { - throw new IllegalArgumentException("max < min"); - } - } - - public SelectionStep(String key, Class elementClass, Object input, IStructuredContentProvider contentProvider, - ILabelProvider labelProvider, int min, int max) - { - this(key, key, elementClass, input, contentProvider, labelProvider, min, max); - } - - public final IStructuredContentProvider getContentProvider() - { - return contentProvider; - } - - public final ILabelProvider getLabelProvider() - { - return labelProvider; - } - - public final int getMin() - { - return min; - } - - public final int getMax() - { - return max; - } - - public final Set getContents() - { - Set result = new HashSet(); - if (contentProvider instanceof ITreeContentProvider) - { - addElements(((ITreeContentProvider)contentProvider).getChildren(input), result); - } - else - { - addElements(contentProvider.getElements(input), result); - } - - return result; - } - - @Override - protected String validateValue(List values) - { - int size = values == null ? 0 : values.size(); - if (size < min) - { - int delta = min - size; - String count = delta == 1 ? " one" : " " + delta; - String more = size > 0 ? " more" : " "; - return "Select" + count + more + getLabel() + " element" + (delta == 1 ? "" : "s"); - } - - if (size > max) - { - int delta = size - max; - String count = delta == 1 ? " one" : " " + delta; - return "Unselect" + count + " " + getLabel() + " element" + (delta == 1 ? "" : "s"); - } - - // Set contents = getContents(); - // for (E element : values) - // { - // if (!contents.contains(element)) - // { - // return false; - // } - // } - - return null; - } - - public boolean isOptional() - { - return min == 0; - } - - public boolean isMulti() - { - return max > 1; - } - - @Override - protected Control createControl(Composite parent) - { - StructuredViewer viewer; - boolean grabVertical = true; - if (contentProvider instanceof ITreeContentProvider) - { - if (isMulti()) - { - viewer = createMultiSelectionTree(parent); - } - else - { - viewer = new TreeViewer(parent, SWT.NONE); - prepareViewer(viewer); - } - } - else - { - if (isMulti()) - { - viewer = CheckboxTableViewer.newCheckList(parent, SWT.NONE); - prepareViewer(viewer); - } - else - { - viewer = createSingleSelectionList(parent); - grabVertical = false; - } - } - - Control control = viewer.getControl(); - control.setLayoutData(createLayoutData(control, grabVertical)); - return viewer.getControl(); - } - - protected ComboViewer createSingleSelectionList(Composite parent) - { - ComboViewer viewer = new ComboViewer(parent, SWT.NONE); - prepareViewer(viewer); - viewer.getCombo().addModifyListener(new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - setValue(null); - } - }); - - // ComboAutoCompleter.attach(viewer, new ComboAutoCompleter(viewer) - // { - // @Override - // protected void setSelection(StructuredSelection selection) - // { - // super.setSelection(selection); - // setSingleSelection(selection); - // } - // }); - - viewer.addPostSelectionChangedListener(new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - setSingleSelection((IStructuredSelection)event.getSelection()); - } - }); - - return viewer; - } - - protected CheckboxTreeViewer createMultiSelectionTree(Composite parent) - { - CheckboxTreeViewer viewer = new CheckboxTreeViewer(parent, SWT.NONE); - prepareViewer(viewer); - viewer.addCheckStateListener(new ICheckStateListener() - { - public void checkStateChanged(CheckStateChangedEvent event) - { - } - }); - - return viewer; - } - - protected void prepareViewer(StructuredViewer viewer) - { - // Following order is important! - viewer.setContentProvider(isOptional() ? new DelegatingContentProvider(contentProvider, true) : contentProvider); - viewer.setInput(input); - // viewer.setSorter(new ViewerSorter()); - viewer.setLabelProvider(labelProvider); - - List value = getValue(); - if (value != null && !value.isEmpty()) - { - viewer.setSelection(new StructuredSelection(value)); - } - } - - protected GridData createLayoutData(Control control, boolean grabVertical) - { - GridData gd = new GridData(SWT.FILL, grabVertical ? SWT.FILL : SWT.TOP, true, grabVertical); - if (!grabVertical) - { - gd.horizontalAlignment = SWT.LEFT; - gd.grabExcessHorizontalSpace = false; - } - - return gd; - } - - private void addElements(Object[] elements, Set result) - { - for (Object element : elements) - { - addElement(element, result); - if (contentProvider instanceof ITreeContentProvider) - { - addElements(((ITreeContentProvider)contentProvider).getChildren(element), result); - } - } - } - - private void addElement(Object element, Set result) - { - if (elementClass.isInstance(element)) - { - result.add((E)element); - } - } - - private void setSingleSelection(IStructuredSelection selection) - { - Object element = selection.getFirstElement(); - if (element instanceof String && ((String)element).length() == 0) - { - setValue(null); - } - else if (elementClass.isInstance(element)) - { - setValue((List)Collections.singletonList(element)); - } - else - { - setValue(null); - } - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SequentialStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SequentialStep.java deleted file mode 100644 index 44f60d6f70..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SequentialStep.java +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -/** - * @author Eike Stepper - */ -public class SequentialStep extends CompoundStep -{ - public SequentialStep() - { - } - - @Override - public boolean isReady() - { - return isEmpty() || getFirst().isReady(); - } - - @Override - public boolean isFinished() - { - return isEmpty() || getLast().isFinished(); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/StaticSelectionStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/StaticSelectionStep.java deleted file mode 100644 index 4a08407f53..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/StaticSelectionStep.java +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.net4j.ui.StaticContentProvider; - -import org.eclipse.jface.viewers.ILabelProvider; - -import java.util.Collection; - -/** - * @author Eike Stepper - */ -public class StaticSelectionStep extends SelectionStep -{ - private static final Object INPUT = new Object(); - - /* - * Input: Object[] elements - */ - - public StaticSelectionStep(String label, String key, Object[] elements, ILabelProvider labelProvider, int min, int max) - { - super(label, key, Object.class, INPUT, new StaticContentProvider(elements), labelProvider, min, max); - } - - public StaticSelectionStep(String key, Object[] elements, ILabelProvider labelProvider, int min, int max) - { - this(key, key, elements, labelProvider, min, max); - } - - public StaticSelectionStep(String key, Object[] elements, int min, int max) - { - this(key, key, elements, null, min, max); - } - - /* - * Input: Collection elements - */ - - public StaticSelectionStep(String label, String key, Collection elements, ILabelProvider labelProvider, int min, - int max) - { - super(label, key, Object.class, INPUT, new StaticContentProvider(elements), labelProvider, min, max); - } - - public StaticSelectionStep(String key, Collection elements, ILabelProvider labelProvider, int min, int max) - { - this(key, key, elements, labelProvider, min, max); - } - - public StaticSelectionStep(String key, Collection elements, int min, int max) - { - this(key, key, elements, null, min, max); - } - - /* - * Input: Class enumClass - */ - - public StaticSelectionStep(String label, String key, Class enumClass, ILabelProvider labelProvider, int min, int max) - { - super(label, key, Object.class, INPUT, new StaticContentProvider(enumClass), labelProvider, min, max); - } - - public StaticSelectionStep(String key, Class enumClass, ILabelProvider labelProvider, int min, int max) - { - this(key, key, enumClass, labelProvider, min, max); - } - - public StaticSelectionStep(String key, Class enumClass, int min, int max) - { - this(key, key, enumClass, null, min, max); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/Step.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/Step.java deleted file mode 100644 index 5497cc0385..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/Step.java +++ /dev/null @@ -1,152 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public abstract class Step -{ - private String label; - - private CompoundStep parent; - - private SteppingWizard wizard; - - private SteppingWizardPage wizardPage; - - public Step() - { - } - - public Step(String label) - { - this.label = label; - } - - public String getLabel() - { - return label; - } - - public final CompoundStep getParent() - { - return parent; - } - - public final SteppingWizard getWizard() - { - return wizard; - } - - public SteppingWizardPage getWizardPage() - { - return wizardPage; - } - - public final Map getContext() - { - return wizard.getContext(); - } - - public final Object getContextValue(String key) - { - return wizard.getContextValue(key); - } - - public final boolean hasContextValue(String key) - { - return wizard.hasContextValue(key); - } - - public final Object setContextValue(String key, Object value) - { - return wizard.setContextValue(key, value); - } - - public boolean isFirst() - { - if (parent == null) - { - return true; - } - - return parent.indexOf(this) == 0; - } - - public boolean isLast() - { - if (parent == null) - { - return true; - } - - return parent.indexOf(this) == parent.size() - 1; - } - - public Step getPrevious() - { - if (parent == null) - { - return null; - } - - int index = parent.indexOf(this); - if (index == 0) - { - return parent.getPrevious(); - } - - return parent.get(index - 1); - } - - public Step getNext() - { - if (parent == null) - { - return null; - } - - int index = parent.indexOf(this); - if (index == parent.size() - 1) - { - return parent.getNext(); - } - - return parent.get(index + 1); - } - - public void accept(IStepVisitor visitor) - { - visitor.visit(this); - } - - public abstract boolean isReady(); - - public abstract boolean isFinished(); - - final void setParent(CompoundStep parent) - { - this.parent = parent; - } - - void setWizard(SteppingWizard wizard) - { - this.wizard = wizard; - } - - final void setWizardPage(SteppingWizardPage wizardPage) - { - this.wizardPage = wizardPage; - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingExportWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingExportWizard.java deleted file mode 100644 index 1cb7c172c4..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingExportWizard.java +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.ui.IExportWizard; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public abstract class SteppingExportWizard extends SteppingWorkbenchWizard implements IExportWizard -{ - public SteppingExportWizard(Map context) - { - super(context); - } - - public SteppingExportWizard() - { - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingImportWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingImportWizard.java deleted file mode 100644 index a1a9eced25..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingImportWizard.java +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.ui.IImportWizard; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public abstract class SteppingImportWizard extends SteppingWorkbenchWizard implements IImportWizard -{ - public SteppingImportWizard(Map context) - { - super(context); - } - - public SteppingImportWizard() - { - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingNewWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingNewWizard.java deleted file mode 100644 index fb894931bb..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingNewWizard.java +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.ui.INewWizard; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public abstract class SteppingNewWizard extends SteppingWorkbenchWizard implements INewWizard -{ - public SteppingNewWizard(Map context) - { - super(context); - } - - public SteppingNewWizard() - { - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWizard.java deleted file mode 100644 index bdea960303..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWizard.java +++ /dev/null @@ -1,205 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.net4j.internal.ui.bundle.OM; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public abstract class SteppingWizard extends Wizard -{ - private Map context; - - private Step rootStep; - - private Step currentStep; - - public SteppingWizard(Map context) - { - this.context = context; - } - - public SteppingWizard() - { - this(new HashMap()); - } - - @Override - public void dispose() - { - super.dispose(); - } - - public final Map getContext() - { - return context; - } - - public final boolean hasContextValue(String key) - { - return getContext().containsKey(key); - } - - public final Object getSingleContextValue(String key) - { - Object value = getContextValue(key); - if (value instanceof Collection) - { - Collection collection = (Collection)value; - if (collection.isEmpty()) - { - return null; - } - else - { - return collection.iterator().next(); - } - } - - return value; - } - - public final Object getContextValue(String key) - { - return getContext().get(key); - } - - public final Object setSingleContextValue(String key, Object value) - { - return setContextValue(key, Collections.singletonList(value)); - } - - public final Object setContextValue(String key, Object value) - { - Object old = getContext().put(key, value); - if (rootStep != null) - { - for (IWizardPage page : getPages()) - { - if (page instanceof SteppingWizardPage) - { - ((SteppingWizardPage)page).validate(); - } - } - } - - return old; - } - - public Step getRootStep() - { - return rootStep; - } - - public Step getCurrentStep() - { - return currentStep; - } - - public Step getPreviousStep() - { - return currentStep.getPrevious(); - } - - public Step getNextStep() - { - return currentStep.getNext(); - } - - public PagingStrategy getPagingStrategy() - { - return new PagingStrategy(); - } - - @Override - public final void addPages() - { - rootStep = createRootStep(); - rootStep.setWizard(this); - - PagingStrategy pagingStrategy = getPagingStrategy(); - rootStep.accept(pagingStrategy); - List pages = pagingStrategy.getPages(); - for (SteppingWizardPage wizardPage : pages) - { - addPage(wizardPage); - } - } - - @Override - public final boolean performFinish() - { - try - { - if (isLongRunningFinish()) - { - new Job("") - { - @Override - protected IStatus run(IProgressMonitor monitor) - { - try - { - doFinish(monitor); - } - catch (Exception ex) - { - handleFinishException(ex); - } - - return Status.OK_STATUS; - } - - }.schedule(); - return true; - } - - doFinish(new NullProgressMonitor()); - return true; - } - catch (Exception ex) - { - handleFinishException(ex); - return false; - } - } - - protected boolean isLongRunningFinish() - { - return false; - } - - protected abstract void doFinish(IProgressMonitor monitor) throws Exception; - - protected abstract Step createRootStep(); - - private void handleFinishException(Exception ex) - { - OM.LOG.error(ex); - MessageDialog.openError(getShell(), getWindowTitle(), ex.getMessage()); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWizardPage.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWizardPage.java deleted file mode 100644 index 3253c6f5c8..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWizardPage.java +++ /dev/null @@ -1,133 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class SteppingWizardPage extends WizardPage -{ - private int index; - - private List steps = new ArrayList(0); - - public SteppingWizardPage(int index) - { - super("page" + index); - this.index = index; - } - - public SteppingWizardPage(int index, String title, ImageDescriptor titleImage) - { - super("page" + index, title, titleImage); - } - - public final int getIndex() - { - return index; - } - - public List getWizardSteps() - { - return Collections.unmodifiableList(steps); - } - - public boolean isEmpty() - { - for (Step step : steps) - { - if (step instanceof ValueStep) - { - return false; - } - } - - return true; - } - - public void createControl(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(2, false)); - - for (Step step : steps) - { - if (step instanceof ValueStep) - { - ValueStep valueStep = (ValueStep)step; - if (valueStep.getControl() != null) - { - addValueControl(composite, valueStep); - } - } - else if (step instanceof DecisionStep) - { - DecisionStep decisionStep = (DecisionStep)step; - Group group = new Group(composite, SWT.BORDER); - group.setText(decisionStep.getLabel()); - // for (Step decision : decisionStep) - // { - // - // } - // - // decisionStep.createControl(composite); - } - } - - validate(); - setControl(composite); - } - - protected void addValueControl(Composite composite, ValueStep valueStep) - { - new Label(composite, SWT.NONE).setText(valueStep.getLabel() + ":"); - Control control = valueStep.createControl(composite); - valueStep.setControl(control); - } - - protected void validate() - { - String errorMessage = null; - for (Step step : steps) - { - if (step instanceof ValueStep) - { - errorMessage = ((ValueStep)step).validate(); - if (errorMessage != null) - { - break; - } - } - } - - setErrorMessage(errorMessage); - setPageComplete(errorMessage == null); - } - - void addWizardStep(Step step) - { - steps.add(step); - step.setWizardPage(this); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWorkbenchWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWorkbenchWizard.java deleted file mode 100644 index 0ff37d9e83..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/SteppingWorkbenchWizard.java +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWizard; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public abstract class SteppingWorkbenchWizard extends SteppingWizard implements IWorkbenchWizard -{ - public static final String KEY_WORKBENCH = "WORKBENCH"; - - public static final String KEY_WORKBENCH_SELECTION = "WORKBENCH_SELECTION"; - - public SteppingWorkbenchWizard(Map context) - { - super(context); - } - - public SteppingWorkbenchWizard() - { - } - - public void init(IWorkbench workbench, IStructuredSelection selection) - { - setContextValue(KEY_WORKBENCH, workbench); - setContextValue(KEY_WORKBENCH_SELECTION, selection); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/StringStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/StringStep.java deleted file mode 100644 index 0db30a6e37..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/StringStep.java +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; - -/** - * @author Eike Stepper - */ -public class StringStep extends ValueStep -{ - public StringStep(String label, String key) - { - super(label, key, String.class); - } - - public StringStep(String key) - { - this(key, key); - } - - @Override - protected String validateValue(String value) - { - if (value == null || value.length() == 0) - { - return super.validateValue(null); - } - - return null; - } - - @Override - protected Control createControl(Composite parent) - { - final Text control = new Text(parent, SWT.BORDER); - String value = getValue(); - if (value != null) - { - control.setText(value); - } - - control.setLayoutData(createLayoutData()); - control.addModifyListener(new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - setValue(control.getText()); - } - }); - - return control; - } - - protected GridData createLayoutData() - { - return new GridData(SWT.FILL, SWT.TOP, true, false); - } -} diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/ValueStep.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/ValueStep.java deleted file mode 100644 index dc58ac24dc..0000000000 --- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/wizards/ValueStep.java +++ /dev/null @@ -1,109 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004-2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.ui.wizards; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * @author Eike Stepper - */ -public abstract class ValueStep extends Step -{ - private String key; - - private Class valueClass; - - private Control control; - - public ValueStep(String label, String key, Class valueClass) - { - super(label); - this.key = key; - this.valueClass = valueClass; - } - - public ValueStep(String key, Class valueClass) - { - this(key, key, valueClass); - } - - public final String getKey() - { - return key; - } - - public final Class getValueClass() - { - return valueClass; - } - - public final V getValue() - { - Object value = getContextValue(key); - if (value != null && !valueClass.isAssignableFrom(value.getClass())) - { - throw new IllegalStateException("Wrong value class: " + value.getClass().getName()); - } - - return (V)value; - } - - public final Object setValue(V value) - { - return setContextValue(key, value); - } - - public final boolean hasValue() - { - return getValue() != null; - } - - @Override - public boolean isReady() - { - return true; - } - - @Override - public boolean isFinished() - { - V value = getValue(); - return value != null && validateValue(value) == null; - } - - protected String validateValue(V value) - { - if (value == null) - { - return "Enter a " + getLabel() + " value"; - } - - return null; - } - - protected abstract Control createControl(Composite parent); - - final String validate() - { - return validateValue(getValue()); - } - - final Control getControl() - { - return control; - } - - final void setControl(Control control) - { - this.control = control; - } -} diff --git a/plugins/org.eclipse.net4j.util.ui/.classpath b/plugins/org.eclipse.net4j.util.ui/.classpath new file mode 100644 index 0000000000..ad67cfd051 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/org.eclipse.net4j.util.ui/.cvsignore b/plugins/org.eclipse.net4j.util.ui/.cvsignore new file mode 100644 index 0000000000..693869726d --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/.cvsignore @@ -0,0 +1,2 @@ +bin +doc diff --git a/plugins/org.eclipse.net4j.util.ui/.options b/plugins/org.eclipse.net4j.util.ui/.options new file mode 100644 index 0000000000..9720d4390e --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/.options @@ -0,0 +1 @@ +org.eclipse.net4j.util.ui/debug = true diff --git a/plugins/org.eclipse.net4j.util.ui/.project b/plugins/org.eclipse.net4j.util.ui/.project new file mode 100644 index 0000000000..a10d2cbd97 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/.project @@ -0,0 +1,28 @@ + + + org.eclipse.net4j.util.ui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..6f94d084b1 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.net4j.util.ui;singleton:=true +Bundle-Version: 0.8.0.qualifier +Bundle-Activator: org.eclipse.net4j.util.internal.ui.bundle.OM$Activator +Bundle-Vendor: %providerName +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ui;visibility:=reexport, + org.eclipse.net4j.util;visibility:=reexport +Eclipse-LazyStart: true +Export-Package: org.eclipse.net4j.util.internal.ui;version="0.8.0", + org.eclipse.net4j.util.ui;version="0.8.0", + org.eclipse.net4j.util.ui.actions;version="0.8.0", + org.eclipse.net4j.util.ui.views;version="0.8.0", + org.eclipse.net4j.util.ui.widgets;version="0.8.0" diff --git a/plugins/org.eclipse.net4j.util.ui/about.html b/plugins/org.eclipse.net4j.util.ui/about.html new file mode 100644 index 0000000000..81a265f458 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/about.html @@ -0,0 +1,42 @@ + + + + + + + + About + + + + + +

About This Content

+ +

May 17, 2007

+ +

License

+ +

The Eclipse Foundation makes available all content in this + plug-in ("Content"). Unless otherwise indicated below, + the Content is provided to you under the terms and conditions of + the Eclipse Public License Version 1.0 ("EPL"). A copy of + the EPL is available at + + http://www.eclipse.org/legal/epl-v10.html. For purposes of the + EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If + no such license exists, contact the Redistributor. Unless otherwise + indicated below, the terms and conditions of the EPL still apply to + any source code in the Content.

+ + + + + diff --git a/plugins/org.eclipse.net4j.util.ui/build.properties b/plugins/org.eclipse.net4j.util.ui/build.properties new file mode 100644 index 0000000000..194bae174c --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/build.properties @@ -0,0 +1,12 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + .options,\ + about.html,\ + copyright.txt,\ + epl-v10.html,\ + icons/,\ + license.html,\ + plugin.properties,\ + plugin.xml diff --git a/plugins/org.eclipse.net4j.util.ui/copyright.txt b/plugins/org.eclipse.net4j.util.ui/copyright.txt new file mode 100644 index 0000000000..025f15218e --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/copyright.txt @@ -0,0 +1,8 @@ +Copyright (c) 2004 - 2007 Eike Stepper, Germany. +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 + +Contributors: + Eike Stepper - initial API and implementation \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/epl-v10.html b/plugins/org.eclipse.net4j.util.ui/epl-v10.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/epl-v10.html @@ -0,0 +1,319 @@ + + + + + +Eclipse Public License - Version 1.0 + + + + + + +
+ +

Eclipse Public License - v 1.0 +

+ +

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.

+ +

1. DEFINITIONS

+ +

"Contribution" means:

+ +

a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and
+b) in the case of each subsequent Contributor:

+ +

i) +changes to the Program, and

+ +

ii) +additions to the Program;

+ +

where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program.

+ +

"Contributor" means any person or +entity that distributes the Program.

+ +

"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program.

+ +

"Program" means the Contributions +distributed in accordance with this Agreement.

+ +

"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.

+ +

2. GRANT OF RIGHTS

+ +

a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.

+ +

b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder.

+ +

c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.

+ +

d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement.

+ +

3. REQUIREMENTS

+ +

A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that: +

+ +

a) +it complies with the terms and conditions of this Agreement; and

+ +

b) +its license agreement:

+ +

i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose;

+ +

ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits;

+ +

iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and

+ +

iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.

+ +

When the Program is made available in source +code form:

+ +

a) +it must be made available under this Agreement; and

+ +

b) a +copy of this Agreement must be included with each copy of the Program.

+ +

Contributors may not remove or alter any +copyright notices contained within the Program.

+ +

Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution.

+ +

4. COMMERCIAL DISTRIBUTION

+ +

Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.

+ +

For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.

+ +

5. NO WARRANTY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations.

+ +

6. DISCLAIMER OF LIABILITY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.

+ +

7. GENERAL

+ +

If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.

+ +

If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed.

+ +

All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

+ +

Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.

+ +

This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.

+ +

 

+ +
+ + \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/icons/.cvsignore b/plugins/org.eclipse.net4j.util.ui/icons/.cvsignore new file mode 100644 index 0000000000..085e8baf0c --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/icons/.cvsignore @@ -0,0 +1 @@ +Thumbs.db diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/.cvsignore b/plugins/org.eclipse.net4j.util.ui/icons/full/.cvsignore new file mode 100644 index 0000000000..085e8baf0c --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/icons/full/.cvsignore @@ -0,0 +1 @@ +Thumbs.db diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/.cvsignore b/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/.cvsignore new file mode 100644 index 0000000000..085e8baf0c --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/.cvsignore @@ -0,0 +1 @@ +Thumbs.db diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/add.gif b/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/add.gif new file mode 100644 index 0000000000..252d7ebcb8 Binary files /dev/null and b/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/add.gif differ diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/delete.gif b/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/delete.gif new file mode 100644 index 0000000000..b6922ac11c Binary files /dev/null and b/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/delete.gif differ diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/refresh.gif b/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/refresh.gif new file mode 100644 index 0000000000..e3831471a6 Binary files /dev/null and b/plugins/org.eclipse.net4j.util.ui/icons/full/etool16/refresh.gif differ diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/.cvsignore b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/.cvsignore new file mode 100644 index 0000000000..085e8baf0c --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/.cvsignore @@ -0,0 +1 @@ +Thumbs.db diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/adapter.gif b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/adapter.gif new file mode 100644 index 0000000000..e8c1e6ff7e Binary files /dev/null and b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/adapter.gif differ diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/factory.gif b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/factory.gif new file mode 100644 index 0000000000..955d5e87a5 Binary files /dev/null and b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/factory.gif differ diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/folder.gif b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/folder.gif new file mode 100644 index 0000000000..42e027c933 Binary files /dev/null and b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/folder.gif differ diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/javabean.gif b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/javabean.gif new file mode 100644 index 0000000000..d9bfbd0541 Binary files /dev/null and b/plugins/org.eclipse.net4j.util.ui/icons/full/obj16/javabean.gif differ diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/view16/.cvsignore b/plugins/org.eclipse.net4j.util.ui/icons/full/view16/.cvsignore new file mode 100644 index 0000000000..085e8baf0c --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/icons/full/view16/.cvsignore @@ -0,0 +1 @@ +Thumbs.db diff --git a/plugins/org.eclipse.net4j.util.ui/icons/full/view16/container.gif b/plugins/org.eclipse.net4j.util.ui/icons/full/view16/container.gif new file mode 100644 index 0000000000..6a2267e6cc Binary files /dev/null and b/plugins/org.eclipse.net4j.util.ui/icons/full/view16/container.gif differ diff --git a/plugins/org.eclipse.net4j.util.ui/license.html b/plugins/org.eclipse.net4j.util.ui/license.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/license.html @@ -0,0 +1,319 @@ + + + + + +Eclipse Public License - Version 1.0 + + + + + + +
+ +

Eclipse Public License - v 1.0 +

+ +

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.

+ +

1. DEFINITIONS

+ +

"Contribution" means:

+ +

a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and
+b) in the case of each subsequent Contributor:

+ +

i) +changes to the Program, and

+ +

ii) +additions to the Program;

+ +

where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program.

+ +

"Contributor" means any person or +entity that distributes the Program.

+ +

"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program.

+ +

"Program" means the Contributions +distributed in accordance with this Agreement.

+ +

"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.

+ +

2. GRANT OF RIGHTS

+ +

a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.

+ +

b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder.

+ +

c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.

+ +

d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement.

+ +

3. REQUIREMENTS

+ +

A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that: +

+ +

a) +it complies with the terms and conditions of this Agreement; and

+ +

b) +its license agreement:

+ +

i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose;

+ +

ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits;

+ +

iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and

+ +

iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.

+ +

When the Program is made available in source +code form:

+ +

a) +it must be made available under this Agreement; and

+ +

b) a +copy of this Agreement must be included with each copy of the Program.

+ +

Contributors may not remove or alter any +copyright notices contained within the Program.

+ +

Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution.

+ +

4. COMMERCIAL DISTRIBUTION

+ +

Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.

+ +

For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.

+ +

5. NO WARRANTY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations.

+ +

6. DISCLAIMER OF LIABILITY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.

+ +

7. GENERAL

+ +

If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.

+ +

If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed.

+ +

All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

+ +

Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.

+ +

This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.

+ +

 

+ +
+ + \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/plugin.properties b/plugins/org.eclipse.net4j.util.ui/plugin.properties new file mode 100644 index 0000000000..e6b79fbbda --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/plugin.properties @@ -0,0 +1,33 @@ +# /** +# * +# * +# * Copyright (c) 2004 - 2007 Eike Stepper, Germany. +# * 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 +# * +# * Contributors: +# * Eike Stepper - Initial API and implementation +# * +# * +# * +# * $Id$ +# */ + +# NLS_MESSAGEFORMAT_VAR + +# ============================================================================== +# Do not change the properties between this line and the last line containing: +# %%% END OF TRANSLATED PROPERTIES %%% +# Instead, either redefine an existing property, or create a new property, +# append it to the end of the file, and change the code to use the new name. +# ============================================================================== + +pluginName=Net4j Utilities UI +providerName=Eclipse.org + +# ============================================================================== +# %%% END OF TRANSLATED PROPERTIES %%% +# The above properties have been shipped for translation. +# ============================================================================== diff --git a/plugins/org.eclipse.net4j.util.ui/plugin.xml b/plugins/org.eclipse.net4j.util.ui/plugin.xml new file mode 100644 index 0000000000..f7eb1e9d41 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/plugin.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/SharedIcons.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/SharedIcons.java new file mode 100644 index 0000000000..97042177c6 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/SharedIcons.java @@ -0,0 +1,106 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.internal.ui; + +import org.eclipse.net4j.util.internal.ui.bundle.OM; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * @author Eike Stepper + */ +public class SharedIcons +{ + private static final ImageRegistry REGISTRY = new ImageRegistry(getDisplay()); + + private static final String ETOOL = "etool16/"; + + private static final String OBJ = "obj16/"; + + private static final String VIEW = "view16/"; + + public static final String OBJ_ADAPTER = OBJ + "adapter"; + + public static final String OBJ_FACTORY = OBJ + "factory"; + + public static final String OBJ_FOLDER = OBJ + "folder"; + + public static final String OBJ_BEAN = OBJ + "javabean"; + + public static final String VIEW_CONTAINER = VIEW + "container"; + + public static final String ETOOL_ADD = ETOOL + "add"; + + public static final String ETOOL_DELETE = ETOOL + "delete"; + + public static final String ETOOL_REFRESH = ETOOL + "refresh"; + + public static Image getImage(String key) + { + key = mangleKey(key); + Image image = REGISTRY.get(key); + if (image == null) + { + createDescriptor(key); + image = REGISTRY.get(key); + } + + return image; + } + + public static ImageDescriptor getDescriptor(String key) + { + key = mangleKey(key); + ImageDescriptor descriptor = REGISTRY.getDescriptor(key); + if (descriptor == null) + { + descriptor = createDescriptor(key); + } + + return descriptor; + } + + private static ImageDescriptor createDescriptor(String key) + { + ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, key); + if (descriptor != null) + { + REGISTRY.put(key, descriptor); + } + + return descriptor; + } + + private static Display getDisplay() + { + Display display = Display.getCurrent(); + if (display == null) + { + display = Display.getDefault(); + } + + if (display == null) + { + throw new IllegalStateException("display == null"); + } + + return display; + } + + private static String mangleKey(String key) + { + return "icons/full/" + key + ".gif"; + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java new file mode 100644 index 0000000000..534f3afa43 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.internal.ui.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.pref.OMPreferences; +import org.eclipse.net4j.util.om.trace.OMTracer; +import org.eclipse.net4j.util.ui.UIActivator; + +/** + * @author Eike Stepper + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.net4j.util.ui"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + public static final OMPreferences PREFS = BUNDLE.preferences(); + + /** + * @author Eike Stepper + */ + public static final class Activator extends UIActivator + { + public static Activator INSTANCE; + + public Activator() + { + super(BUNDLE); + INSTANCE = this; + } + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerView.java new file mode 100644 index 0000000000..cad7eee85b --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerView.java @@ -0,0 +1,25 @@ +package org.eclipse.net4j.util.internal.ui.views; + +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IPluginTransportContainer; +import org.eclipse.net4j.util.ui.views.ContainerItemProvider; +import org.eclipse.net4j.util.ui.views.ContainerView; + +public class Net4jContainerView extends ContainerView +{ + public Net4jContainerView() + { + } + + @Override + protected ContainerItemProvider createContainerItemProvider() + { + return new Net4jItemProvider(); + } + + @Override + protected IManagedContainer getContainer() + { + return IPluginTransportContainer.INSTANCE; + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jItemProvider.java new file mode 100644 index 0000000000..fbfabda458 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jItemProvider.java @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.internal.ui.views; + +import org.eclipse.net4j.util.internal.ui.SharedIcons; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; +import org.eclipse.net4j.util.ui.actions.SafeAction; +import org.eclipse.net4j.util.ui.views.ContainerItemProvider; +import org.eclipse.net4j.util.ui.views.ContainerView; +import org.eclipse.net4j.util.ui.views.IElementFilter; + +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.viewers.ITreeSelection; +import org.eclipse.swt.graphics.Image; + +import java.util.Iterator; + +/** + * @author Eike Stepper + */ +public class Net4jItemProvider extends ContainerItemProvider +{ + public Net4jItemProvider() + { + } + + public Net4jItemProvider(IElementFilter rootElementFilter) + { + super(rootElementFilter); + } + + @Override + protected void fillContextMenu(IMenuManager manager, ITreeSelection selection) + { + manager.add(new RemoveAction(selection)); + } + + @Override + public Image getImage(Object obj) + { + return SharedIcons.getImage(SharedIcons.OBJ_BEAN); + } + + /** + * @author Eike Stepper + */ + public class RemoveAction extends SafeAction + { + private ITreeSelection selection; + + public RemoveAction(ITreeSelection selection) + { + super("Remove", "Remove", ContainerView.getDeleteImageDescriptor()); + this.selection = selection; + } + + @Override + protected void doRun() throws Exception + { + for (Iterator it = selection.iterator(); it.hasNext();) + { + Object object = it.next(); + LifecycleUtil.deactivate(object); + } + } + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/ComboAutoCompleter.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/ComboAutoCompleter.java new file mode 100644 index 0000000000..c6914592b8 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/ComboAutoCompleter.java @@ -0,0 +1,92 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui; + +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; + +/** + * @author Eike Stepper + */ +public class ComboAutoCompleter implements ModifyListener +{ + private ComboViewer viewer; + + public ComboAutoCompleter(ComboViewer viewer) + { + this.viewer = viewer; + } + + public final ComboViewer getViewer() + { + return viewer; + } + + public final void modifyText(ModifyEvent e) + { + String text = getText(); + Object foundElement = findShortestLabel(text); + if (foundElement != null) + { + setSelection(new StructuredSelection(foundElement)); + } + else + { + // setSelection(StructuredSelection.EMPTY); + } + } + + protected void setSelection(StructuredSelection selection) + { + viewer.setSelection(selection); + } + + private Object findShortestLabel(String prefix) + { + Object foundElement = null; + String shortestLabel = null; + ILabelProvider labelProvider = (ILabelProvider)viewer.getLabelProvider(); + IStructuredContentProvider contentProvider = (IStructuredContentProvider)viewer.getContentProvider(); + for (Object element : contentProvider.getElements(viewer.getInput())) + { + String label = labelProvider.getText(element); + if (label.startsWith(prefix)) + { + if (shortestLabel == null || label.length() < shortestLabel.length()) + { + shortestLabel = label; + foundElement = element; + } + } + } + + return foundElement; + } + + private String getText() + { + return viewer.getCombo().getText(); + } + + public static void attach(ComboViewer viewer, ComboAutoCompleter completer) + { + viewer.getCombo().addModifyListener(completer); + } + + public static void attach(ComboViewer viewer) + { + viewer.getCombo().addModifyListener(new ComboAutoCompleter(viewer)); + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/DelegatingContentProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/DelegatingContentProvider.java new file mode 100644 index 0000000000..22f7a069b1 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/DelegatingContentProvider.java @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +/** + * @author Eike Stepper + */ +public class DelegatingContentProvider implements IStructuredContentProvider +{ + public static final String NONE = ""; + + private IStructuredContentProvider delegate; + + private boolean optional; + + public DelegatingContentProvider(IStructuredContentProvider delegate, boolean optional) + { + this.delegate = delegate; + this.optional = optional; + } + + public DelegatingContentProvider(IStructuredContentProvider delegate) + { + this(delegate, false); + } + + public IStructuredContentProvider getDelegate() + { + return delegate; + } + + public boolean isOptional() + { + return optional; + } + + public void dispose() + { + delegate.dispose(); + } + + public Object[] getElements(Object inputElement) + { + Object[] elements = delegate.getElements(inputElement); + if (optional) + { + Object[] newElements = new Object[elements.length + 1]; + newElements[0] = NONE; + System.arraycopy(elements, 0, newElements, 1, elements.length); + elements = newElements; + } + + return elements; + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) + { + delegate.inputChanged(viewer, oldInput, newInput); + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StaticContentProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StaticContentProvider.java new file mode 100644 index 0000000000..d0de8b794f --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StaticContentProvider.java @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui; + +import java.util.Collection; + +/** + * @author Eike Stepper + */ +public class StaticContentProvider extends StructuredContentProvider +{ + private Object[] elements; + + public StaticContentProvider(Object[] elements) + { + this.elements = elements; + } + + public StaticContentProvider(Collection elements) + { + this(elements.toArray()); + } + + public StaticContentProvider(Class enumClass) + { + this(createElements(enumClass)); + } + + public Object[] getElements(Object inputElement) + { + return elements; + } + + private static Object[] createElements(Class enumClass) + { + Object[] enumConstants = enumClass.getEnumConstants(); + if (enumConstants == null) + { + throw new IllegalArgumentException("Illegal enum: " + enumClass); + } + + return enumConstants; + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java new file mode 100644 index 0000000000..e5fcde7a46 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java @@ -0,0 +1,165 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui; + +import org.eclipse.net4j.util.event.IEvent; +import org.eclipse.net4j.util.event.IListener; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.widgets.Display; + +/** + * @author Eike Stepper + */ +public abstract class StructuredContentProvider implements IStructuredContentProvider, IListener +{ + private StructuredViewer viewer; + + private INPUT input; + + public StructuredContentProvider() + { + } + + public void dispose() + { + if (input != null) + { + disconnectInput(input); + input = null; + } + } + + public INPUT getInput() + { + return input; + } + + public StructuredViewer getViewer() + { + return viewer; + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) + { + this.viewer = (StructuredViewer)viewer; + if (newInput != input) + { + if (input != null) + { + disconnectInput(input); + } + try + { + input = (INPUT)newInput; + connectInput(input); + } + catch (Exception ex) + { + input = null; + } + } + } + + protected void connectInput(INPUT input) + { + } + + protected void disconnectInput(INPUT input) + { + } + + public void notifyEvent(IEvent event) + { + refreshViewer(true); + } + + protected void refreshViewer(boolean updateLabels) + { + refreshElement(null, updateLabels); + } + + protected void refreshElement(final Object element, final boolean updateLabels) + { + try + { + getDisplay().asyncExec(new Runnable() + { + public void run() + { + try + { + if (element != null) + { + viewer.refresh(element, updateLabels); + } + else + { + viewer.refresh(updateLabels); + } + } + catch (Exception ignore) + { + } + } + }); + } + catch (Exception ignore) + { + } + } + + protected void revealElement(final Object element) + { + try + { + getDisplay().asyncExec(new Runnable() + { + public void run() + { + try + { + viewer.reveal(element); + } + catch (Exception ignore) + { + } + } + }); + } + catch (Exception ignore) + { + } + } + + protected Display getDisplay() + { + Display display = viewer.getControl().getDisplay(); + if (display == null) + { + display = Display.getCurrent(); + } + + if (display == null) + { + display = Display.getDefault(); + } + + if (display == null) + { + throw new IllegalStateException("display == null"); + } + + return display; + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java new file mode 100644 index 0000000000..02cc52080f --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui; + +import org.eclipse.net4j.internal.util.om.OSGiBundle; +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OSGiActivator; + +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import org.osgi.framework.BundleContext; + +/** + * @author Eike Stepper + */ +public class UIActivator extends AbstractUIPlugin +{ + private OMBundle omBundle; + + public UIActivator(OMBundle omBundle) + { + this.omBundle = omBundle; + } + + public final OMBundle getOMBundle() + { + return omBundle; + } + + @Override + public void start(BundleContext context) throws Exception + { + OSGiActivator.startBundle(context, (OSGiBundle)getOMBundle()); + super.start(context); + } + + @Override + public void stop(BundleContext context) throws Exception + { + super.stop(context); + OSGiActivator.stopBundle(context, (OSGiBundle)getOMBundle()); + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java new file mode 100644 index 0000000000..136deb8cbf --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Eike Stepper + */ +public final class UIUtil +{ + private UIUtil() + { + } + + public static Composite createGridComposite(Composite parent, int columns) + { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(createGridLayout(columns)); + return composite; + } + + public static GridLayout createGridLayout(int columns) + { + GridLayout layout = new GridLayout(); + layout.numColumns = columns; + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.verticalSpacing = 0; + layout.horizontalSpacing = 0; + return layout; + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java new file mode 100644 index 0000000000..f23de36df9 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java @@ -0,0 +1,191 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.actions; + +import org.eclipse.net4j.util.internal.ui.bundle.OM; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; + +/** + * @author Eike Stepper + */ +public abstract class LongRunningAction extends SafeAction +{ + private IWorkbenchPage page; + + private IStatus status; + + private int totalWork; + + public LongRunningAction(IWorkbenchPage page) + { + this.page = page; + } + + public LongRunningAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image) + { + super(text, toolTipText, image); + this.page = page; + } + + public LongRunningAction(IWorkbenchPage page, String text, ImageDescriptor image) + { + super(text, image); + this.page = page; + } + + public LongRunningAction(IWorkbenchPage page, String text, String toolTipText) + { + super(text, toolTipText); + this.page = page; + } + + public LongRunningAction(IWorkbenchPage page, String text, int style) + { + super(text, style); + this.page = page; + } + + public LongRunningAction(IWorkbenchPage page, String text) + { + super(text); + this.page = page; + } + + public LongRunningAction() + { + } + + public LongRunningAction(String text, ImageDescriptor image) + { + super(text, image); + } + + public LongRunningAction(String text, int style) + { + super(text, style); + } + + public LongRunningAction(String text, String toolTipText, ImageDescriptor image) + { + super(text, toolTipText, image); + } + + public LongRunningAction(String text, String toolTipText) + { + super(text, toolTipText); + } + + public LongRunningAction(String text) + { + super(text); + } + + public void setPage(IWorkbenchPage page) + { + this.page = page; + } + + public IWorkbenchPage getPage() + { + return page; + } + + public IWorkbenchWindow getWorkbenchWindow() + { + return page.getWorkbenchWindow(); + } + + public Shell getShell() + { + return getWorkbenchWindow().getShell(); + } + + protected final int getTotalWork() + { + return totalWork; + } + + protected final void setTotalWork(int totalWork) + { + this.totalWork = totalWork; + } + + protected final void cancel() + { + totalWork = 0; + } + + protected final void setStatus(IStatus status) + { + this.status = status; + } + + @Override + protected final void doRun() throws Exception + { + totalWork = IProgressMonitor.UNKNOWN; + preRun(); + if (totalWork != 0) + { + new Job(getText()) + { + @Override + protected IStatus run(IProgressMonitor monitor) + { + monitor.beginTask("", totalWork); + try + { + setStatus(Status.OK_STATUS); + doRun(monitor); + return status; + } + catch (Exception ex) + { + return handleException(ex); + } + finally + { + monitor.done(); + } + } + }.schedule(); + } + } + + protected void preRun() throws Exception + { + } + + protected abstract void doRun(IProgressMonitor monitor) throws Exception; + + protected IStatus handleException(Exception ex) + { + ex.printStackTrace(); + return new Status(IStatus.ERROR, OM.BUNDLE_ID, "An error has occured.", ex); + } + + protected final void checkCancelation(IProgressMonitor monitor) + { + if (monitor.isCanceled()) + { + throw new OperationCanceledException(); + } + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/SafeAction.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/SafeAction.java new file mode 100644 index 0000000000..3c64f21b69 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/SafeAction.java @@ -0,0 +1,60 @@ +package org.eclipse.net4j.util.ui.actions; + +import org.eclipse.net4j.util.internal.ui.bundle.OM; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * @author Eike Stepper + */ +public abstract class SafeAction extends Action +{ + public SafeAction() + { + } + + public SafeAction(String text, String toolTipText, ImageDescriptor image) + { + super(text, image); + setToolTipText(toolTipText); + } + + public SafeAction(String text, String toolTipText) + { + super(text, null); + setToolTipText(toolTipText); + } + + public SafeAction(String text, ImageDescriptor image) + { + super(text, image); + } + + public SafeAction(String text, int style) + { + super(text, style); + } + + public SafeAction(String text) + { + super(text); + } + + @Override + public final void run() + { + try + { + doRun(); + } + catch (Exception ex) + { + OM.LOG.error(ex); + MessageDialog.openError(null, getText(), ex.getMessage() + "\nSee the Error log for details."); + } + } + + protected abstract void doRun() throws Exception; +} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java new file mode 100644 index 0000000000..f10da07c76 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java @@ -0,0 +1,385 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.views; + +import org.eclipse.net4j.internal.util.container.ContainerEventAdapter; +import org.eclipse.net4j.util.container.IContainer; +import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class ContainerItemProvider extends ItemProvider +{ + private Map nodes = new HashMap(); + + private ContainerNode root; + + private IElementFilter rootElementFilter; + + public ContainerItemProvider() + { + } + + public ContainerItemProvider(IElementFilter rootElementFilter) + { + this.rootElementFilter = rootElementFilter; + } + + public IElementFilter getRootElementFilter() + { + return rootElementFilter; + } + + @Override + public boolean hasChildren(Object element) + { + try + { + Node node = getNode(element); + return !node.getChildren().isEmpty(); + } + catch (Exception ex) + { + return false; + } + } + + public Object[] getChildren(Object element) + { + try + { + Node node = getNode(element); + List children = node.getChildren(); + for (Iterator it = children.iterator(); it.hasNext();) + { + Object child = it.next(); + if (!LifecycleUtil.isActive(child)) + { + it.remove(); + } + } + + Object[] result = new Object[children.size()]; + for (int i = 0; i < result.length; i++) + { + result[i] = children.get(i).getElement(); + } + + return result; + } + catch (RuntimeException ex) + { + return NO_CHILDREN; + } + } + + public Object getParent(Object element) + { + try + { + Node node = getNode(element); + Node parentNode = node.getParent(); + return parentNode == null ? null : parentNode.getElement(); + } + catch (RuntimeException ex) + { + return null; + } + } + + @Override + protected void connectInput(CONTAINER input) + { + root = (ContainerNode)createNode(null, input); + nodes.put(input, root); + } + + @Override + protected void disconnectInput(CONTAINER input) + { + root.dispose(); + root = null; + nodes.clear(); + } + + protected void elementAdded(Object element, Object parent) + { + } + + protected void elementRemoved(Object element, Object parent) + { + } + + protected ContainerNode getRoot() + { + return root; + } + + protected Map getNodes() + { + return nodes; + } + + protected Node getNode(Object element) + { + Node node = root; + if (element != getInput()) + { + node = nodes.get(element); + } + + if (node == null) + { + throw new IllegalStateException("No node for " + element); + } + + return node; + } + + protected Node createNode(Node parent, Object element) + { + if (element instanceof IContainer) + { + return new ContainerNode(parent, (IContainer)element); + } + + return new LeafNode(parent, element); + } + + protected boolean filterRootElement(Object element) + { + if (rootElementFilter != null) + { + return rootElementFilter.filter(element); + } + + return true; + } + + /** + * @author Eike Stepper + */ + public interface Node + { + public void dispose(); + + public Object getElement(); + + public Node getParent(); + + public List getChildren(); + } + + /** + * @author Eike Stepper + */ + public abstract class AbstractNode implements Node + { + private Node parent; + + private List children; + + public AbstractNode(Node parent) + { + this.parent = parent; + } + + public void dispose() + { + parent = null; + if (children != null) + { + for (Node child : children) + { + child.dispose(); + } + + children.clear(); + children = null; + } + } + + @Override + public String toString() + { + return getElement().toString(); + } + + public final Node getParent() + { + return parent; + } + + public final List getChildren() + { + if (children == null) + { + children = createChildren(); + } + + return children; + } + + protected abstract List createChildren(); + } + + /** + * @author Eike Stepper + */ + public class ContainerNode extends AbstractNode + { + private IContainer container; + + private IListener containerListener = new ContainerEventAdapter() + { + @Override + protected void onAdded(IContainer container, Object element) + { + if (container == ContainerNode.this.container) + { + Node node = addChild(getChildren(), element); + if (node != null) + { + refreshElement(container, false); + revealElement(element); + elementAdded(element, container); + } + } + } + + @Override + protected void onRemoved(IContainer container, Object element) + { + if (container == ContainerNode.this.container) + { + Node node = nodes.remove(element); + if (node != null) + { + getChildren().remove(node); + node.dispose(); + refreshElement(container, false); + elementRemoved(element, container); + } + } + } + }; + + public ContainerNode(Node parent, IContainer container) + { + super(parent); + this.container = container; + } + + @Override + public void dispose() + { + container.removeListener(containerListener); + container = null; + super.dispose(); + } + + public IContainer getContainer() + { + return container; + } + + public Object getElement() + { + return container; + } + + @Override + public String toString() + { + return container == null ? super.toString() : container.toString(); + } + + @Override + protected List createChildren() + { + Object[] elements = container.getElements(); + List children = new ArrayList(elements.length); + for (int i = 0; i < elements.length; i++) + { + Object element = elements[i]; + addChild(children, element); + } + + container.addListener(containerListener); + return children; + } + + protected Node addChild(List children, Object element) + { + if (this != root || filterRootElement(element)) + { + Node node = createNode(this, element); + nodes.put(element, node); + children.add(node); + return node; + } + + return null; + } + } + + /** + * @author Eike Stepper + */ + public class LeafNode implements Node + { + private Node parent; + + private Object element; + + public LeafNode(Node parent, Object element) + { + this.parent = parent; + this.element = element; + } + + public void dispose() + { + parent = null; + element = null; + } + + public Node getParent() + { + return parent; + } + + public Object getElement() + { + return element; + } + + public List getChildren() + { + return Collections.EMPTY_LIST; + } + + @Override + public String toString() + { + return element == null ? super.toString() : element.toString(); + } + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerNameSorter.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerNameSorter.java new file mode 100644 index 0000000000..000df70ca3 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerNameSorter.java @@ -0,0 +1,17 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.views; + +import org.eclipse.jface.viewers.ViewerSorter; + +public class ContainerNameSorter extends ViewerSorter +{ +} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java new file mode 100644 index 0000000000..b9467b66fa --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java @@ -0,0 +1,270 @@ +package org.eclipse.net4j.util.ui.views; + +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.internal.ui.SharedIcons; +import org.eclipse.net4j.util.ui.actions.SafeAction; + +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.resource.ImageDescriptor; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ITreeSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TreeViewer; +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.IWorkbenchActionConstants; +import org.eclipse.ui.part.ISetSelectionTarget; +import org.eclipse.ui.part.ViewPart; + +public abstract class ContainerView extends ViewPart implements ISetSelectionTarget +{ + private ContainerItemProvider itemProvider; + + private TreeViewer viewer; + + private ISelectionChangedListener selectionListener = new ISelectionChangedListener() + { + public void selectionChanged(SelectionChangedEvent event) + { + ITreeSelection selection = (ITreeSelection)event.getSelection(); + IActionBars bars = getViewSite().getActionBars(); + ContainerView.this.selectionChanged(bars, selection); + } + }; + + private Action refreshAction = new RefreshAction(); + + public ContainerView() + { + } + + @Override + public void setFocus() + { + viewer.getControl().setFocus(); + } + + public void selectReveal(ISelection selection) + { + viewer.setSelection(selection, true); + } + + @Override + public void createPartControl(Composite parent) + { + itemProvider = createContainerItemProvider(); + viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.setContentProvider(itemProvider); + viewer.setLabelProvider(itemProvider); + viewer.setSorter(new ContainerNameSorter()); + viewer.setInput(getContainer()); + viewer.addSelectionChangedListener(selectionListener); + getSite().setSelectionProvider(viewer); + + hookContextMenu(); + hookDoubleClick(); + contributeToActionBars(); + } + + protected ContainerItemProvider createContainerItemProvider() + { + return new ContainerItemProvider(getRootElementFilter()) + { + @Override + public Image getImage(Object obj) + { + Image image = getElementImage(obj); + if (image == null) + { + image = super.getImage(obj); + } + + return image; + } + + @Override + public String getText(Object obj) + { + String text = getElementText(obj); + if (text == null) + { + text = super.getText(obj); + } + + return text; + } + }; + } + + protected String getElementText(Object element) + { + return null; + } + + protected Image getElementImage(Object element) + { + return null; + } + + protected IElementFilter getRootElementFilter() + { + return null; + } + + protected abstract IManagedContainer getContainer(); + + protected void hookDoubleClick() + { + viewer.addDoubleClickListener(new IDoubleClickListener() + { + public void doubleClick(DoubleClickEvent event) + { + ITreeSelection selection = (ITreeSelection)viewer.getSelection(); + Object object = selection.getFirstElement(); + doubleClicked(object); + } + }); + } + + protected void hookContextMenu() + { + MenuManager menuMgr = new MenuManager("#PopupMenu"); + menuMgr.setRemoveAllWhenShown(true); + menuMgr.addMenuListener(new IMenuListener() + { + public void menuAboutToShow(IMenuManager manager) + { + ITreeSelection selection = (ITreeSelection)viewer.getSelection(); + fillContextMenu(manager, selection); + } + }); + + Menu menu = menuMgr.createContextMenu(viewer.getControl()); + viewer.getControl().setMenu(menu); + getSite().registerContextMenu(menuMgr, viewer); + } + + protected void contributeToActionBars() + { + IActionBars bars = getViewSite().getActionBars(); + fillLocalPullDown(bars.getMenuManager()); + fillLocalToolBar(bars.getToolBarManager()); + } + + protected void fillLocalPullDown(IMenuManager manager) + { + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + manager.add(refreshAction); + } + + protected void fillLocalToolBar(IToolBarManager manager) + { + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + } + + protected void fillContextMenu(IMenuManager manager, ITreeSelection selection) + { + itemProvider.fillContextMenu(manager, selection); + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + } + + protected void selectionChanged(IActionBars bars, ITreeSelection selection) + { + } + + protected void doubleClicked(Object object) + { + if (object != null && viewer.isExpandable(object)) + { + if (viewer.getExpandedState(object)) + { + viewer.collapseToLevel(object, TreeViewer.ALL_LEVELS); + } + else + { + viewer.expandToLevel(object, 1); + } + } + } + + protected void showMessage(String message) + { + showMessage(MessageType.INFORMATION, message); + } + + protected boolean showMessage(MessageType type, String message) + { + switch (type) + { + case INFORMATION: + MessageDialog.openInformation(viewer.getControl().getShell(), getTitle(), message); + return true; + + case ERROR: + MessageDialog.openError(viewer.getControl().getShell(), getTitle(), message); + return true; + + case WARNING: + MessageDialog.openWarning(viewer.getControl().getShell(), getTitle(), message); + return true; + + case CONFIRM: + return MessageDialog.openConfirm(viewer.getControl().getShell(), getTitle(), message); + + case QUESTION: + return MessageDialog.openQuestion(viewer.getControl().getShell(), getTitle(), message); + + default: + return true; + } + } + + public static ImageDescriptor getAddImageDescriptor() + { + return SharedIcons.getDescriptor(SharedIcons.ETOOL_ADD); + } + + public static ImageDescriptor getDeleteImageDescriptor() + { + return SharedIcons.getDescriptor(SharedIcons.ETOOL_DELETE); + } + + public static ImageDescriptor getRefreshImageDescriptor() + { + return SharedIcons.getDescriptor(SharedIcons.ETOOL_REFRESH); + } + + protected static enum MessageType + { + INFORMATION, ERROR, WARNING, CONFIRM, QUESTION + } + + /** + * @author Eike Stepper + */ + private final class RefreshAction extends SafeAction + { + private RefreshAction() + { + super("Refresh", "Refresh view", getRefreshImageDescriptor()); + } + + @Override + protected void doRun() throws Exception + { + viewer.refresh(false); + } + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/IElementFilter.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/IElementFilter.java new file mode 100644 index 0000000000..1a4562f054 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/IElementFilter.java @@ -0,0 +1,19 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.views; + +/** + * @author Eike Stepper + */ +public interface IElementFilter +{ + public boolean filter(Object element); +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java new file mode 100644 index 0000000000..1607821d65 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java @@ -0,0 +1,131 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.views; + +import org.eclipse.net4j.util.internal.ui.bundle.OM; +import org.eclipse.net4j.util.ui.StructuredContentProvider; + +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.ITreeSelection; +import org.eclipse.jface.viewers.LabelProviderChangedEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +import java.util.ArrayList; +import java.util.List; + +public abstract class ItemProvider extends StructuredContentProvider implements ITreeContentProvider, + ILabelProvider +{ + protected static final Object[] NO_CHILDREN = new Object[0]; + + private List listeners = new ArrayList(0); + + public ItemProvider() + { + } + + public final Object[] getElements(Object parent) + { + return getChildren(parent); + } + + public boolean hasChildren(Object parent) + { + return getChildren(parent).length != 0; + } + + public String getText(Object obj) + { + return obj.toString(); + } + + public Image getImage(Object obj) + { + String imageKey = ISharedImages.IMG_OBJ_ELEMENT; + return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); + } + + public boolean isLabelProperty(Object element, String property) + { + return true; + } + + public ILabelProviderListener[] getListeners() + { + synchronized (listeners) + { + return listeners.toArray(new ILabelProviderListener[listeners.size()]); + } + } + + public void addListener(ILabelProviderListener listener) + { + synchronized (listeners) + { + listeners.add(listener); + } + } + + public void removeListener(ILabelProviderListener listener) + { + synchronized (listeners) + { + listeners.remove(listener); + } + } + + protected void fillContextMenu(IMenuManager manager, ITreeSelection selection) + { + } + + protected void fireLabelProviderChanged() + { + fireLabelProviderChanged(new LabelProviderChangedEvent(this)); + } + + protected void fireLabelProviderChanged(Object element) + { + fireLabelProviderChanged(new LabelProviderChangedEvent(this, element)); + } + + protected void fireLabelProviderChanged(Object[] elements) + { + fireLabelProviderChanged(new LabelProviderChangedEvent(this, elements)); + } + + /** + * Fires a label provider changed event to all registered listeners Only + * listeners registered at the time this method is called are notified. + * + * @param event + * a label provider changed event + * @see ILabelProviderListener#labelProviderChanged + */ + private void fireLabelProviderChanged(LabelProviderChangedEvent event) + { + for (ILabelProviderListener listener : getListeners()) + { + try + { + listener.labelProviderChanged(event); + } + catch (Exception ex) + { + OM.LOG.error(ex); + } + } + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ManagedContainerItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ManagedContainerItemProvider.java new file mode 100644 index 0000000000..1417c58ad9 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ManagedContainerItemProvider.java @@ -0,0 +1,173 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.views; + +import org.eclipse.net4j.util.container.IManagedContainer; + +import java.util.List; + +/** + * @author Eike Stepper + */ +@Deprecated +public class ManagedContainerItemProvider extends ContainerItemProvider +{ + private boolean showProductGroups = true; + + private boolean showFactoryTypes = false; + + public ManagedContainerItemProvider() + { + } + + public boolean isShowProductGroups() + { + return showProductGroups; + } + + public void setShowProductGroups(boolean showProductGroups) + { + this.showProductGroups = showProductGroups; + } + + public boolean isShowFactoryTypes() + { + return showFactoryTypes; + } + + public void setShowFactoryTypes(boolean showFactoryTypes) + { + this.showFactoryTypes = showFactoryTypes; + } + + @Override + protected Node createNode(Node parent, Object element) + { + if (element instanceof IManagedContainer) + { + return new ManagedContainerNode(parent, (IManagedContainer)element); + } + + return super.createNode(parent, element); + } + + /** + * @author Eike Stepper + */ + public class ManagedContainerNode extends ContainerNode + { + public ManagedContainerNode(Node parent, IManagedContainer container) + { + super(parent, container); + } + } + + /** + * @author Eike Stepper + */ + public class ProductGroupNode extends AbstractNode + { + private String productGroup; + + public ProductGroupNode(ContainerNode parent, String productGroup) + { + super(parent); + this.productGroup = productGroup; + } + + public String getProductGroup() + { + return productGroup; + } + + public IManagedContainer getContainer() + { + ContainerNode parent = (ContainerNode)getParent(); + return (IManagedContainer)parent.getContainer(); + } + + public Object getElement() + { + return this; + } + + @Override + protected List createChildren() + { + return null; + } + } + + /** + * @author Eike Stepper + */ + public class FactoryTypeNode extends AbstractNode + { + private String factoryType; + + public FactoryTypeNode(ProductGroupNode parent, String factoryType) + { + super(parent); + this.factoryType = factoryType; + } + + public ProductGroupNode getProductGroupNode() + { + return (ProductGroupNode)getParent(); + } + + public String getFactoryType() + { + return factoryType; + } + + public IManagedContainer getContainer() + { + return getProductGroupNode().getContainer(); + } + + public Object getElement() + { + return this; + } + + @Override + protected List createChildren() + { + return null; + } + } + + /** + * @author Eike Stepper + */ + public class ProductGroupFactoryTypeNode extends ProductGroupNode + { + private String factoryType; + + public ProductGroupFactoryTypeNode(ContainerNode parent, String productGroup, String factoryType) + { + super(parent, productGroup); + this.factoryType = factoryType; + } + + public String getFactoryType() + { + return factoryType; + } + + @Override + protected List createChildren() + { + return null; + } + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/BaseDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/BaseDialog.java new file mode 100644 index 0000000000..ea189b9c1e --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/BaseDialog.java @@ -0,0 +1,145 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.widgets; + +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Eike Stepper + */ +public abstract class BaseDialog extends TitleAreaDialog +{ + public static final int DEFAULT_SHELL_STYLE = SWT.SHELL_TRIM; + + private String title; + + private String message; + + private IDialogSettings settings; + + private VIEWER currentViewer; + + private MenuManager contextMenu; + + public BaseDialog(Shell parentShell, int shellStyle, String title, String message, IDialogSettings settings) + { + super(parentShell); + setShellStyle(shellStyle); + this.title = title; + this.message = message; + this.settings = settings; + } + + public BaseDialog(Shell parentShell, String title, String message, IDialogSettings settings) + { + this(parentShell, DEFAULT_SHELL_STYLE, title, message, settings); + } + + @Override + protected void configureShell(Shell newShell) + { + super.configureShell(newShell); + newShell.setText(title); + } + + @Override + protected Control createDialogArea(Composite parent) + { + Composite composite = (Composite)super.createDialogArea(parent); + setTitle(title); + setMessage(message); + + contextMenu = new MenuManager("#PopupMenu"); + contextMenu.setRemoveAllWhenShown(true); + contextMenu.addMenuListener(new IMenuListener() + { + public void menuAboutToShow(IMenuManager manager) + { + VIEWER viewer = getCurrentViewer(); + if (viewer != null) + { + fillContextMenu(manager, viewer); + } + } + }); + + createUI(composite); + return composite; + } + + protected abstract void createUI(Composite parent); + + public VIEWER getCurrentViewer() + { + return currentViewer; + } + + public void setCurrentViewer(VIEWER currentViewer) + { + if (this.currentViewer != null) + { + Control control = this.currentViewer.getControl(); + control.setMenu(null); + } + + this.currentViewer = currentViewer; + if (this.currentViewer != null) + { + Control control = this.currentViewer.getControl(); + Menu menu = contextMenu.createContextMenu(control); + control.setMenu(menu); + } + } + + protected void hookContextMenu() + { + contextMenu = new MenuManager("#PopupMenu"); + contextMenu.setRemoveAllWhenShown(true); + contextMenu.addMenuListener(new IMenuListener() + { + public void menuAboutToShow(IMenuManager manager) + { + fillContextMenu(manager, getCurrentViewer()); + } + }); + } + + protected void fillContextMenu(IMenuManager manager, VIEWER viewer) + { + } + + @Override + protected IDialogSettings getDialogBoundsSettings() + { + if (settings == null) + { + return null; + } + + IDialogSettings section = settings.getSection(title); + if (section == null) + { + section = settings.addNewSection(title); + } + + return section; + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java new file mode 100644 index 0000000000..3c8d912569 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java @@ -0,0 +1,257 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.widgets; + +import org.eclipse.net4j.util.ReflectUtil; +import org.eclipse.net4j.util.StringUtil; +import org.eclipse.net4j.util.collection.IHistory; +import org.eclipse.net4j.util.collection.IHistoryChangeEvent; +import org.eclipse.net4j.util.collection.IHistoryElement; +import org.eclipse.net4j.util.event.IEvent; +import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.internal.ui.bundle.OM; +import org.eclipse.net4j.util.ui.UIUtil; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; + +import java.lang.reflect.Method; + +/** + * @author Eike Stepper + */ +public class HistoryText extends Composite +{ + private IHistory history; + + private CCombo combo; + + private Method droppedMethod; + + private IListener historyListener = new IListener() + { + public void notifyEvent(IEvent event) + { + if (event instanceof IHistoryChangeEvent) + { + historyChanged(); + } + } + }; + + public HistoryText(Composite parent, int comboStyle, IHistory history) + { + super(parent, SWT.NONE); + setLayout(UIUtil.createGridLayout(1)); + + combo = createCombo(comboStyle); + combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + try + { + droppedMethod = combo.getClass().getDeclaredMethod("isDropped", ReflectUtil.NO_PARAMETERS); + droppedMethod.setAccessible(true); + } + catch (Exception ex) + { + OM.LOG.error(ex); + } + + this.history = history; + historyChanged(); + history.addListener(historyListener); + } + + public IHistory getHistory() + { + return history; + } + + public CCombo getCombo() + { + return combo; + } + + @Override + public void dispose() + { + history.removeListener(historyListener); + super.dispose(); + } + + public void addModifyListener(ModifyListener listener) + { + combo.addModifyListener(listener); + } + + public void addSelectionListener(SelectionListener listener) + { + combo.addSelectionListener(listener); + } + + public void addVerifyListener(VerifyListener listener) + { + combo.addVerifyListener(listener); + } + + public void append(String string) + { + combo.setText(combo.getText() + string); + } + + public void clearSelection() + { + combo.clearSelection(); + } + + public void copy() + { + combo.copy(); + } + + public void cut() + { + combo.cut(); + } + + public int getCharCount() + { + return combo.getText().length(); + } + + public int getLineCount() + { + return StringUtil.occurrences(combo.getText(), getLineDelimiter()) + 1; + } + + public String getLineDelimiter() + { + return Text.DELIMITER; + } + + public int getLineHeight() + { + return combo.getTextHeight(); + } + + public String getText() + { + return combo.getText(); + } + + public int getTextLimit() + { + return combo.getTextLimit(); + } + + public void paste() + { + combo.paste(); + } + + public void removeModifyListener(ModifyListener listener) + { + combo.removeModifyListener(listener); + } + + public void removeSelectionListener(SelectionListener listener) + { + combo.removeSelectionListener(listener); + } + + public void removeVerifyListener(VerifyListener listener) + { + combo.removeVerifyListener(listener); + } + + public void setText(String string) + { + combo.setText(string); + } + + public void setTextLimit(int limit) + { + combo.setTextLimit(limit); + } + + @Override + public boolean setFocus() + { + return combo.setFocus(); + } + + public boolean isDropped() + { + if (droppedMethod != null) + { + try + { + return (Boolean)droppedMethod.invoke(combo, ReflectUtil.NO_ARGUMENTS); + } + catch (Exception ex) + { + OM.LOG.error(ex); + } + } + + return false; + } + + protected void historyChanged() + { + if (isDisposed()) + { + return; + } + + combo.removeAll(); + for (IHistoryElement element : history) + { + combo.add(element.getData()); + } + + String mostRecent = history.getMostRecent(); + if (mostRecent != null) + { + setText(mostRecent); + } + } + + protected CCombo createCombo(int style) + { + final CCombo combo = new CCombo(this, style); + combo.addKeyListener(new KeyAdapter() + { + @Override + public void keyPressed(KeyEvent event) + { + if (event.character == SWT.DEL && event.stateMask == 0 && isDropped()) + { + int index = combo.getSelectionIndex(); + if (index != -1) + { + history.remove(index); + } + } + } + }); + + return combo; + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java new file mode 100644 index 0000000000..3cbdb5968d --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java @@ -0,0 +1,138 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.widgets; + +import org.eclipse.net4j.util.collection.IHistory; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IInputValidator; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +/** + * TODO extend BaseDialog + * + * @author Eike Stepper + */ +public class HistoryTextDialog extends InputDialog +{ + private static final String EMPTY = ""; + + private IHistory history; + + private String value = EMPTY; + + private HistoryText historyText; + + public HistoryTextDialog(Shell parentShell, String dialogTitle, String dialogMessage, IHistory history, + IInputValidator validator) + { + super(parentShell, dialogTitle, dialogMessage, history.getMostRecent(), validator); + this.history = history; + value = super.getValue(); + } + + public IHistory getHistory() + { + return history; + } + + public HistoryText getHistoryText() + { + return historyText; + } + + @Override + public String getValue() + { + return value; + } + + @Override + protected Control createDialogArea(Composite parent) + { + Composite composite = (Composite)super.createDialogArea(parent); + Text text = getText(); + text.setVisible(false); + text.setEnabled(false); + + historyText = new HistoryText(composite, SWT.BORDER, history); + historyText.moveAbove(text); + historyText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); + historyText.addModifyListener(new ModifyListener() + { + public void modifyText(ModifyEvent e) + { + validateInput(); + } + }); + + text.addFocusListener(new FocusAdapter() + { + @Override + public void focusGained(FocusEvent e) + { + historyText.setFocus(); + } + }); + + composite.getShell().layout(true); + return composite; + } + + @Override + protected void buttonPressed(int buttonId) + { + if (IDialogConstants.OK_ID == buttonId) + { + value = historyText.getText(); + okPressed(); + } + else if (IDialogConstants.CANCEL_ID == buttonId) + { + value = null; + cancelPressed(); + } + } + + @Override + protected void createButtonsForButtonBar(Composite parent) + { + super.createButtonsForButtonBar(parent); + historyText.setFocus(); + if (value != null) + { + historyText.setText(value); + } + } + + @Override + protected void validateInput() + { + String errorMessage = null; + if (getValidator() != null) + { + errorMessage = getValidator().isValid(historyText.getText()); + } + // Bug 16256: important not to treat "" (blank error) the same as null + // (no error) + setErrorMessage(errorMessage); + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/LogDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/LogDialog.java new file mode 100644 index 0000000000..d754326363 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/LogDialog.java @@ -0,0 +1,167 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.widgets; + +import org.eclipse.net4j.util.io.IORuntimeException; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.TextStyle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class LogDialog extends BaseDialog +{ + private StringBuilder log = new StringBuilder(); + + private StyledText text; + + private TextStyle textStyle; + + private List styleRanges = new ArrayList(); + + private StyleRange currentStyleRange = new StyleRange(); + + private StyleRange lastStyleRange; + + private Font font; + + public LogDialog(Shell parentShell, int shellStyle, String title, String message, IDialogSettings settings) + { + super(parentShell, shellStyle, title, message, settings); + } + + public LogDialog(Shell parentShell, String title, String message, IDialogSettings settings) + { + this(parentShell, DEFAULT_SHELL_STYLE, title, message, settings); + } + + public TextStyle getTextStyle() + { + return textStyle; + } + + public void setTextStyle(TextStyle textStyle) + { + if (textStyle == null) + { + throw new IllegalArgumentException("textStyle == null"); + } + + if (textStyle.equals(this.textStyle)) + { + return; + } + + lastStyleRange = currentStyleRange; + this.textStyle = textStyle; + + currentStyleRange = new StyleRange(); + currentStyleRange.start = log.length(); + currentStyleRange.rise = textStyle.rise; + currentStyleRange.background = textStyle.background; + currentStyleRange.font = textStyle.font; + currentStyleRange.foreground = textStyle.foreground; + currentStyleRange.metrics = textStyle.metrics; + currentStyleRange.strikeout = textStyle.strikeout; + currentStyleRange.underline = textStyle.underline; + } + + public void append(String text) + { + checkStyleRange(); + log.append(text); + currentStyleRange.length += text.length(); + } + + public void append(Throwable t) + { + try + { + checkStyleRange(); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + String message = t.getMessage() + "\n"; + bytes.write(message.getBytes()); + t.printStackTrace(new PrintStream(bytes)); + + String text = bytes.toString(); + log.append(text); + currentStyleRange.length += text.length(); + } + catch (IOException ex) + { + throw new IORuntimeException(ex); + } + } + + @Override + public boolean close() + { + font.dispose(); + return super.close(); + } + + @Override + protected void createUI(Composite parent) + { + GridLayout grid = new GridLayout(); + grid.marginTop = 6; + grid.marginLeft = 6; + grid.marginRight = 6; + grid.marginBottom = 6; + + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(grid); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + font = new Font(getShell().getDisplay(), "Courier New", 9, SWT.NORMAL); + checkStyleRange(); + lastStyleRange = currentStyleRange; + checkStyleRange(); + + text = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + text.setText(log.toString()); + text.setStyleRanges(styleRanges.toArray(new StyleRange[styleRanges.size()])); + text.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); + text.setFont(font); + } + + @Override + protected void createButtonsForButtonBar(Composite parent) + { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true); + } + + private void checkStyleRange() + { + if (lastStyleRange != null) + { + styleRanges.add(lastStyleRange); + lastStyleRange = null; + } + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorDialog.java new file mode 100644 index 0000000000..56491e30d4 --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorDialog.java @@ -0,0 +1,126 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.widgets; + +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.om.monitor.MonitorUtil; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + +import java.lang.reflect.InvocationTargetException; + +/** + * @author Eike Stepper + */ +public class MonitorDialog extends ProgressMonitorDialog +{ + public static final int DEFAULT_SHELL_STYLE = SWT.SHELL_TRIM; + + private String title; + + private IDialogSettings settings; + + private MonitorLogDialog log; + + public MonitorDialog(Shell parentShell, int shellStyle, String title, IDialogSettings settings) + { + super(parentShell); + setShellStyle(shellStyle); + this.title = title; + this.settings = settings; + } + + public MonitorDialog(Shell parentShell, String title, IDialogSettings settings) + { + this(parentShell, DEFAULT_SHELL_STYLE, title, settings); + } + + public void run(boolean fork, boolean cancelable, final Runnable runnable) + { + try + { + log = new MonitorLogDialog(getShell(), getShellStyle(), "Log of " + title, "See the log for details.", settings); + log.setEmphasizePrefix("Woven class ", "Mixed in ", "Reversioned "); + + super.run(fork, cancelable, new IRunnableWithProgress() + { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException + { + MonitorUtil.Eclipse.startMonitoring(monitor, log); + try + { + runnable.run(); + } + catch (RuntimeException ex) + { + log.append(ex); + throw ex; + } + finally + { + MonitorUtil.Eclipse.stopMonitoring(); + } + } + }); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + } + + @Override + protected void finishedRun() + { + super.finishedRun(); + if (log != null) + { + log.open(); + } + } + + @Override + @Deprecated + public final void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) + throws InvocationTargetException, InterruptedException + { + throw new UnsupportedOperationException(); + } + + @Override + protected void configureShell(Shell newShell) + { + super.configureShell(newShell); + newShell.setText(title); + } + + @Override + protected IDialogSettings getDialogBoundsSettings() + { + if (settings == null) + { + return null; + } + + IDialogSettings section = settings.getSection(title); + if (section == null) + { + section = settings.addNewSection(title); + } + + return section; + } +} diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorLogDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorLogDialog.java new file mode 100644 index 0000000000..8ca63d601c --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorLogDialog.java @@ -0,0 +1,109 @@ +package org.eclipse.net4j.util.ui.widgets; + +import org.eclipse.net4j.util.om.monitor.OMMonitorHandler; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.TextStyle; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Eike Stepper + */ +public class MonitorLogDialog extends LogDialog implements OMMonitorHandler +{ + private String[] emphasizePrefix; + + private TextStyle taskStyle; + + private TextStyle normalStyle; + + private TextStyle emphasizedStyle; + + private TextStyle problemStyle; + + public MonitorLogDialog(Shell parentShell, int shellStyle, String title, String message, IDialogSettings settings) + { + super(parentShell, shellStyle, title, message, settings); + Display display = Display.getCurrent(); + taskStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_BLACK), null); + normalStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_DARK_GRAY), null); + emphasizedStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_BLUE), null); + problemStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_RED), null); + } + + public MonitorLogDialog(Shell parentShell, String title, String message, IDialogSettings settings) + { + this(parentShell, DEFAULT_SHELL_STYLE, title, message, settings); + } + + public String[] getEmphasizePrefix() + { + return emphasizePrefix; + } + + public void setEmphasizePrefix(String... emphasizePrefix) + { + this.emphasizePrefix = emphasizePrefix; + } + + public TextStyle getNormalStyle() + { + return normalStyle; + } + + public TextStyle getTaskStyle() + { + return taskStyle; + } + + public TextStyle getProblemStyle() + { + return problemStyle; + } + + public TextStyle getEmphasizedStyle() + { + return emphasizedStyle; + } + + public void handleTask(String task, int level) + { + setTextStyle(taskStyle); + append(task); + append("\n"); + } + + public void handleMessage(String msg, int level) + { + boolean emphasized = false; + if (emphasizePrefix != null) + { + for (String prefix : emphasizePrefix) + { + if (msg.startsWith(prefix)) + { + setTextStyle(emphasizedStyle); + emphasized = true; + break; + } + } + } + + if (!emphasized) + { + setTextStyle(normalStyle); + } + + append(msg); + append("\n"); + } + + @Override + public void append(Throwable t) + { + setTextStyle(problemStyle); + super.append(t); + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java new file mode 100644 index 0000000000..54e327cc5f --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java @@ -0,0 +1,117 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.ui.widgets; + +import org.eclipse.net4j.util.om.pref.OMPreference; +import org.eclipse.net4j.util.ui.UIUtil; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Eike Stepper + */ +public class PreferenceButton extends Composite +{ + private OMPreference preference; + + private Button button; + + public PreferenceButton(Composite parent, int buttonStyle, final OMPreference preference) + { + super(parent, SWT.NONE); + setLayout(UIUtil.createGridLayout(1)); + this.preference = preference; + + button = createButton(buttonStyle); + button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + button.setSelection(preference.getValue()); + button.addSelectionListener(new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + preference.setValue(button.getSelection()); + } + }); + } + + public OMPreference getPreference() + { + return preference; + } + + public Button getButton() + { + return button; + } + + protected Button createButton(int buttonStyle) + { + return new Button(this, buttonStyle); + } + + public void addSelectionListener(SelectionListener listener) + { + button.addSelectionListener(listener); + } + + public int getAlignment() + { + return button.getAlignment(); + } + + public Image getImage() + { + return button.getImage(); + } + + public boolean getSelection() + { + return button.getSelection(); + } + + public String getText() + { + return button.getText(); + } + + public void removeSelectionListener(SelectionListener listener) + { + button.removeSelectionListener(listener); + } + + public void setAlignment(int alignment) + { + button.setAlignment(alignment); + } + + public void setImage(Image image) + { + button.setImage(image); + } + + public void setSelection(boolean selected) + { + button.setSelection(selected); + } + + public void setText(String string) + { + button.setText(string); + } +} diff --git a/plugins/org.eclipse.net4j.util/plugin.properties b/plugins/org.eclipse.net4j.util/plugin.properties index dbb165f354..5238578f42 100644 --- a/plugins/org.eclipse.net4j.util/plugin.properties +++ b/plugins/org.eclipse.net4j.util/plugin.properties @@ -24,7 +24,7 @@ # append it to the end of the file, and change the code to use the new name. # ============================================================================== -pluginName=Net4j +pluginName=Net4j Utilities providerName=Eclipse.org # ============================================================================== diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java index 3b0ada5599..f70001cff4 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java @@ -10,6 +10,7 @@ **************************************************************************/ package org.eclipse.net4j.internal.util.bundle; +import org.eclipse.net4j.internal.util.container.PluginTransportContainer; import org.eclipse.net4j.internal.util.om.OSGiBundle; import org.eclipse.net4j.internal.util.om.log.EclipseLoggingBridge; import org.eclipse.net4j.internal.util.om.log.PrintLogHandler; @@ -48,6 +49,11 @@ public abstract class OM private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OM, OM.class); + static void stop() throws Exception + { + PluginTransportContainer.dispose(); + } + /** * @author Eike Stepper */ diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginTransportContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginTransportContainer.java new file mode 100644 index 0000000000..d93e3b754a --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginTransportContainer.java @@ -0,0 +1,74 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.internal.util.container; + +import org.eclipse.net4j.internal.util.bundle.OM; +import org.eclipse.net4j.internal.util.factory.PluginFactoryRegistry; +import org.eclipse.net4j.util.container.IElementProcessor; +import org.eclipse.net4j.util.container.IPluginTransportContainer; +import org.eclipse.net4j.util.factory.IFactory; +import org.eclipse.net4j.util.factory.IFactoryKey; +import org.eclipse.net4j.util.registry.IRegistry; + +import java.util.List; + +/** + * @author Eike Stepper + */ +public class PluginTransportContainer extends ManagedContainer implements IPluginTransportContainer +{ + private static PluginTransportContainer instance; + + private PluginTransportContainer() + { + } + + @Override + protected IRegistry createFactoryRegistry() + { + return new PluginFactoryRegistry(); + } + + @Override + protected List createPostProcessors() + { + return new PluginElementProcessorList(); + } + + public static void dispose() + { + if (instance != null) + { + instance.deactivate(); + instance = null; + } + } + + public static synchronized PluginTransportContainer getInstance() + { + if (instance == null) + { + instance = new PluginTransportContainer(); + + try + { + instance.activate(); + } + catch (Exception ex) + { + OM.LOG.error(ex); + instance = null; + } + } + + return instance; + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java index ca5af16d53..d0789b473c 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java @@ -86,11 +86,6 @@ public class Lifecycle extends Notifier implements ILifecycle.Introspection catch (Exception ex) { OM.LOG.error(ex); - if (TRACER.isEnabled()) - { - TRACER.trace(ex); - } - return ex; } finally diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IPluginTransportContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IPluginTransportContainer.java new file mode 100644 index 0000000000..9ff726e026 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IPluginTransportContainer.java @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.util.container; + +import org.eclipse.net4j.internal.util.container.PluginTransportContainer; + +/** + * @author Eike Stepper + * @since 0.8.0 + */ +public interface IPluginTransportContainer extends IManagedContainer +{ + public static final IPluginTransportContainer INSTANCE = PluginTransportContainer.getInstance(); +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/NIOUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/NIOUtil.java index 831d90c7bc..b87e918a96 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/NIOUtil.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/NIOUtil.java @@ -94,7 +94,8 @@ public final class NIOUtil // checks if (!src.isFile() || !src.exists()) throw new IllegalArgumentException("Source file '" + src.getAbsolutePath() + "' not found!"); - if (dst.exists()) if (dst.isDirectory()) // Directory? -> use source file name + if (dst.exists()) if (dst.isDirectory()) // Directory? -> use source file + // name dst = new File(dst, src.getName()); else if (dst.isFile()) { diff --git a/plugins/org.eclipse.net4j/plugin.xml b/plugins/org.eclipse.net4j/plugin.xml index 158fa0e3eb..34c3a39a3a 100644 --- a/plugins/org.eclipse.net4j/plugin.xml +++ b/plugins/org.eclipse.net4j/plugin.xml @@ -4,6 +4,26 @@ + + + + + + + + + + + diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/AcceptorFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/AcceptorFactory.java index c3e0508cbc..61ea43f189 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/AcceptorFactory.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/AcceptorFactory.java @@ -18,10 +18,10 @@ import org.eclipse.net4j.internal.util.factory.Factory; */ public abstract class AcceptorFactory extends Factory { - public static final String ACCEPTOR_GROUP = "org.eclipse.net4j.acceptors"; + public static final String PRODUCT_GROUP = "org.eclipse.net4j.acceptors"; public AcceptorFactory(String type) { - super(ACCEPTOR_GROUP, type); + super(PRODUCT_GROUP, type); } } diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/BufferProviderFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/BufferProviderFactory.java new file mode 100644 index 0000000000..dd717c4e56 --- /dev/null +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/BufferProviderFactory.java @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.internal.net4j; + +import org.eclipse.net4j.IBufferProvider; +import org.eclipse.net4j.Net4jUtil; +import org.eclipse.net4j.internal.util.factory.Factory; +import org.eclipse.net4j.util.container.IManagedContainer; + +/** + * @author Eike Stepper + */ +public class BufferProviderFactory extends Factory +{ + public static final String PRODUCT_GROUP = "org.eclipse.net4j.bufferProviders"; + + public static final String TYPE = "default"; + + public static final short BUFFER_CAPACITY = 4096; + + public BufferProviderFactory() + { + super(PRODUCT_GROUP, TYPE); + } + + public IBufferProvider create(String description) + { + return Net4jUtil.createBufferPool(BUFFER_CAPACITY); + } + + public static IBufferProvider get(IManagedContainer container) + { + return (IBufferProvider)container.getElement(PRODUCT_GROUP, TYPE, null); + } +} diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/BufferUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/BufferUtil.java index 77c028e7f0..baf4816e86 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/BufferUtil.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/BufferUtil.java @@ -10,8 +10,6 @@ **************************************************************************/ package org.eclipse.internal.net4j; -import org.eclipse.net4j.IBufferProvider; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -35,21 +33,6 @@ public final class BufferUtil { } - public static IBufferProvider getBufferProvider(Object object) - { - if (object instanceof IBufferProvider) - { - return (IBufferProvider)object; - } - - if (object == null) - { - throw new IllegalArgumentException("object == null"); //$NON-NLS-1$ - } - - throw new IllegalArgumentException("Unable to provide buffers: " + object); //$NON-NLS-1$ - } - public static byte[] toUTF8(String str) { if (str == null) diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ClientProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ClientProtocolFactory.java index af73a50a16..b8c95fb228 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ClientProtocolFactory.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ClientProtocolFactory.java @@ -18,10 +18,10 @@ import org.eclipse.net4j.internal.util.factory.Factory; */ public abstract class ClientProtocolFactory extends Factory { - public static final String CLIENT_PROTOCOL_GROUP = "org.eclipse.net4j.clientProtocols"; + public static final String PRODUCT_GROUP = "org.eclipse.net4j.clientProtocols"; public ClientProtocolFactory(String type) { - super(CLIENT_PROTOCOL_GROUP, type); + super(PRODUCT_GROUP, type); } } diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java index 5fa107a89d..8ad2e3e400 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java @@ -578,9 +578,9 @@ public abstract class Connector extends Lifecycle implements IConnector switch (getLocation()) { case SERVER: - return new FactoryKey(ServerProtocolFactory.SERVER_PROTOCOL_GROUP, type); + return new FactoryKey(ServerProtocolFactory.PRODUCT_GROUP, type); case CLIENT: - return new FactoryKey(ClientProtocolFactory.CLIENT_PROTOCOL_GROUP, type); + return new FactoryKey(ClientProtocolFactory.PRODUCT_GROUP, type); default: throw new IllegalStateException(); } diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ConnectorFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ConnectorFactory.java index 5c76abb440..03bdddff08 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ConnectorFactory.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ConnectorFactory.java @@ -18,10 +18,10 @@ import org.eclipse.net4j.internal.util.factory.Factory; */ public abstract class ConnectorFactory extends Factory { - public static final String CONNECTOR_GROUP = "org.eclipse.net4j.connectors"; + public static final String PRODUCT_GROUP = "org.eclipse.net4j.connectors"; public ConnectorFactory(String type) { - super(CONNECTOR_GROUP, type); + super(PRODUCT_GROUP, type); } } diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ExecutorServiceFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ExecutorServiceFactory.java new file mode 100644 index 0000000000..a7834f696d --- /dev/null +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ExecutorServiceFactory.java @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.internal.net4j; + +import org.eclipse.net4j.internal.util.concurrent.NamedExecutorService; +import org.eclipse.net4j.internal.util.factory.Factory; +import org.eclipse.net4j.util.container.IManagedContainer; + +import java.util.concurrent.ExecutorService; + +/** + * @author Eike Stepper + */ +public class ExecutorServiceFactory extends Factory +{ + public static final String PRODUCT_GROUP = "org.eclipse.net4j.executorServices"; + + public static final String TYPE = "default"; + + public ExecutorServiceFactory() + { + super(PRODUCT_GROUP, TYPE); + } + + public ExecutorService create(String description) + { + return new NamedExecutorService(); + } + + public static ExecutorService get(IManagedContainer container) + { + return (ExecutorService)container.getElement(PRODUCT_GROUP, TYPE, null); + } +} diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java new file mode 100644 index 0000000000..d7d30c45a4 --- /dev/null +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java @@ -0,0 +1,66 @@ +package org.eclipse.internal.net4j; + +import org.eclipse.net4j.util.container.IElementProcessor; +import org.eclipse.net4j.util.container.IManagedContainer; + +import java.util.concurrent.ExecutorService; + +/** + * @author Eike Stepper + */ +public class Net4jTransportInjector implements IElementProcessor +{ + public Object process(IManagedContainer container, String productGroup, String factoryType, final String description, + final Object element) + { + if (element instanceof Acceptor) + { + Acceptor acceptor = (Acceptor)element; + if (acceptor.getBufferProvider() == null) + { + acceptor.setBufferProvider(getBufferProvider(container)); + } + + if (acceptor.getReceiveExecutor() == null) + { + acceptor.setReceiveExecutor(getExecutorService(container)); + } + + if (acceptor.getFactoryRegistry() == null) + { + acceptor.setFactoryRegistry(container.getFactoryRegistry()); + } + } + else if (element instanceof Connector) + { + Connector connector = (Connector)element; + if (connector.getBufferProvider() == null) + { + connector.setBufferProvider(getBufferProvider(container)); + } + + if (connector.getReceiveExecutor() == null) + { + connector.setReceiveExecutor(getExecutorService(container)); + } + + if (connector.getFactoryRegistry() == null) + { + connector.setFactoryRegistry(container.getFactoryRegistry()); + } + } + + return element; + } + + public BufferProvider getBufferProvider(IManagedContainer container) + { + return (BufferProvider)container.getElement(BufferProviderFactory.PRODUCT_GROUP, BufferProviderFactory.TYPE, null); + } + + public ExecutorService getExecutorService(IManagedContainer container) + { + return (ExecutorService)container.getElement(ExecutorServiceFactory.PRODUCT_GROUP, ExecutorServiceFactory.TYPE, + null); + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java index 802c7e7fbf..342be62617 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java @@ -10,6 +10,7 @@ **************************************************************************/ package org.eclipse.internal.net4j; +import org.eclipse.net4j.Net4jUtil; import org.eclipse.net4j.IBuffer; import org.eclipse.net4j.IBufferProvider; import org.eclipse.net4j.IChannel; @@ -39,17 +40,17 @@ public abstract class Protocol extends Lifecycle implements IProtocol, IBufferPr public short getBufferCapacity() { - return BufferUtil.getBufferProvider(channel).getBufferCapacity(); + return Net4jUtil.getBufferProvider(channel).getBufferCapacity(); } public IBuffer provideBuffer() { - return BufferUtil.getBufferProvider(channel).provideBuffer(); + return Net4jUtil.getBufferProvider(channel).provideBuffer(); } public void retainBuffer(IBuffer buffer) { - BufferUtil.getBufferProvider(channel).retainBuffer(buffer); + Net4jUtil.getBufferProvider(channel).retainBuffer(buffer); } @Override diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ServerProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ServerProtocolFactory.java index 24b0655111..a648d781f2 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ServerProtocolFactory.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/ServerProtocolFactory.java @@ -18,10 +18,10 @@ import org.eclipse.net4j.internal.util.factory.Factory; */ public abstract class ServerProtocolFactory extends Factory { - public static final String SERVER_PROTOCOL_GROUP = "org.eclipse.net4j.serverProtocols"; + public static final String PRODUCT_GROUP = "org.eclipse.net4j.serverProtocols"; public ServerProtocolFactory(String type) { - super(SERVER_PROTOCOL_GROUP, type); + super(PRODUCT_GROUP, type); } } diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java deleted file mode 100644 index 70958ba571..0000000000 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.internal.net4j; - -import org.eclipse.net4j.IBufferProvider; -import org.eclipse.net4j.ITransportContainer; -import org.eclipse.net4j.BufferUtil; -import org.eclipse.net4j.internal.util.concurrent.NamedExecutorService; -import org.eclipse.net4j.internal.util.container.ManagedContainer; -import org.eclipse.net4j.util.container.IElementProcessor; -import org.eclipse.net4j.util.container.IManagedContainer; - -import java.text.MessageFormat; -import java.util.concurrent.ExecutorService; - -/** - * @author Eike Stepper - */ -public class TransportContainer extends ManagedContainer implements ITransportContainer -{ - private short bufferCapacity; - - public TransportContainer(short bufferCapacity) - { - this.bufferCapacity = bufferCapacity; - putElement(BUFFER_PROVIDER_GROUP, null, null, createBufferProvider()); - putElement(EXECUTOR_SERVICE_GROUP, null, null, createExecutorService()); - addPostProcessor(new PostProcessor()); - } - - public TransportContainer() - { - this(DEFAULT_BUFFER_CAPACITY); - } - - public short getBufferCapacity() - { - return bufferCapacity; - } - - public BufferProvider getBufferProvider() - { - return (BufferProvider)getElement(BUFFER_PROVIDER_GROUP, null, null); - } - - public ExecutorService getExecutorService() - { - return (ExecutorService)getElement(EXECUTOR_SERVICE_GROUP, null, null); - } - - public Acceptor getAcceptor(String type, String description) - { - return (Acceptor)getElement(AcceptorFactory.ACCEPTOR_GROUP, type, description); - } - - public Connector getConnector(String type, String description) - { - return (Connector)getElement(ConnectorFactory.CONNECTOR_GROUP, type, description); - } - - @Override - public String toString() - { - return MessageFormat.format("TransportContainer[{0}]", bufferCapacity); - } - - protected IBufferProvider createBufferProvider() - { - return BufferUtil.createBufferPool(getBufferCapacity()); - } - - protected ExecutorService createExecutorService() - { - return new NamedExecutorService(); - } - - /** - * @author Eike Stepper - */ - private final class PostProcessor implements IElementProcessor - { - public Object process(final IManagedContainer container, final String productGroup, final String factoryType, - final String description, final Object element) - { - if (element instanceof Acceptor) - { - Acceptor acceptor = (Acceptor)element; - if (acceptor.getBufferProvider() == null) - { - acceptor.setBufferProvider(getBufferProvider()); - } - - if (acceptor.getReceiveExecutor() == null) - { - acceptor.setReceiveExecutor(getExecutorService()); - } - - if (acceptor.getFactoryRegistry() == null) - { - acceptor.setFactoryRegistry(getFactoryRegistry()); - } - } - - else if (element instanceof Connector) - { - Connector connector = (Connector)element; - if (connector.getBufferProvider() == null) - { - connector.setBufferProvider(getBufferProvider()); - } - - if (connector.getReceiveExecutor() == null) - { - connector.setReceiveExecutor(getExecutorService()); - } - - if (connector.getFactoryRegistry() == null) - { - connector.setFactoryRegistry(getFactoryRegistry()); - } - } - - return element; - } - } -} diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java index 6e8dea3f57..ef26ae6b2b 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java @@ -43,11 +43,6 @@ public abstract class OM public static final OMLogger LOG = BUNDLE.logger(); - static void stop() throws Exception - { - PluginTransportContainer.dispose(); - } - /** * @author Eike Stepper */ diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/PluginTransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/PluginTransportContainer.java deleted file mode 100644 index 77b3facb0c..0000000000 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/PluginTransportContainer.java +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.internal.net4j.bundle; - -import org.eclipse.net4j.IPluginTransportContainer; -import org.eclipse.net4j.internal.util.container.PluginElementProcessorList; -import org.eclipse.net4j.internal.util.factory.PluginFactoryRegistry; -import org.eclipse.net4j.util.container.IElementProcessor; -import org.eclipse.net4j.util.factory.IFactory; -import org.eclipse.net4j.util.factory.IFactoryKey; -import org.eclipse.net4j.util.registry.IRegistry; - -import org.eclipse.internal.net4j.TransportContainer; - -import java.util.List; - -/** - * @author Eike Stepper - */ -public class PluginTransportContainer extends TransportContainer implements IPluginTransportContainer -{ - private static PluginTransportContainer instance; - - private PluginTransportContainer() - { - } - - @Override - protected IRegistry createFactoryRegistry() - { - return new PluginFactoryRegistry(); - } - - @Override - protected List createPostProcessors() - { - return new PluginElementProcessorList(); - } - - static void dispose() - { - if (instance != null) - { - instance.deactivate(); - instance = null; - } - } - - public static synchronized PluginTransportContainer getInstance() - { - if (instance == null) - { - instance = new PluginTransportContainer(); - - try - { - instance.activate(); - } - catch (Exception ex) - { - OM.LOG.error(ex); - instance = null; - } - } - - return instance; - } -} diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/BufferUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/BufferUtil.java deleted file mode 100644 index 7cb670c96e..0000000000 --- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/BufferUtil.java +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j; - -import org.eclipse.internal.net4j.BufferFactory; -import org.eclipse.internal.net4j.BufferPool; - -/** - * @author Eike Stepper - * @since 0.8.0 - */ -public final class BufferUtil -{ - public static final short DEFAULT_BUFFER_CAPACITY = 4096; - - private BufferUtil() - { - } - - public static IBufferProvider createBufferFactory(short bufferCapacity) - { - return new BufferFactory(bufferCapacity); - } - - public static IBufferProvider createBufferFactory() - { - return createBufferFactory(DEFAULT_BUFFER_CAPACITY); - } - - public static IBufferPool createBufferPool(IBufferProvider factory) - { - return new BufferPool(factory); - } - - public static IBufferPool createBufferPool(short bufferCapacity) - { - return createBufferPool(createBufferFactory(bufferCapacity)); - } - - public static IBufferPool createBufferPool() - { - return createBufferPool(createBufferFactory()); - } - - public static long getProvidedBuffers(IBufferProvider bufferProvider) - { - if (bufferProvider instanceof IBufferProvider.Introspection) - { - return ((IBufferProvider.Introspection)bufferProvider).getProvidedBuffers(); - } - - return -1L; - } - - public static long getRetainedBuffers(IBufferProvider bufferProvider) - { - if (bufferProvider instanceof IBufferProvider.Introspection) - { - return ((IBufferProvider.Introspection)bufferProvider).getRetainedBuffers(); - } - - return -1L; - } - - public static int getPooledBuffers(IBufferPool bufferPool) - { - if (bufferPool instanceof IBufferPool.Introspection) - { - return ((IBufferPool.Introspection)bufferPool).getPooledBuffers(); - } - - return -1; - } -} diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IPluginTransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IPluginTransportContainer.java deleted file mode 100644 index 11b4b1703e..0000000000 --- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IPluginTransportContainer.java +++ /dev/null @@ -1,22 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j; - -import org.eclipse.internal.net4j.bundle.PluginTransportContainer; - -/** - * @author Eike Stepper - * @since 0.8.0 - */ -public interface IPluginTransportContainer extends ITransportContainer -{ - public static final ITransportContainer INSTANCE = PluginTransportContainer.getInstance(); -} diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ITransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ITransportContainer.java deleted file mode 100644 index e23371225d..0000000000 --- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ITransportContainer.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * 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 - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j; - -import org.eclipse.net4j.util.container.IManagedContainer; - -import java.util.concurrent.ExecutorService; - -/** - * @author Eike Stepper - * @since 0.8.0 - */ -public interface ITransportContainer extends IManagedContainer -{ - public static final String EXECUTOR_SERVICE_GROUP = "org.eclipse.net4j.executorServices"; - - public static final String BUFFER_PROVIDER_GROUP = "org.eclipse.net4j.bufferProviders"; - - public static final short DEFAULT_BUFFER_CAPACITY = 4096; - - public short getBufferCapacity(); - - public IBufferProvider getBufferProvider(); - - public ExecutorService getExecutorService(); - - public IAcceptor getAcceptor(String type, String description); - - public IConnector getConnector(String type, String description); -} diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java new file mode 100644 index 0000000000..80cfa1946f --- /dev/null +++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java @@ -0,0 +1,133 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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 + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j; + +import org.eclipse.net4j.util.container.IManagedContainer; + +import org.eclipse.internal.net4j.AcceptorFactory; +import org.eclipse.internal.net4j.BufferFactory; +import org.eclipse.internal.net4j.BufferPool; +import org.eclipse.internal.net4j.BufferProviderFactory; +import org.eclipse.internal.net4j.ConnectorFactory; +import org.eclipse.internal.net4j.ExecutorServiceFactory; +import org.eclipse.internal.net4j.Net4jTransportInjector; + +import java.util.concurrent.ExecutorService; + +/** + * @author Eike Stepper + * @since 0.8.0 + */ +public final class Net4jUtil +{ + public static final short DEFAULT_BUFFER_CAPACITY = 4096; + + private Net4jUtil() + { + } + + public static void prepareContainer(IManagedContainer container) + { + container.registerFactory(new ExecutorServiceFactory()); + container.registerFactory(new BufferProviderFactory()); + container.addPostProcessor(new Net4jTransportInjector()); + } + + public static ExecutorService getExecutorService(IManagedContainer container) + { + return ExecutorServiceFactory.get(container); + } + + public static IBufferProvider getBufferProvider(IManagedContainer container) + { + return BufferProviderFactory.get(container); + } + + public static IAcceptor getAcceptor(IManagedContainer container, String type, String description) + { + return (IAcceptor)container.getElement(AcceptorFactory.PRODUCT_GROUP, type, description); + } + + public static IConnector getConnector(IManagedContainer container, String type, String description) + { + return (IConnector)container.getElement(ConnectorFactory.PRODUCT_GROUP, type, description); + } + + public static IBufferProvider getBufferProvider(Object object) + { + if (object instanceof IBufferProvider) + { + return (IBufferProvider)object; + } + + if (object == null) + { + throw new IllegalArgumentException("object == null"); //$NON-NLS-1$ + } + + throw new IllegalArgumentException("Unable to provide buffers: " + object); //$NON-NLS-1$ + } + + public static IBufferProvider createBufferFactory(short bufferCapacity) + { + return new BufferFactory(bufferCapacity); + } + + public static IBufferProvider createBufferFactory() + { + return createBufferFactory(DEFAULT_BUFFER_CAPACITY); + } + + public static IBufferPool createBufferPool(IBufferProvider factory) + { + return new BufferPool(factory); + } + + public static IBufferPool createBufferPool(short bufferCapacity) + { + return createBufferPool(createBufferFactory(bufferCapacity)); + } + + public static IBufferPool createBufferPool() + { + return createBufferPool(createBufferFactory()); + } + + public static long getProvidedBuffers(IBufferProvider bufferProvider) + { + if (bufferProvider instanceof IBufferProvider.Introspection) + { + return ((IBufferProvider.Introspection)bufferProvider).getProvidedBuffers(); + } + + return -1L; + } + + public static long getRetainedBuffers(IBufferProvider bufferProvider) + { + if (bufferProvider instanceof IBufferProvider.Introspection) + { + return ((IBufferProvider.Introspection)bufferProvider).getRetainedBuffers(); + } + + return -1L; + } + + public static int getPooledBuffers(IBufferPool bufferPool) + { + if (bufferPool instanceof IBufferPool.Introspection) + { + return ((IBufferPool.Introspection)bufferPool).getPooledBuffers(); + } + + return -1; + } +} diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java index 70452ce47e..ee874677ee 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java @@ -16,7 +16,6 @@ import org.eclipse.net4j.internal.util.om.trace.ContextTracer; import org.eclipse.net4j.stream.BufferInputStream; import org.eclipse.net4j.stream.ChannelOutputStream; -import org.eclipse.internal.net4j.BufferUtil; import org.eclipse.internal.net4j.Protocol; import org.eclipse.internal.net4j.bundle.OM; @@ -227,7 +226,7 @@ public abstract class SignalProtocol extends Protocol { super(getChannel(), new IBufferProvider() { - private IBufferProvider delegate = BufferUtil.getBufferProvider(getChannel()); + private IBufferProvider delegate = org.eclipse.net4j.Net4jUtil.getBufferProvider(getChannel()); private boolean firstBuffer = addSignalID; -- cgit v1.2.3